Skip to content

x/crypto: error parsing even large ASN.1 identifiers #58821

Open
@xinfengliu

Description

@xinfengliu

What version of Go are you using (go version)?

$ go version
go version go1.20.1 darwin/arm64

Does this issue reproduce with the latest release?

Yes on go 1.20.1 .
Similar to #49678 but with an even larger oid: https://oidref.com/1.2.36.20151795998
This caused our program failure to parse a customer's certificate. Error message: x509: invalid certificate policies

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/docker/Library/Caches/go-build"
GOENV="/Users/docker/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/docker/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/docker/go"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.20.1"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/docker/work/codes/go/src/lxf/asn.1-oid-test/go.mod"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/25/fnckz31d0jjfqdhs8yb80lmh0000gn/T/go-build2511654897=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

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

What did you expect to see?

Object Identifier: 1.2.36.20151795998.3.1.1.1
ASN.1 Encoding:    060b2a24cb8990821e03010101
Decode result: true
Object Identifier: 1.2.36.20151795998.3.1.1.1

What did you see instead?

Object Identifier: 1.2.36.20151795998.3.1.1.1
ASN.1 Encoding:    060b2a24cb8990821e03010101
Decode result: false
Object Identifier: 

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions