Skip to content

encoding/pem: Decode method uses extensive CPU when providing large data #50116

@naveensrinivasan

Description

@naveensrinivasan

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

$ go version
17.5

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
go env
GO111MODULE=""
GOARCH="amd64"
GOBIN="/home/sammy/go/bin"
GOCACHE="/home/sammy/.cache/go-build"
GOENV="/home/sammy/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/sammy/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/sammy/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/nix/store/i8x0bv8v69j8c2njymgs4cl3albqc20h-go-1.17.5/share/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/nix/store/i8x0bv8v69j8c2njymgs4cl3albqc20h-go-1.17.5/share/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17.5"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/run/user/1000/go-build3984378223=/tmp/go-build -gno-record-gcc-switches"

What did you do?

As part of fuzz testing sigstore/sigstore#188 using oss-fuzz we ran into an issue where the pem.Decode is consuming extensive CPU and here is the test case for it https://github.com/sigstore/sigstore/files/7676542/clusterfuzz-testcase-minimized-FuzzUnmarshalCertificatesFromPEM-4710187355734016.zip

What did you expect to see?

The pem.Decode finishing sooner than it consumes large amount of CPU

What did you see instead?

It being slow

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.Performance

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions