Repository navigation
fix(verify): reject non-canonical IPv4 origins in CORS proofs - #724
Merged
Merged
Conversation
The Fetch host parser runs the IPv4 parser whenever the last label of a host is a number, and a browser serializes the result as a dotted quad. Legacy spellings such as 0x7f.1, 1.2.3.4.5, 2130706433 or a label with a leading zero are therefore normalized before they can appear in an Origin header. ValidateBrowserOrigin accepted them as ordinary domain labels, so a CORS proof could still be marked verified with an origin no browser sends. A numeric host must now parse as a canonical IPv4 address whose String() equals the host. Domains, canonical dotted quads and localhost are unchanged. The five new rejection cases fail against the previous implementation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #720 by @tausifzaman. The new CORS proof check rejects an
Originthat a browser cannot send, but a host whose last label is numeric still went through the domain-label path, so these origins were accepted:https://1.2.3.4.5https://0x7f.1https://999.1.1.1https://2130706433https://1.2.3.04The Fetch host parser runs the IPv4 parser whenever the last label is a number, and a browser serializes the result as a dotted quad. Those spellings are normalized (or the URL is rejected) before an
Originheader can carry them, so they are the same class of non-browser proof that #720 already refuses for:443or an uppercase host.Behavior change
A numeric host must now parse as a canonical IPv4 address whose
String()equals the host. Canonical dotted quads (127.0.0.1,0.0.0.0,192.0.2.10:8080), domains andlocalhostare unchanged. A numeric TLD does not exist, so no legitimate domain is affected.This is the last gap I documented on #720 after reviewing it; the target still has to reflect the exact origin for a proof to pass, so it is a strictness fix, not an incident.
Tests
db/cors_verification_test.goplus three acceptance cases for canonical IPv4.go build ./...,go vet ./db ./server,gofmton the committed blobs, andgo test ./db -count=1: PASS.Ships in 0.7.1; the existing changelog line already says the proof needs an RFC 6454 serialized origin, so no changelog change.