CVE-2021-4456
Received Received - Intake
Leading Zero Handling Flaw in Net::CIDR Enables Access Bypass

Publication date: 2026-02-27

Last updated on: 2026-03-03

Assigner: CPANSec

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.
CVSS Scores
EPSS Scores
Probability:
Percentile:
Meta Information
Published
2026-02-27
Last Modified
2026-03-03
Generated
2026-05-27
AI Q&A
2026-02-27
EPSS Evaluated
2026-05-25
NVD
EUVD
Affected Vendors & Products
Showing 1 associated CPE
Vendor Product Version / Range
mrsam net to 0.24 (exc)
Helpful Resources
Exploitability
CWE
CWE Icon
KEV
KEV Icon
CWE ID Description
CWE-704 The product does not correctly convert an object, resource, or structure from one type to a different type.
Attack-Flow Graph
AI Powered Q&A
Can you explain this vulnerability to me?

CVE-2021-4456 is a vulnerability in the Perl module Net::CIDR versions before 0.24, where the functions addr2cidr and cidrlookup mishandle IP CIDR addresses that contain leading zeros in their octets.

Specifically, these functions may return CIDR strings with leading zeros, which can be interpreted as octal numbers by other software components. This misinterpretation can cause incorrect IP address parsing.

An attacker could exploit this behavior to bypass access controls that rely on IP address matching, by crafting IP addresses with leading zeros that are parsed differently than intended.

Although the module provides a cidrvalidate function to validate untrusted CIDR strings, this validation is optional and not enforced by default, leading to potential misuse.


How can this vulnerability impact me? :

This vulnerability can impact you by allowing attackers to bypass IP-based access controls or security filters that rely on CIDR address parsing.

If your system uses Net::CIDR functions like addr2cidr or cidrlookup on untrusted input without proper validation, attackers might craft IP addresses with leading zeros that are interpreted differently, potentially granting unauthorized access.

This could lead to unauthorized network access, exposure of sensitive resources, or other security breaches depending on how IP address filtering is used in your environment.


How does this vulnerability affect compliance with common standards and regulations (like GDPR, HIPAA)?:

I don't know


How can this vulnerability be detected on my network or system? Can you suggest some commands?

[{'type': 'paragraph', 'content': 'This vulnerability involves mishandling of leading zeros in IP CIDR addresses by the Net::CIDR Perl module, which may cause incorrect IP address parsing and potential bypass of access controls.'}, {'type': 'paragraph', 'content': 'To detect this vulnerability on your system, you should check if your Perl environment uses Net::CIDR versions before 0.24.'}, {'type': 'paragraph', 'content': 'You can verify the installed version of Net::CIDR with the following command:'}, {'type': 'list_item', 'content': 'perl -MNet::CIDR -e \'print $Net::CIDR::VERSION, "\\n"\''}, {'type': 'paragraph', 'content': 'If the version is older than 0.24, your system is potentially vulnerable.'}, {'type': 'paragraph', 'content': "Additionally, you can test if the functions addr2cidr or cidrlookup return CIDR strings with leading zeros by running a Perl script that calls these functions with IP addresses containing leading zeros, for example '010.0.0.1'."}, {'type': 'list_item', 'content': 'perl -MNet::CIDR -e \'use Data::Dumper; print Dumper(Net::CIDR::addr2cidr("010.0.0.1"));\''}, {'type': 'paragraph', 'content': 'If the output contains octets with leading zeros, the vulnerability is present.'}] [1]


What immediate steps should I take to mitigate this vulnerability?

The primary mitigation is to upgrade the Net::CIDR Perl module to version 0.24 or later, where the vulnerability has been fixed by stripping leading zeros from IP address octets in the addr2cidr function.

If upgrading is not immediately possible, ensure that any untrusted CIDR strings are validated using the cidrvalidate() function before being processed by addr2cidr or cidrlookup, as recommended in the documentation.

This validation step helps prevent attackers from exploiting leading zero octets to bypass access controls.

Review your code to avoid calling addr2cidr or cidrlookup with untrusted input without prior validation.


Ask Our AI Assistant
Need more information? Ask your question to get an AI reply (Powered by our expertise)
0/70
EPSS Chart