Skip to content

Set /128 suffix in single-address IPv6 CIDR - #174

Merged
Mzack9999 merged 1 commit into
projectdiscovery:mainfrom
MarkOtzen:bugfix/ipv6-128-cidr
Mar 19, 2026
Merged

Set /128 suffix in single-address IPv6 CIDR#174
Mzack9999 merged 1 commit into
projectdiscovery:mainfrom
MarkOtzen:bugfix/ipv6-128-cidr

Conversation

@MarkOtzen

Copy link
Copy Markdown
Contributor

The asCidr() helper in networkpolicy.go unconditionally appended a /32 suffix to bare IP addresses. This is correct for IPv4 but invalid for IPv6, where the single-host prefix length is /128.

asCidr() now parses the address to determine its family before appending the suffix (/32 for IPv4, /128 for IPv6). If parsing fails, the original string is passed through to netip.ParsePrefix, which will surface the error as before.

@neo-by-projectdiscovery-dev

neo-by-projectdiscovery-dev Bot commented Feb 25, 2026

Copy link
Copy Markdown

Neo - PR Security Review

No security issues found

Highlights

  • Updates asCidr() helper to detect IP address family (IPv4 vs IPv6) before appending CIDR suffix
  • Appends /32 for IPv4 addresses and /128 for IPv6 addresses (previously always used /32)
  • Adds comprehensive test coverage for IPv4/IPv6 address and CIDR handling
Hardening Notes
  • Consider adding validation in New() to log or warn when deny list entries fail both CIDR and regex parsing, as they would be silently ignored in the current implementation

Comment @neo help for available commands. · Open in Neo

@Mzack9999 Mzack9999 linked an issue Mar 19, 2026 that may be closed by this pull request
@Mzack9999
Mzack9999 merged commit 3abcddf into projectdiscovery:main Mar 19, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support single-address IPv6 CIDR handling

2 participants