Skip to content

fix(verify): reject non-canonical IPv4 origins in CORS proofs - #724

Merged
BaaRai merged 1 commit into
mainfrom
fix/cors-ipv4-canonical
Nov 30, 2026
Merged

BaaRai merged 1 commit into
mainfrom
fix/cors-ipv4-canonical

Conversation

@BaaRai

@BaaRai BaaRai commented Nov 30, 2026

Copy link
Copy Markdown
Owner

Summary

Follow-up to #720 by @tausifzaman. The new CORS proof check rejects an Origin that 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.5
  • https://0x7f.1
  • https://999.1.1.1
  • https://2130706433
  • https://1.2.3.04

The 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 Origin header can carry them, so they are the same class of non-browser proof that #720 already refuses for :443 or 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 and localhost are 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

  • Five new rejection cases in db/cors_verification_test.go plus three acceptance cases for canonical IPv4.
  • The five rejection cases fail against the previous implementation (verified by swapping the original file back in) and pass with the fix.
  • go build ./..., go vet ./db ./server, gofmt on the committed blobs, and go test ./db -count=1: PASS.
  • No schema, no config and no other package touched.

Ships in 0.7.1; the existing changelog line already says the proof needs an RFC 6454 serialized origin, so no changelog change.

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.
@BaaRai
BaaRai merged commit 7728faa into main Nov 30, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant