From 517745a93647c200b059f874735ba30edfe86d7d Mon Sep 17 00:00:00 2001 From: AI 13rac1 Date: Sat, 14 Nov 2026 20:51:20 +0000 Subject: [PATCH 1/2] Fix CT checks of certificates with SCTs from tiled logs only The leaf certificate that rekor.sigstore.dev serves since 2026-11-14 14:05Z carries two SCTs, both from Static CT API (tiled) logs. The CT check found the log of an SCT with loglist3's FindLogByKeyHash, which in certificate-transparency-go v1.3.3 searches only the RFC 6962 logs of the log list and never its tiled logs. Each SCT failed with "SCT log ID not found in trusted log list", so every connection to Rekor failed. Without Rekor, build_transparency_log, provider_signer_recognition and component_signature_recognition fail, and where they are enforced, as for NEAR direct, the model is blocked. A provider host that moves to a certificate with tiled-log SCTs only fails the same way. The check now also looks the log ID up in the tiled logs of the same log list and verifies the SCT with that log's key, in the same way as an SCT of an RFC 6962 log. An SCT of a log that is not in the list still fails. To verify: go test ./internal/tlsct -run TestCheckTLSState_TiledLogSCT. The test fails without the fix with "SCT log ID not found in trusted log list". Co-Authored-By: Claude Opus 5.5 --- internal/tlsct/checker.go | 26 +++++++++-- internal/tlsct/checker_test.go | 84 ++++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+), 3 deletions(-) diff --git a/internal/tlsct/checker.go b/internal/tlsct/checker.go index 2b3372a3..4d9179ea 100644 --- a/internal/tlsct/checker.go +++ b/internal/tlsct/checker.go @@ -3,6 +3,7 @@ package tlsct import ( "context" "crypto/sha256" + "crypto/subtle" "crypto/tls" "crypto/x509" "encoding/hex" @@ -259,12 +260,12 @@ func (c *Checker) checkTLSState( var verifyErrs []string for _, candidate := range scts { - log := logList.FindLogByKeyHash(candidate.sct.LogID.KeyID) - if log == nil { + logKey := findLogKey(logList, candidate.sct.LogID.KeyID) + if logKey == nil { verifyErrs = append(verifyErrs, "SCT log ID not found in trusted log list") continue } - pub, pkErr := ctx509.ParsePKIXPublicKey(log.Key) + pub, pkErr := ctx509.ParsePKIXPublicKey(logKey) if pkErr != nil { verifyErrs = append(verifyErrs, "parse log public key: "+pkErr.Error()) continue @@ -284,6 +285,25 @@ func (c *Checker) checkTLSState( return fmt.Errorf("no valid SCTs: %s", strings.Join(verifyErrs, "; ")) } +// findLogKey returns the public key of the log in ll whose ID is logID, or +// nil. It searches the RFC 6962 logs and the Static CT API (tiled) logs: +// loglist3's FindLogByKeyHash searches only the RFC 6962 logs, and a +// certificate can carry SCTs from tiled logs only. An SCT of a tiled log has +// the same signature form, so the caller verifies both kinds the same way. +func findLogKey(ll *loglist3.LogList, logID [sha256.Size]byte) []byte { + if log := ll.FindLogByKeyHash(logID); log != nil { + return log.Key + } + for _, op := range ll.Operators { + for _, log := range op.TiledLogs { + if subtle.ConstantTimeCompare(log.LogID, logID[:]) == 1 { + return log.Key + } + } + } + return nil +} + func (c *Checker) addCacheEntry(key string) { c.mu.Lock() defer c.mu.Unlock() diff --git a/internal/tlsct/checker_test.go b/internal/tlsct/checker_test.go index c4fe3971..31145524 100644 --- a/internal/tlsct/checker_test.go +++ b/internal/tlsct/checker_test.go @@ -375,6 +375,90 @@ func TestCheckTLSState_SCTLogNotFound(t *testing.T) { t.Logf("SCT not found error: %v", err) } +// An SCT from a Static CT API (tiled) log verifies with the tiled log's key: +// a certificate whose SCTs all come from tiled logs passes. An SCT that the +// tiled log did not sign, or one from a log that is not listed, fails. +func TestCheckTLSState_TiledLogSCT(t *testing.T) { + logKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) + if err != nil { + t.Fatalf("generate log key: %v", err) + } + pubDER, err := x509.MarshalPKIXPublicKey(&logKey.PublicKey) + if err != nil { + t.Fatalf("marshal log key: %v", err) + } + logID := sha256.Sum256(pubDER) + tiledOnly := &loglist3.LogList{Operators: []*loglist3.Operator{{ + Name: "test operator", + TiledLogs: []*loglist3.TiledLog{{Description: "test tiled log", LogID: logID[:], Key: pubDER}}, + }}} + cert := selfSignedCert(t) + + check := func(ll *loglist3.LogList, sct []byte) error { + c := tlsct.NewChecker() + c.InjectLogList(ll) + return c.CheckTLSState(context.Background(), "example.com", &tls.ConnectionState{ + PeerCertificates: []*x509.Certificate{cert}, + SignedCertificateTimestamps: [][]byte{sct}, + }) + } + if err := check(tiledOnly, signedHandshakeSCT(t, logKey, logID, cert)); err != nil { + t.Errorf("SCT of a tiled log: %v", err) + } + + otherKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) + if err != nil { + t.Fatalf("generate other key: %v", err) + } + if err := check(tiledOnly, signedHandshakeSCT(t, otherKey, logID, cert)); err == nil { + t.Error("SCT with the tiled log's ID but another key passed") + } + if err := check(emptyLogList(t), signedHandshakeSCT(t, logKey, logID, cert)); err == nil || + !strings.Contains(err.Error(), "SCT log ID not found in trusted log list") { + t.Errorf("SCT of an unlisted log: %v", err) + } +} + +// signedHandshakeSCT returns a TLS-marshalled SCT for cert, signed by key +// under logID, with the leaf_index extension that a Static CT API log adds. +func signedHandshakeSCT(t *testing.T, key *ecdsa.PrivateKey, logID [32]byte, cert *x509.Certificate) []byte { + t.Helper() + sct := ct.SignedCertificateTimestamp{ + SCTVersion: ct.V1, + LogID: ct.LogID{KeyID: logID}, + Timestamp: uint64(time.Now().UnixMilli()), + Extensions: ct.CTExtensions{0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x2a}, + } + leaf := ct.MerkleTreeLeaf{ + Version: ct.V1, + LeafType: ct.TimestampedEntryLeafType, + TimestampedEntry: &ct.TimestampedEntry{ + Timestamp: sct.Timestamp, + EntryType: ct.X509LogEntryType, + X509Entry: &ct.ASN1Cert{Data: cert.Raw}, + Extensions: sct.Extensions, + }, + } + input, err := ct.SerializeSCTSignatureInput(sct, ct.LogEntry{Leaf: leaf}) + if err != nil { + t.Fatalf("serialize SCT signature input: %v", err) + } + digest := sha256.Sum256(input) + sig, err := ecdsa.SignASN1(rand.Reader, key, digest[:]) + if err != nil { + t.Fatalf("sign SCT: %v", err) + } + sct.Signature = ct.DigitallySigned{ + Algorithm: cttls.SignatureAndHashAlgorithm{Hash: cttls.SHA256, Signature: cttls.ECDSA}, + Signature: sig, + } + raw, err := cttls.Marshal(sct) + if err != nil { + t.Fatalf("marshal SCT: %v", err) + } + return raw +} + // fabricateHandshakeSCT creates a TLS-marshalled SCT with a random LogID. func fabricateHandshakeSCT(t *testing.T) []byte { t.Helper() From bb6eee75fbf01a13a0e996209a7782e035d6829a Mon Sep 17 00:00:00 2001 From: AI 13rac1 Date: Sat, 14 Nov 2026 20:54:32 +0000 Subject: [PATCH 2/2] Check the failure reason of a tiled-log SCT with another key The test of an SCT that carries a listed tiled log's ID but has another key's signature only checked that an error occurred. It now also checks that the log was found and the signature check failed, so a parse error or a missed lookup cannot pass for the expected failure. Co-Authored-By: Claude Opus 5.5 --- internal/tlsct/checker_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/tlsct/checker_test.go b/internal/tlsct/checker_test.go index 31145524..d4eab478 100644 --- a/internal/tlsct/checker_test.go +++ b/internal/tlsct/checker_test.go @@ -410,8 +410,12 @@ func TestCheckTLSState_TiledLogSCT(t *testing.T) { if err != nil { t.Fatalf("generate other key: %v", err) } - if err := check(tiledOnly, signedHandshakeSCT(t, otherKey, logID, cert)); err == nil { + // The log is found, so the failure must come from the signature check. + err = check(tiledOnly, signedHandshakeSCT(t, otherKey, logID, cert)) + if err == nil { t.Error("SCT with the tiled log's ID but another key passed") + } else if !strings.Contains(err.Error(), "no valid SCTs") || strings.Contains(err.Error(), "not found in trusted log list") { + t.Errorf("SCT with another key: %v, want a signature failure of a found log", err) } if err := check(emptyLogList(t), signedHandshakeSCT(t, logKey, logID, cert)); err == nil || !strings.Contains(err.Error(), "SCT log ID not found in trusted log list") {