CVE-2021-4456: Net::CIDR versions before 0.24 for Perl mishandle leading zeros in IP CIDR addresses, which may have unspecified impact
Timothy Legge 27 Feb 2026 00:17 UTC
========================================================================
CVE-2021-4456 CPAN Security Group
========================================================================
CVE ID: CVE-2021-4456
Distribution: Net-CIDR
Versions: before 0.24
MetaCPAN: https://metacpan.org/dist/Net-CIDR
VCS Repo: https://github.com/svarshavchik/Net-CIDR
Net::CIDR versions before 0.24 for Perl mishandle leading zeros in IP
CIDR addresses, which may have unspecified impact
Description
-----------
Net::CIDR versions before 0.24 for Perl mishandle leading zeros in IP
CIDR addresses, which may have unspecified impact.
The functions `addr2cidr` and `cidrlookup` may return leading zeros in
a CIDR string, which may in turn be parsed as octal numbers by
subsequent users. In some cases an attacker may be able to leverage
this to bypass access controls based on IP addresses.
The documentation advises validating untrusted CIDR strings with the
`cidrvalidate` function. However, this mitigation is optional and not
enforced by default. In practice, users may call `addr2cidr` or
`cidrlookup` with untrusted input and without validation, incorrectly
assuming that this is safe.
Problem types
-------------
- CWE-704 Incorrect Type Conversion or Cast
Solutions
---------
Use the `cidrvalidate` function on untrusted input before passing to
the affected functions or upgrade to version 0.24 or later
References
----------
https://blog.urth.org/2021/03/29/security-issues-in-perl-ip-address-distros/
https://github.com/svarshavchik/Net-CIDR/commit/e3648c6bc6bdd018f90cca4149c467017d42bd10
https://metacpan.org/dist/Net-CIDR/changes