Skip to content

fix(identity): harden HTTP clients and add TLS cert pinning for JWKS fetch (PILOT-241)#88

Open
matthew-pilot wants to merge 1 commit into
mainfrom
openclaw/pilot-241-20260629-214234
Open

fix(identity): harden HTTP clients and add TLS cert pinning for JWKS fetch (PILOT-241)#88
matthew-pilot wants to merge 1 commit into
mainfrom
openclaw/pilot-241-20260629-214234

Conversation

@matthew-pilot

Copy link
Copy Markdown
Collaborator

What changed

sharedHTTPClient hardening

  • Disabled HTTP redirects on the identity webhook HTTP client (previously followed up to 10 redirects by default)
  • Enforced TLS 1.2 minimum version

TLS certificate pinning for JWKS fetch (PILOT-241)

  • New jwksPinnedHTTPClient() helper that returns a hardened HTTP client which verifies the server TLS certificate fingerprint (SHA-256 of DER-encoded cert) against a configured pin
  • New GetKeyWithPinning() method on JWKSCache — fetches JWKS keys with optional TLS fingerprint verification
  • New FetchJWKSKeysWithPinning() exported function for direct use by external callers
  • HandleValidateToken now uses the Store’s pinned fingerprint (when configured) during JWKS key fetch
  • Store.SetPinnedCertFingerprint() / Store.GetPinnedCertFingerprint() for runtime configuration

Why

PILOT-241 reported that the OIDC/JWKS fetch path followed up to 10 redirects and had no TLS certificate pinning. The redirect + TLS minimum version parts were already addressed via jwksHTTPClient in the original implementation. This PR:

  1. Extends the same hardening to sharedHTTPClient (used by the identity webhook path)
  2. Adds certificate pinning infrastructure to prevent MITM attacks during JWKS key fetch

Verification

  • go build ./... — clean
  • go vet ./... — clean
  • go test ./... — all passing (including identity package)

Closes PILOT-241

…fetch (PILOT-241)

Harden sharedHTTPClient used for identity webhook calls: disable redirects
(redirect is a protocol anomaly) and enforce TLS 1.2 minimum version.

Add TLS certificate pinning support for JWKS key fetch:
- New jwksPinnedHTTPClient helper returns a client that verifies the
  server's TLS certificate fingerprint (SHA-256 of DER) against a
  configured pin, rejecting MITM who serve a different certificate.
- New GetKeyWithPinning method on JWKSCache accepts a pinning fingerprint.
- New FetchJWKSKeysWithPinning exported function for external callers.
- HandleValidateToken uses the Store's pinned fingerprint when fetching
  JWKS keys.
- SetPinnedCertFingerprint / GetPinnedCertFingerprint on Store for runtime
  configuration (future: migrate to BlueprintIdentityProvider field).

Previously sharedHTTPClient had no redirect protection and no TLS
minimum. JWKS fetch was already hardened with jwksHTTPClient but
lacked certificate pinning.

Closes PILOT-241
@codecov

codecov Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Comment thread identity/identity.go
// the actual cert verification via fingerprint check. The standard
// chain verification is bypassed to allow self-signed or
// non-CA-signed certs that match the pinned fingerprint.
InsecureSkipVerify: true,
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.

2 participants