Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crypto/ecdsa: signature verification succeeds when it should fail #42340

Closed
guidovranken opened this issue Nov 2, 2020 · 4 comments
Closed
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@guidovranken
Copy link

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

go version devel +b53df56 Fri Oct 30 19:00:33 2020 +0000 linux/amd64

Does this issue reproduce with the latest release?

I think so.

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

GO111MODULE="off"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/jhg/.cache/go-build"
GOENV="/home/jhg/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/mnt/2tb/golang/go/packages/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/mnt/2tb/golang/go/packages"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/mnt/2tb/golang/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/mnt/2tb/golang/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build057338421=/tmp/go-build -gno-record-gcc-switches"

What did you do?

https://play.golang.org/p/cpkYx0J-eh5

What did you expect to see?

Console output:

false

What did you see instead?

Console output:

true

Notes

Found with fuzzing, hence the odd values.

@toothrot toothrot changed the title ECDSA signature verification succeeds when it should fail crypto/ecdsa: signature verification succeeds when it should fail Nov 2, 2020
@toothrot
Copy link
Contributor

toothrot commented Nov 2, 2020

/cc @FiloSottile

@toothrot toothrot added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Nov 2, 2020
@toothrot toothrot added this to the Backlog milestone Nov 2, 2020
@FiloSottile
Copy link
Contributor

FiloSottile commented Dec 8, 2020

It looks like the public key point is not on the curve, so I don't think there is any defined behavior we're supposed to follow here. As an issue it seems harmless because 1) any public key decoding function like elliptic.Unmarshal or x509.ParsePKIXPublicKey will check that the point is on the curve and 2) an attacker generally doesn't control the ECDSA public key, or they would just pick one for which they know the private key.

https://play.golang.org/p/DfYlrn_lObX

Is there anything particular about this input? Why should it fail verification?

@fasmat
Copy link

fasmat commented Dec 8, 2020

To add to @FiloSottile s response:

If for some reason you parse the PublicKey yourself, you can easily check if it's a valid public key by calling elliptic.CurveParams.IsOnCurve(x, y):

https://play.golang.org/p/YxY4nJ8k8Nm

But consider using parsing functions provided by the standard library. They check for you if the provided public key is valid.

@FiloSottile FiloSottile added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Dec 8, 2020
@gopherbot
Copy link

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@golang golang locked and limited conversation to collaborators Jan 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

5 participants