Describe the bug
events.Match.cidr() throws Invalid IP address range at synth time for any IPv6 range that embeds an IPv4 address, and accepts a malformed one.
Regression?
No
Last known working version
n/a
Expected Behavior
Match.cidr('::ffff:192.168.0.1') and Match.cidr('64:ff9b::192.0.2.33/96') should be accepted — both are valid CIDR ranges (RFC 4291 §2.5.5 IPv4-mapped, RFC 6052 NAT64). Match.cidr('::ffff:1dd.1dd.1dd.1dd') should be rejected.
Current Behavior
Error: Invalid IP address range: ::ffff:192.168.0.1
Error: Invalid IP address range: 64:ff9b::192.0.2.33/96
and ::ffff:1dd.1dd.1dd.1dd is accepted.
Reproduction Steps
import { Match } from 'aws-cdk-lib/aws-events';
Match.cidr('2001:db8::/32'); // ok
Match.cidr('::ffff:192.168.0.1'); // throws
Possible Solution
The IPv6 regex in aws-events/lib/event-pattern.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
The same regex is duplicated in aws-ec2/lib/prefix-list.ts and has the same defect.
CDK CLI Version
n/a (synth-time validation)
Framework Version
aws-cdk-lib (current main)
Node.js Version
20.x
OS
macOS
Language
TypeScript
Describe the bug
events.Match.cidr()throwsInvalid IP address rangeat synth time for any IPv6 range that embeds an IPv4 address, and accepts a malformed one.Regression?
No
Last known working version
n/a
Expected Behavior
Match.cidr('::ffff:192.168.0.1')andMatch.cidr('64:ff9b::192.0.2.33/96')should be accepted — both are valid CIDR ranges (RFC 4291 §2.5.5 IPv4-mapped, RFC 6052 NAT64).Match.cidr('::ffff:1dd.1dd.1dd.1dd')should be rejected.Current Behavior
and
::ffff:1dd.1dd.1dd.1ddis accepted.Reproduction Steps
Possible Solution
The IPv6 regex in
aws-events/lib/event-pattern.tslost its backslashes in the embedded-IPv4 alternatives —(25[0-5]|2[0-4]d|1dd|[1-9]?d)matches the literal letterdrather than\d, and the.separator matches any character. Restoring\d,\.and\sfixes it.Additional Information/Context
The same regex is duplicated in
aws-ec2/lib/prefix-list.tsand has the same defect.CDK CLI Version
n/a (synth-time validation)
Framework Version
aws-cdk-lib (current main)
Node.js Version
20.x
OS
macOS
Language
TypeScript