(aws-ec2): PrefixList rejects IPv6 entries with an embedded IPv4 address
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the bug
`ec2.PrefixList` with `addressFamily: IP_V6` refuses to synth if any entry embeds an IPv4 address, and accepts a malformed one.
### Regression?
No
### Last known working version
n/a
### Expected Behavior
`::ffff:192.168.0.1/128` and the NAT64 range `64:ff9b::192.0.2.33/96` should be accepted — both are valid IPv6 CIDRs (RFC 4291 §2.5.5, RFC 6052). `::ffff:1dd.1dd.1dd.1dd/128` should be rejected.
### Current Behavior
```
Error: Invalid IPv6 address range: 64:ff9b::192.0.2.33/96
```
and `::ffff:1dd.1dd.1dd.1dd/128` is accepted.
### Reproduction Steps
```ts
new ec2.PrefixList(this, 'PL', {
addressFamily: ec2.AddressFamily.IP_V6,
entries: [{ cidr: '64:ff9b::192.0.2.33/96' }],
});
```
Plain IPv6 entries (`2001:db8::/32`, `64:ff9b::/96`) and IPv4 prefix lists are unaffected.
### Possible Solution
The IPv6 regex in the `PrefixList` constructor (`aws-ec2/lib/prefix-list.ts`) lost its backslashes in the embedded-IPv4 alternatives — `(25[0-5]|2[0-4]d|1dd|[1-9]?d)` matches the literal letter `d` rather than `\d`, and the `.` separator matches any character. Restoring `\d`, `\.` and `\s` fixes it.
### Additional Information/Context
Same root cause as the duplicated copy of this regex in `aws-events/lib/event-pattern.ts`.
### CDK CLI Version
n/a (synth-time validation)
### Framework Version
aws-cdk-lib (current main)
### Node.js Version
20.x
### OS
macOS
### Language
TypeScript
Contributor guide
Research direction
Start in aws-ec2/lib/prefix-list.ts at the PrefixList constructor's IPv6 validation, then compare the duplicated regex in aws-events/lib/event-pattern.ts. Verify that valid embedded-IPv4 IPv6 CIDRs synth successfully while the malformed address is rejected, without changing plain IPv6 or IPv4 prefix-list behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cloud
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100