fix(tls): handle bracketed IPv6 hostnames in checkServerIdentity#30662
fix(tls): handle bracketed IPv6 hostnames in checkServerIdentity#30662Abioy wants to merge 1 commit into
Conversation
Strip IPv6 literal brackets before net.isIP() check, since
net.isIP("[::1]") returns 0. The brackets are a URL convention,
not part of the actual address, so they must be removed before
IP validation and matching.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThis PR fixes IPv6 server identity validation in Node.js TLS by stripping bracket literals ( ChangesIPv6 Server Identity Validation
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Abioy
left a comment
There was a problem hiding this comment.
Reviewed in CodeRabbit Change Stack
Strip IPv6 literal brackets before net.isIP() check, since net.isIP("[::1]") returns 0. The brackets are a URL convention, not part of the actual address, so they must be removed before IP validation and matching.
What does this PR do?
Fixes
tls.checkServerIdentityrejecting valid IPv6 hostnames in bracket form like[::1]or[2001:db8::1]. The brackets are a URL convention for IPv6 literals, not part of the actual IP address. Previously,net.isIP("[::1]")returned0(not an IP), causing the function to incorrectly treat it as a DNS name and always fail validation.How did you verified your code works?
net.isIP()correctly:[::1]→::1→isIP=6test-tls-check-server-identity.jscontinue to pass::1, bracketed[::1], uppercase[2001:DB8::1], mismatched addresses, and bracketed IP against DNS-only SAN