Skip to content

Reject IPv4-mapped IPv6 addresses in IPAddr's IsLoopback and IsMulticast#157

Merged
kjamieson-sdm merged 1 commit into
cedar-policy:mainfrom
strongdm:kjamieson/is-loopback-exclude-4-in-6
Jun 1, 2026
Merged

Reject IPv4-mapped IPv6 addresses in IPAddr's IsLoopback and IsMulticast#157
kjamieson-sdm merged 1 commit into
cedar-policy:mainfrom
strongdm:kjamieson/is-loopback-exclude-4-in-6

Conversation

@kjamieson-sdm

Copy link
Copy Markdown
Collaborator

Issue #, if available:

#152

Description of changes:

This PR updates IPAddr's IsLoopback and IsMulticast methods to reject IPv4-mapped IPv6 addresses to conform to the behavior of Cedar Rust.

The Rust standard library, and therefore the Cedar Rust implementation, has different behavior from Go's standard library with respect to IPv4-mapped IPv6 addresses.

In Cedar Rust, an IPv4 loopback address encoded as an IPv4-mapped IPv6 address (such as ::ffff:127.0.0.1) is not considered to be a valid loopback address.

Similarily, an IPv4 multicast address encoded as an IPv4-mapped IPv6 address (such as ::ffff:224.0.0.0) is not considered to be a valid multicast address.

The Go standard library, in contrast, unwraps such addresses and therefore Cedar Go would consider those addresses to be valid loopback and multicast addresses, respectively.

This patch modifies Cedar Go's IsLoopback and IsMulticast implementation to explicitly check for IPv4-mapped IPv6 addresses and reject those, to conform to the behavior of Cedar Rust.

@kjamieson-sdm kjamieson-sdm force-pushed the kjamieson/is-loopback-exclude-4-in-6 branch from fc241d8 to eae5d6e Compare June 1, 2026 20:31
…sMulticast

The Rust standard library, and therefore the Cedar Rust implementation, has different
behavior from Go's standard library with respect to IPv4-mapped IPv6 addresses.

In Cedar Rust, an IPv4 loopback address encoded as an IPv4-mapped IPv6 address
(such as ::ffff:127.0.0.1) is not considered to be a valid loopback address.

Similarily, an IPv4 multicast address encoded as an IPv4-mapped IPv6 address
(such as ::ffff:224.0.0.0) is not considered to be a valid multicast address.

The Go standard library, in contrast, unwraps such addresses and therefore
Cedar Go would consider those addresses to be valid loopback and multicast
addresses, respectively.

This patch modifies Cedar Go's IsLoopback and IsMulticast implementation to
explicitly check for IPv4-mapped IPv6 addresses and reject those, to conform to
the behavior of Cedar Rust.

Signed-off-by: Kevin Jamieson <kevin.jamieson@delinea.com>
@kjamieson-sdm kjamieson-sdm force-pushed the kjamieson/is-loopback-exclude-4-in-6 branch from eae5d6e to 9005ab6 Compare June 1, 2026 20:32
@kjamieson-sdm kjamieson-sdm merged commit cda92d0 into cedar-policy:main Jun 1, 2026
2 checks passed
@kjamieson-sdm kjamieson-sdm linked an issue Jun 1, 2026 that may be closed by this pull request
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.

IsLoopback returns true for 4-in-6 loopback addresses

2 participants