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/x509: RevocationList.CheckSignatureFrom doesn't check Subject #60728

Open
thierry-f-78 opened this issue Jun 11, 2023 · 2 comments
Open
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@thierry-f-78
Copy link

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

$ go version
go version go1.20.5 darwin/amd64

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
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/thierry/Library/Caches/go-build"
GOENV="/Users/thierry/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/thierry/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/thierry/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.20.5"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/thierry/git/XXX/poc/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 x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/_d/zs7l5ldx1r94fn_qh1zvn1rw0000gn/T/go-build3292834562=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I try to validate CRL files. I use three CA certificate:

  • The first one (ca.pem) is the legit certificate which sign the CRL
  • The second one (ca_very_wrong.pem) is wrong certificate with any key
  • The third one (ca_wrong.pem) is not the right CA certificate but it have the same private key than (ca.pem)

With openssl I observe this behaviour:

$ openssl crl -in ca.crl -CAfile ca.pem -noout
verify OK

$ openssl crl -in ca.crl -CAfile ca_very_wrong.pem -noout
Error getting CRL issuer certificate

$ openssl crl -in ca.crl -CAfile ca_wrong.pem -noout
Error getting CRL issuer certificate

It's the expected behaviour.

With Golang primitives, the last case is true. This behaviour is wrong.

I join zip file with a poc.

What did you expect to see?

I Expect the function CheckSignatureFrom() with certificate ca_wrong.pem return an error

What did you see instead?

Function CheckSignatureFrom() with certificate ca_wrong.pem end with success

poc.zip

@seankhliao seankhliao changed the title verify CRL issuer error: affected/package: crypto/x509 crypto/x509: RevocationList.CheckSignatureFrom doesn't check Subject Jun 11, 2023
@seankhliao seankhliao added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 11, 2023
@seankhliao
Copy link
Member

my reading of RFC 5820 Seection 6.3.3 step g
makes me think that matching the other certificate contents isn't necessary, only that the public key matches.

cc @golang/security

@thierry-f-78
Copy link
Author

thierry-f-78 commented Jun 11, 2023

You're right !

If I understand right the issuer must be checked at the b.1 step according with the distribution point. In my case, I got CRL and CA from configuration, not from certificate, so I understand that i do check the issuer control myself.

so, anyway it's a marginal case !

Note, I'm not familiar with crypto and certificate, but it seems the f step which verify certification chain implies control of the ISSUER. (it is the case for certificates, the function isValid verify issuer - https://cs.opensource.google/go/go/+/refs/tags/go1.20.5:src/crypto/x509/verify.go;drc=36b87f273cc43e21685179dc1664ebb5493d26ae;l=565)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

2 participants