Skip to content

Allow configurable client signing algorithms#1938

Merged
Hayden-IO merged 9 commits into
sigstore:mainfrom
trail-of-forks:configurable-crypto
Feb 14, 2025
Merged

Allow configurable client signing algorithms#1938
Hayden-IO merged 9 commits into
sigstore:mainfrom
trail-of-forks:configurable-crypto

Conversation

@ret2libc

@ret2libc ret2libc commented Feb 5, 2025

Copy link
Copy Markdown
Contributor

Summary

This PR adds a --client-signing-algorithms flag to Fulcio to restrict what key/hash combinations are allowed.

Closes #1388
This is based on #1517, but I could not mark it as Ready because done by @tetsuo-cpp .

Release Note

Documentation

ret2libc and others added 3 commits January 30, 2025 11:49
Co-authored-by: Alex Cameron <asc@tetsuo.sh>
Co-authored-by: Riccardo Schirone <riccardo.schirone@trailofbits.com>
Signed-off-by: Alex Cameron <asc@tetsuo.sh>
Signed-off-by: Riccardo Schirone <riccardo.schirone@trailofbits.com>
Signed-off-by: Riccardo Schirone <riccardo.schirone@trailofbits.com>
Signed-off-by: Riccardo Schirone <riccardo.schirone@trailofbits.com>
@ret2libc

ret2libc commented Feb 5, 2025

Copy link
Copy Markdown
Contributor Author

cc @haydentherapper

@ret2libc ret2libc marked this pull request as draft February 5, 2025 18:02
@ret2libc ret2libc force-pushed the configurable-crypto branch from f046e70 to 5d81096 Compare February 6, 2025 09:33
@ret2libc ret2libc marked this pull request as ready for review February 6, 2025 09:35
Signed-off-by: Riccardo Schirone <riccardo.schirone@trailofbits.com>
@ret2libc ret2libc force-pushed the configurable-crypto branch from 5d81096 to 277af89 Compare February 6, 2025 10:15
@codecov

codecov Bot commented Feb 7, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 52.70270% with 35 lines in your changes missing coverage. Please review.

Project coverage is 51.80%. Comparing base (cf238ac) to head (811b363).
Report is 301 commits behind head on main.

Files with missing lines Patch % Lines
pkg/server/grpc_server.go 52.63% 15 Missing and 3 partials ⚠️
cmd/app/serve.go 50.00% 16 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1938      +/-   ##
==========================================
- Coverage   57.93%   51.80%   -6.14%     
==========================================
  Files          50       73      +23     
  Lines        3119     5683    +2564     
==========================================
+ Hits         1807     2944    +1137     
- Misses       1154     2463    +1309     
- Partials      158      276     +118     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Riccardo Schirone <riccardo.schirone@trailofbits.com>
Signed-off-by: Riccardo Schirone <riccardo.schirone@trailofbits.com>

@Hayden-IO Hayden-IO left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two tiny comments, looks great otherwise, thanks!

Comment thread cmd/app/serve.go
Comment thread cmd/app/serve.go
Signed-off-by: Riccardo Schirone <riccardo.schirone@trailofbits.com>
Comment thread pkg/server/grpc_server.go
Comment on lines +149 to +153
// The proof of possession signature always uses SHA-256, unless the key algorithm is ED25519
hashFunc = crypto.SHA256
if _, ok := publicKey.(ed25519.PublicKey); ok {
hashFunc = crypto.Hash(0)
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was testing the Cosign changes and I've realized this is not good in general.

Something like this seems to work:

		switch pk := publicKey.(type) {
		case ed25519.PublicKey:
			// Fulcio only works with PureEd25519
			hashFunc = crypto.Hash(0)
		case *ecdsa.PublicKey:
			switch pk.Curve {
			case elliptic.P256():
				hashFunc = crypto.SHA256
			case elliptic.P384():
				hashFunc = crypto.SHA384
			case elliptic.P521():
				hashFunc = crypto.SHA512
			default:
				hashFunc = crypto.SHA256
			}
		case *rsa.PublicKey:
			hashFunc = crypto.SHA256
		default:
			hashFunc = crypto.SHA256
		}

		// Check proof of possession signature
		if err := challenges.CheckSignatureWithOpts(publicKey, proofOfPossession, principal.Name(ctx), options.WithHash(hashFunc)); err != nil {
			return nil, handleFulcioGRPCError(ctx, codes.InvalidArgument, err, invalidSignature)
		}

@haydentherapper what do you think about this?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a breaking change? Currently, it's assumed that the digest is always SHA256 regardless of key type.

Can we work around this and note this as something to correct in a major version bump?

What about other clients as well? -python for example, is it always using sha256? Or has it just so happened that we didn't notice this because only RSA and ECDSA-P256 keys have been used?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a breaking change? Currently, it's assumed that the digest is always SHA256 regardless of key type.

I guess it is, yes. Right now even if you use a elliptic.P384, you use sha256 so this would break things.

What about other clients as well? -python for example, is it always using sha256? Or has it just so happened that we didn't notice this because only RSA and ECDSA-P256 keys have been used?

sigstore-python always uses sha256 (https://github.com/sigstore/sigstore-python/blob/main/sigstore/sign.py#L158).

Can we work around this and note this as something to correct in a major version bump?

Ok I think we can get away with just enforcing SHA256 when doing SignMessage for the fulcio proof of possesion. We probably need to pay attention to just ed25519 because it would fail in that case, but apart from that it should be good.

Thanks for the feedback!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tracking for Fulcio v2 in #1945.

@Hayden-IO

Copy link
Copy Markdown
Contributor

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow configurable client signing algorithms

2 participants