Repository navigation
Description
Summary
validate.NormalizeDomain can return a domain that still ends in a dot, and it does not treat Unicode full stops (。, ., 。) as label separators. The result is a target that is not in canonical form, and normalising it a second time gives a different answer.
Where
internal/validate/validate.go:116(NormalizeDomain):strings.TrimSuffix(s, ".")removes only one dot, and runs before the IDN conversioninternal/validate/validate.go(Domain): accepts a name ending in a dot
Details
Observed at 69ab79a:
| input | result |
|---|---|
example.com.. |
example.com. (accepted) |
bücher.example.. |
xn--bcher-kva.example. (accepted) |
bücher.example。 |
xn--bcher-kva.xn--example-dp3f (the full stop becomes part of a label) |
bücher.example.。 |
xn--bcher-kva.example.xn--r6j |
IDNA (UTS #46) maps U+3002, U+FF0E and U+FF61 to ., so a pasted Japanese or Chinese domain ending in 。 should be read as that domain, not as one with an extra label.
Found by a fuzz target added for #259 (FuzzNormalizeDomain: an accepted domain should normalise to itself).
Impact
Low. A target typed or pasted with a trailing .. or an ideographic full stop is scanned under a name that is not the user's domain (or with a stray trailing dot in output and diffs), and different entry points may disagree on the canonical form.
Steps to reproduce
go test -run '^$' -fuzz '^FuzzNormalizeDomain$' -fuzztime 30s ./internal/validate/, or- Call
validate.NormalizeDomain("example.com..")and see"example.com."with no error.
Suggested fix
Map the Unicode full stops to . before splitting, trim every trailing dot (or reject more than one), and make Domain reject a trailing dot so non-canonical names cannot pass. Add the inputs above to validate_test.go.
Acceptance criteria
-
NormalizeDomainnever returns a name ending in.. -
bücher.example。normalises toxn--bcher-kva.example. -
FuzzNormalizeDomainruns for a few minutes without failures.
Getting started
- Relevant files:
internal/validate/validate.go,internal/validate/validate_test.go,internal/validate/fuzz_test.go - How to run tests:
go test ./internal/validate/ - Related docs:
docs/cli.md(target normalisation)
Related: #54
Filed by repo-audit/fix-issues at 69ab79a. Severity: low. Effort: S. audit-key: bug|internal/validate/validate.go|NormalizeDomain-trailing-dot
Activity
Add fuzz targets and skip over-long Wayback lines (#259)
Note the #281 fix in the changelog and fuzz target