fix(ec2): PrefixList rejects IPv6 entries with an embedded IPv4 address - #38474
fix(ec2): PrefixList rejects IPv6 entries with an embedded IPv4 address#38474devteamaegis wants to merge 1 commit into
PrefixList rejects IPv6 entries with an embedded IPv4 address#38474Conversation
The IPv6 validation regex in the PrefixList constructor lost its backslashes, so each embedded-IPv4 octet group matches the literal letter 'd' rather than \d, and the '.' separator matches any character. An IPv6 prefix list containing '::ffff:192.168.0.1/128' or the NAT64 range '64:ff9b::192.0.2.33/96' therefore failed to synth with 'Invalid IPv6 address range', while '::ffff:1dd.1dd.1dd.1dd/128' was accepted. Restore \d, \. and \s in that group.
There was a problem hiding this comment.
The pull request linter fails with the following errors:
❌ Fixes must contain a change to an integration test file and the resulting snapshot.
If you believe this pull request should receive an exemption, please comment and provide a justification. A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed, add Clarification Request to a comment.
✅ A exemption request has been requested. Please wait for a maintainer's review.
PrefixList rejects IPv6 entries with an embedded IPv4 address
|
Exemption Request This change is confined to a client-side validation regex in the I'd rather be upfront about why I'm asking for the exemption rather than just adding a test file: I have no AWS account to deploy against, so I cannot produce a deploy-backed snapshot. I could generate one from synth alone, but that would assert a deployment I never actually ran, and for this particular change that distinction matters — whether the EC2 API accepts a given embedded-IPv4 range in an IPv6 prefix list is genuinely something I have not verified, and I don't want to imply otherwise by shipping a snapshot. What is not in question is that the regex is broken in both directions. It reads so The two unit tests in If you'd prefer this gated behind an integration test, I'm glad to write |
|
Exemption Request This is a validation-only change: one line in It only changes which entry strings are accepted at synth time — for any input that already synthesized, the emitted It's fully covered by the unit tests added in |
Issue # (if applicable)
Closes #38476.
Reason for this change
ec2.PrefixListwithaddressFamily: IP_V6refuses to synth if any entry embeds an IPv4 address, and accepts a nonsense one.Affected: any address written with an embedded IPv4 part —
::ffff:a.b.c.d,2001:db8::a.b.c.d. Plain IPv6 (2001:db8::/32,64:ff9b::/96) and IPv4 prefix lists are unaffected.To be precise about the scope of the claim: this is about client-side validation only. Whether EC2 itself accepts a given embedded-IPv4 range at deploy time is a separate question — and one this regex is not the right place to settle. What is not in question is that the regex as written is broken in both directions: it rejects syntactically valid addresses and accepts
::ffff:1dd.1dd.1dd.1dd.Description of changes
The regex in the
PrefixListconstructor lost its backslashes in the embedded-IPv4 alternatives:dmatches the literal letterd, not\d, and the separator.matches any character.192cannot match[1-9]?d, so every real address is rejected — and1ddmatches literally, so the malformed one passes.s*(for\s*) is wrong the same way.This restores
\d,\.and\s— 14 occurrences, one line, no structural change.The identical regex is also in
aws-events/lib/event-pattern.ts(Match.cidr); that copy is fixed separately in #38473. The two modules cannot share a helper, so both need the correction.Describe any new or updated permissions being added
None.
Description of how you validated changes
Two unit tests added in
aws-ec2/test/prefix-list.test.ts— one asserting the synthesizedAWS::EC2::PrefixListentries, one asserting a malformed embedded address is still rejected. Both fail onmain:and pass with the change.
jest aws-ec2/test/prefix-list.test.ts: 16 passed. ESLint clean.Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license