Skip to content

x/net/idna: Punycode labels ending with hyphen (xn--example-) should be rejected per updated UTS-46 #74330

Open
@KageShiron

Description

@KageShiron

Go version

go version go1.24.4 linux/amd64

Output of go env in your module/workspace:

AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN='/home/kiso/.local/share/mise/installs/go/1.24.4/bin'
GOCACHE='/home/kiso/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/kiso/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1616535208=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/kiso/s/golang/text/go.mod'
GOMODCACHE='/home/kiso/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/kiso/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/kiso/.local/share/mise/installs/go/1.24.4'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/kiso/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/kiso/.local/share/mise/installs/go/1.24.4/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.24.4'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

https://go.dev/play/p/Yn4dKzNY2Tr

What did you see happen?

.com <nil>
example.com <nil>

What did you expect to see?

Go's IDNA implementation currently accepts Punycode labels ending with hyphens (e.g., "xn--example-") and produces unexpected results.
UTS-46 Revision 33 now specifies these should be treated as errors.
https://www.unicode.org/reports/tr46/tr46-33.html#Modifications

This issue was already partially noted as a TODO in Go's IDNA test files:
https://github.com/golang/text/blob/master/internal/export/idna/idna10.0.0_test.go

I reported a similar issue in rust-url, which led to the specification being updated.

I have a local fix ready and would like to contribute it.
Should this be filed against x/text/idna since the relevant code appears to be generated?

Note:
I initially reported this to Google Bug Hunters, but was advised to report it on GitHub since it's not a sensitive security issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    LibraryProposalIssues describing a requested change to the Go standard library or x/ libraries, but not to a tool

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions