i2goSignals

goSignals

33. Expected verification material is discriminated by issuer-JWKS-URL presence

Date: 2026-08-19

Status

Accepted (GH #264) — recorded ahead of the fix, as a constraint on it.

Context

StreamService keeps receiverStreams, a per-process map from receive SID to the stream record, with the resolved *keyfunc.JWKS hung off it as ValidateJwks. GetIssuerJwksForReceiver treats entry presence as a cache hit and returns ValidateJwks verbatim — including when it is nil. Four call sites populate the map (the startup preload in LoadReceiverStreams, CreateStream, and both miss paths in GetIssuerJwksForReceiver — pair-by- inbound-SID and plain receiver); exactly one evicts from it (DeleteStream).

fetchReceiverJwks collapses three unrelated outcomes into that same nil:

On the first of those it logs "Temporary error loading JWKS, will retry", and the function’s own doc comment says transient errors are “left for retry”. There is nothing to retry from. The nil is cached under the SID and every later lookup is a hit, for the life of the process.

The two error classes are asymmetric in a way that hides the live one. A permanent error (isPermanentJwksError: 4xx other than 429, unusable URL, undecodable body) disables the record and persists Status + ErrorMsg, so an operator can see it. A transient error (connection refused, timeout, 5xx) — the class that is actually expected to recover — leaves the stream enabled with an empty reason while it verifies nothing. Nothing an operator can query distinguishes it from a healthy stream. Verification is fail-closed at every consumer (goSetSstp, goSetPush, goSetPoll), so inbound SETs are rejected rather than admitted unverified: this is an availability defect, not a verification bypass.

A second silent failure sits behind the same nil. keyService.GetPublicJWKS swallows every per-key error with continue and returns whatever accumulated, so a total failure yields {"keys":[]} — which keyfunc.NewJSON parses into a non-nil, zero-key JWKS with a nil error. A presence check on the pointer cannot tell “resolved” from “resolved to nothing”.

Fixing the caching therefore requires a distinction the codebase does not currently have: verification material is expected here and I do not have it versus nothing is expected here. Only the first may retry, and the predicate that separates them is the whole decision. Too permissive and every bearer-authenticated stream enters a permanent retry loop against an endpoint it was never given; too strict and the original bug reopens on the branch that was supposed to recover. The pull toward the permissive reading is strong, because from inside the verification path “no keys” reads as a fault — which is why the rule is recorded here rather than left implicit in the retry code.

Decision

Consequences

Positive

Negative