Skip to content

IDN targets skip Unicode normalization; use x/net/idna UTS #46 mapping #435

Closed

Description

@TMHSDigital

Summary

IDN targets are converted with a hand-written RFC 3492 encoder after a plain strings.ToLower, with no Unicode normalization. A domain pasted in decomposed form (for example café as e + U+0301, common in text copied from macOS) encodes to a different xn-- label than the registered name, so subenum scans a domain that does not exist and reports nothing. golang.org/x/net is already a direct dependency, and its idna package does full UTS #46 mapping.

Where

Details

s = strings.ToLower(strings.TrimRight(s, "."))
if !isASCII(s) {
    ascii, ierr := toASCII(s)

ToLower does not apply NFC, compatibility mapping (full-width letters), or UTS #46's disallowed-character checks. Full stops are handled separately (#281), so this is the remaining part of the known limitation.

Impact

Users targeting internationalized domains can get an empty result with exit 0 and no warning, because the scan ran against the wrong apex. The roadmap lists this as a known limitation, not a tracked task.

Suggested fix

Replace toASCII with idna.Lookup.ToASCII (or a idna.New(idna.MapForLookup(), idna.BidiRule(), ...) profile) from golang.org/x/net/idna, keep the existing "using the punycode form" note, and delete punycode.go. Note: x/net/idna imports golang.org/x/text, so go.mod gains that module. Per the repo's rules it must keep the go 1.26.0 directive and pass govulncheck in CI. Then drop the limitation from docs/ROADMAP.md.

Acceptance criteria

  • NFC and NFD spellings of the same name normalize to the same xn-- form (table test in internal/validate).
  • Full-width ASCII input (example.com) maps to example.com.
  • Disallowed code points return a clear error.
  • The ROADMAP known-limitation line is removed.

Getting started

  • Relevant files: internal/validate/validate.go, internal/validate/punycode.go, go.mod
  • How to run tests: go test ./internal/validate/

Filed by repo-audit/feature-ideas at 090df0a. Severity: low. Effort: S. audit-key: enhancement|internal/validate/validate.go|NormalizeDomain-uts46

Activity

  1. added
    enhancement
    good first issue
    severity: low
    on Nov 18, 2026
  2. TMHSDigital commented on Nov 18, 2026

    @TMHSDigital
    OwnerAuthor

    Fixed in f967e6a. Non-ASCII labels now go through golang.org/x/net/idna (lookup profile: nontransitional UTS #46 with the bidi rule) before Punycode, replacing the hand-written encoder. ASCII labels are left alone, so _dmarc and a * wildcard still pass. A disallowed code point is an error naming the label. go.mod gains golang.org/x/text (indirect, via x/net/idna); the go 1.26.0 directive is unchanged, go mod tidy -diff is clean and govulncheck v1.9.0 reports no vulnerabilities. The ROADMAP known-limitation line is removed.

    Verified: TestToASCII now includes NFC and NFD spellings of café (both xn--caf-dma), full-width example.com to example.com, and the _dmarc/* pass-through; TestNormalizeDomainIDNMapping checks the same end to end plus errors for a C1 control and a bidi mark. CI green.

  3. added a commit that references this issue on Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementgood first issueseverity: low

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions