Skip to content

Commit

Permalink
Verify certificate validity with only current time
Browse files Browse the repository at this point in the history
Using a certificate's NBF will always pass the time verification. We
should be using only the current time to try to verify a certificate's
validity. This is likely to only work with long-lived certificates or
where verification happens immediately after signing.

Fixes sigstore#276

Signed-off-by: Hayden Blauzvern <[email protected]>
  • Loading branch information
haydentherapper committed Aug 19, 2024
1 parent f9235ff commit 6e31232
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
14 changes: 2 additions & 12 deletions pkg/verify/signed_entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -724,18 +724,8 @@ func (v *SignedEntityVerifier) VerifyObserverTimestamps(entity SignedEntity, log
}

if v.config.weDoNotExpectAnyObserverTimestamps {
// if we have a cert, let's pop the leafcert's NotBefore
verificationContent, err := entity.VerificationContent()
if err != nil {
return nil, err
}

if leafCert := verificationContent.GetCertificate(); leafCert != nil {
verifiedTimestamps = append(verifiedTimestamps, TimestampVerificationResult{Type: "LeafCert.NotBefore", URI: "", Timestamp: leafCert.NotBefore})
} else {
// no cert? use current time
verifiedTimestamps = append(verifiedTimestamps, TimestampVerificationResult{Type: "CurrentTime", URI: "", Timestamp: time.Now()})
}
// use current time to verify certificate if no signed timestamps are provided
verifiedTimestamps = append(verifiedTimestamps, TimestampVerificationResult{Type: "CurrentTime", URI: "", Timestamp: time.Now()})
}

if len(verifiedTimestamps) == 0 {
Expand Down
4 changes: 2 additions & 2 deletions pkg/verify/signed_entity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func TestEntitySignedByPublicGoodWithoutTimestampsVerifiesSuccessfully(t *testin
tr := data.PublicGoodTrustedMaterialRoot(t)
entity := data.SigstoreJS200ProvenanceBundle(t)

v, err := verify.NewSignedEntityVerifier(tr, verify.WithoutAnyObserverTimestampsUnsafe())
v, err := verify.NewSignedEntityVerifier(tr, verify.WithTransparencyLog(1), verify.WithIntegratedTimestamps(1))
assert.NoError(t, err)

res, err := v.Verify(entity, SkipArtifactAndIdentitiesPolicy)
Expand Down Expand Up @@ -204,7 +204,7 @@ func TestEntityWithOthernameSan(t *testing.T) {
tr := data.ScaffoldingTrustedMaterialRoot(t)
entity := data.OthernameBundle(t)

v, err := verify.NewSignedEntityVerifier(tr, verify.WithoutAnyObserverTimestampsUnsafe())
v, err := verify.NewSignedEntityVerifier(tr, verify.WithTransparencyLog(1), verify.WithIntegratedTimestamps(1))
assert.NoError(t, err)

digest, err := hex.DecodeString("bc103b4a84971ef6459b294a2b98568a2bfb72cded09d4acd1e16366a401f95b")
Expand Down

0 comments on commit 6e31232

Please sign in to comment.