Get started
Docs menu

Security

Security review: RFC 9700, requirement by requirement

On this page

Introduction

RFC 9700 (OAuth 2.0 Security Best Current Practice, BCP 240) is the current security standard for this stack as of August 2026. It is a BCP, not an informational note: its §2 carries MUST-level requirements on authorization servers. An "authorization server" is OAuth's word for the service that issues tokens, which here is Signari.

This page checks Signari against that standard, requirement by requirement. The standard's §2 covers redirects, the authorization code and Proof Key for Code Exchange (PKCE), token replay, and the limits on access tokens. Each table gives the requirement, its level (MUST, SHOULD and so on), and what Signari does.

It is for a security reviewer or an auditor. The sections follow the RFC's own numbering, then dated passes that checked the code again. A row in bold is a defect this review found, and the section after its table explains it.

§2.1 Protecting redirect-based flows

RequirementLevelSignari
Exact string matching of redirect URIsMUSTyes: HasRedirectURI, byte equality
Variable port numbers for loopback native applicationsMUSTwas missing, now implemented
No open redirectorsMUST NOTno forwarding of arbitrary query-supplied URIs
Avoid forwarding a person's credentials on redirect (§4.12)MUSTcredentials are never placed in a redirect

The defect: native applications could not use Signari at all

RFC 9700 §4.1.3 says this, immediately after it mandates exact matching:

The only exception is native apps using a localhost URI: In this case, the authorization server MUST allow variable port numbers as described in Section 7.3 of [RFC8252].

RFC 8252 §7.3 gives the reason:

The authorization server MUST allow any port to be specified at the time of the request for loopback IP redirect URIs, to accommodate clients that obtain an available ephemeral port from the operating system at the time of the request.

HasRedirectURI was pure string equality, with a test asserting that even https://app.example:443/cb must not match https://app.example/cb. That strictness is right for public hosts, and wrong for the one case both RFCs carve out.

A desktop application cannot know its port before it asks the operating system for one. It registers http://127.0.0.1:1234/cb, listens on 51004, and was refused.

loopbackPortMatch now allows the port, and only the port, to differ. Both sides must be http, and the host must be the same loopback host (127.0.0.1 and ::1 are different addresses). The path, query and fragment must match exactly.

§2.1.1 Authorization code grant

RequirementLevelSignari
Support PKCEMUSTyes
Enforce code_verifier when a challenge was sentMUSTyes
Mitigate PKCE downgrade: verifier accepted only if a challenge was presentMUSTyes, since 18 August 2026, when this review found it missing. A code_verifier sent for a code whose authorization request had no code_challenge is refused with invalid_request
Provide a way to detect PKCE supportMUSTcode_challenge_methods_supported in metadata
Prefer challenge methods that do not expose the verifierSHOULDS256 only; plain refused outright
Detect constant PKCE challenge / nonce valuesencouragedchallenges, yes; nonces, no (see below)

A client sending a code challenge it sent in the last day is recorded as oauth.pkce_challenge_reused. It is a signal and not a refusal. A person reloading a page can repeat one legitimately, and telling that from a hard-coded pair needs a human looking at how often it happens. A repeated nonce is not tracked.

§2.2 Token replay prevention

RequirementLevelSignari
Sender-constrain access tokens (mTLS or Demonstrating Proof of Possession (DPoP))SHOULDboth: RFC 8705 x5t#S256 and RFC 9449 jkt
Public-client refresh tokens sender-constrained or rotatedMUSTrotation with reuse detection (store/refresh.go)

§2.3 Access token privilege restriction

RequirementLevelSignari
Audience-restrict access tokensSHOULDyes: aud is the client, or the RFC 8707 resource values, each one a resource server the client's organisation registered (resource indicators); until October 2026 any http(s) URI was accepted
Resource server MUST refuse a token not meant for itMUSTwas missing, now enforced

The second defect: audience was not enforced at Signari's own resource

VerifyAccessTokenAny checked signature, typ, iss, sub, exp, iat and jti, and never looked at aud. Meanwhile the mint path sets the audience to the RFC 8707 resource values whenever a client sends them.

So a client could request a token for https://api.example, and receive one whose audience says exactly that. It could then spend it at Signari's own /userinfo, to read the subject's profile. §2.3 is explicit about whose job that is:

every resource server is obliged to verify, for every request, whether the access token sent with that request was meant to be used for that particular resource server. If it was not, the resource server MUST refuse to serve the respective request.

A "resource server" is an API that accepts access tokens, and Signari is one for its own endpoints. This is the "Compromised Resource Server" case of §4.9.2. Whoever holds a token meant for one API should not be able to use it at a different one. That includes the API itself, if it is compromised.

tokens.AudienceAccepted now gates /userinfo. It accepts the client the token was issued to, so ordinary OpenID Connect (OIDC) is unaffected. It also accepts this issuer, named explicitly as a resource.

A client wanting one token for both asks for both, which is what RFC 8707 §2's multiple resource parameters are for. It does not get the second without asking for it. An absent aud is refused rather than treated as a wildcard: RFC 9068 §4 requires the claim.

§2.4 – §2.6

RequirementLevelSignari
Resource owner password credentials grantMUST NOTrefused in ValidateGrantType
Enforce client authentication where feasibleSHOULDyes, and shared across every direct-request endpoint
Asymmetric client authentication availableRECOMMENDEDprivate_key_jwt and mutual Transport Layer Security (TLS)
Publish authorization server metadataRECOMMENDEDRFC 8414 discovery
Clients must not influence client_idSHOULD NOTdynamic registration assigns it; the request cannot choose it
Authorization responses never over unencrypted connectionsMUSTValidateRedirectURI refuses non-loopback http
Cross-Origin Resource Sharing (CORS) MUST NOT be supported at the authorization endpointMUST NOTsatisfied: CORS is served from an explicit allow-list in cors.go, and the authorization endpoint is not on it

§4 attack-specific countermeasures

AttackCountermeasureSignari
§4.1 Insufficient redirect URI validationexact matching + loopback exceptionyes
§4.2 Leakage via Refererno credentials in URLs beyond the response itselfyes
§4.3.1 Code in browser historycode is single-use and short-livedyes
§4.3.2 Token in browser historynever accepted from a query stringyes
§4.4 Mix-upRFC 9207 iss in the authorization responseyes, on by default
§4.5 Code injectionPKCE required by defaultyes
§4.6 Access token injectionno implicit grant; code flow onlyyes
§4.7 Cross-site request forgery (CSRF)double-submit __Host- cookie, constant-time compareyes
§4.8 PKCE downgradeverifier refused without a challengeyes, since 18 August 2026, when this review found it missing
§4.10.1 Stolen token misuseDPoP and mTLS sender-constrainingyes
§4.10.2 Audience restrictionenforced at our own resourcefixed above
§4.11.2 AS as open redirectorredirect targets are registered, never request-suppliedyes
§4.13 TLS-terminating proxiesURLs built from the configured issuer, never Hostyes
§4.14 Refresh token protectionrotation with reuse detection and family revocationyes
§4.16 Clickjackingframe-ancestors 'none' and X-Frame-Options: DENYyes
§4.17 In-browser communicationno postMessage response mode implementednot applicable

Verdict

Two MUST-level defects were found and fixed. One was the loopback port exception (§2.1 / §4.1.3), and the other was audience enforcement at Signari's own resource server (§2.3).

The existing tests missed both, because both were absences: one check that was too strict, and one that was not there at all.

When this was written, one MUST NOT was satisfied only because the corresponding feature was unbuilt: Cross-Origin Resource Sharing (CORS). CORS has since been built as an allow-list that leaves the authorization endpoint out, as the later pass records. One encouragement, constant-PKCE-value detection, was not implemented then. A repeated code challenge is now recorded, as the §2.1.1 table says, and a repeated nonce is not.

Every fix in this document is mutation-tested: the guard was removed or inverted, and the naming test observed to fail.

A step-up requirement nothing could satisfy (August 2026)

This was found by tracing the authorization journey end to end, not by any test failing.

A client sends acr_values=2. The subject has no second factor enrolled. The authorize endpoint finds the session insufficient, and renders the sign-in form. A correct password produces a password-only session, which correctly reports acr=1. The redirect lands back at authorize, which finds it insufficient and renders the form again.

Nothing errored. Every component was individually correct. acr is derived from amr rather than asserted, and the step-up check was right to refuse. A sign-in form is the reasonable response to "authentication is needed". The person saw two pages alternating indefinitely, with no explanation and no action available to them that would end it.

Fixed at the authorize endpoint. When the required context is StepUpNeedStronger and the subject has no second factor enrolled, the request is refused with unmet_authentication_requirements. That is the error OIDC defines for exactly this, and it is delivered to the client's redirect_uri, not to a form.

The fix is deliberately narrow. A max_age or prompt=login step-up is satisfiable by signing in again, so those still render the form. A failure to read the subject's factors fails open to the form, because a database error must not become a refusal.

Both directions are covered by tests (internal/httpapi/stepuploop_test.go). The fix was verified by removing it and watching the loop test fail.

This predates the flow engine. The hard-coded if enrolled it replaced behaved identically.

Mutating the JWT verifier (August 2026)

internal/tokens/verify.go is where attacks on a JSON Web Token (JWT) land: alg-confusion, jku and typ-confusion. It had thirteen tests, all passing. Every hardening property was deleted in turn, to see whether any test failed.

A real defect: id_token_hint accepted tokens that were not ID tokens

The hardening was implemented three times: in VerifyIDTokenAudience, VerifyTyped and verifiedPayload. A comment in the same file warned that this is the part people write twice and get right once. It also said "the shared part lives in verifiedPayload and both callers use it", which the code did not do.

The copies had drifted. VerifyIDTokenAudience checked the algorithm allow-list, the single signature, embedded key material and the kid/alg pinning, and not typ. Every other path checks it.

That function reads an id_token_hint at the end-session endpoint. Its answer decides which client's registered post_logout_redirect_uri values apply, and whether the sign-out confirmation prompt is skipped. RP-Initiated Logout accepts a verified hint in place of asking the person. So any token Signari signed whose claims unmarshal into IDTokenClaims was accepted as an ID token.

Access tokens were safe by accident: their aud is a JSON array and the struct wants a string, so they fail to unmarshal. Transaction tokens carry a string aud, and went straight through.

It was fixed by routing all three paths through verifiedPayload. There is one implementation now, so a mutation to it can fail a test.

A test that could not tell which defence had fired

TestAlgConfusionIsRejected forged tokens with the signature "AAAA", which is not a valid signature. Every one is refused, but by the last check rather than the one under test. Whichever header defence you delete, tok.Verify still fails. Deleting the algorithm allow-list broke nothing.

TestAlgConfusionWithARealSignatureIsRejected performs the attack. It makes a token signed HS256 using Signari's own published JSON Web Key Set (JWKS) entry as the HMAC secret. That is a valid signature for the algorithm claimed. The test asserts that the token is refused before any key is consulted.

What single-mutant survival means here

Four properties still survive deletion on their own: kid required, exactly one signature, the algorithm allow-list, and the kid/alg pinning. They are not four untested defects, because each is backed by another:

  • Drop the allow-list, and the kid/alg pinning refuses the HS256 token.
  • Drop the pinning, and the allow-list refuses it.
  • Drop both, and go-jose declines to verify an HMAC signature against an EC key (a third layer, in the library).
  • Drop the kid requirement, and ByKID("") fails anyway.

Removing any one leaves Signari safe, as defence in depth intends. The new test kills the case where both application layers go.

A correction to this review's own method

The first mutation run reported all six properties surviving, and that was wrong. Go caches test results, and the harness read a cached ok. Re-run with -count=1, the picture changed: two died immediately.

A mutation harness has to bypass the test cache. Otherwise it reports every mutant as surviving.

Re-verified by mutation, August 2026

The tables above record what the code does. This section records what happens when it stops doing it. Each MUST was disabled in turn, and the whole test suite was run, not only the owning package.

A guarantee enforced through a caller is killed by a test in another package. A package-local run reports that as a survivor.

RequirementLevelMutationKilled by
§2.1 no open redirectorsMUST NOTmake pre-verification errors redirect instead of rendering directly4 tests: TestErrorsBeforeRedirectVerificationAreDirect, TestRedirectURIMatchingIsExact, TestErrorRedirectRefusesDirectErrors, TestLookupErrorIsInvalidClient
§2.1 exact redirect matchingMUSTdrop the loopback confinementTestThePortExceptionAppliesOnlyToLoopback (written this pass; it had survived the whole suite)
§2.1.1 PKCE downgradeMUSTaccept a code_verifier for a code that carried no challengeTestAVerifierAgainstACodeWithNoChallengeIsRefused
§2.2 refresh rotation with reuse detectionMUST—verified under concurrency this pass: 8 simultaneous rotations yield exactly one winner, and a read-then-update rewrite yields 8
§2.3 resource server refuses a token not meant for itMUSTAudienceAccepted returns true unconditionallyTestATokenForAnotherResourceIsRefused and TestAudienceRestrictionIsEnforcedAgainstOurselves

Every mutant was killed.

What was not implemented: §2.1.1's encouragement to detect constant PKCE challenge or nonce values across requests. It is "encouraged" rather than a MUST. It needed cross-request state Signari did not keep then. A repeated code challenge has since been recorded as oauth.pkce_challenge_reused. A repeated nonce is still not tracked.


Three structural properties, re-confirmed on 24 August 2026

These three were derived again from the code rather than from a checklist. Each rules out a family of published attacks by construction, not by a check that could be forgotten.

  • No request object is fetched from a URL. request_uri_parameter_supported is false, because Signari fetches no remote request object, which would open it to server-side request forgery (SSRF). The only request_uri accepted is a Pushed Authorization Requests (PAR) handle, which is an opaque database reference and not a URL. RFC 9126 §5 confirms false is the correct advertisement for a PAR-supporting server; the metadata comment says so. Since November 2026 an inline request JWT is taken, signed by a key the client registered and never by a shared secret or none: see signed authorization requests.
  • Authorization compares relation tuples for exact identity (internal/authzen), never URI paths by prefix. There is no path to normalize, so trailing-slash and matrix-parameter normalisation bypasses have nothing to act on. Forward auth does no path-based authorization: it verifies a session-bound cookie and sets identity headers, and the protected application authorizes for itself.
  • Security Assertion Markup Language (SAML) source trust keys are explicit PEM configuration (internal/delegated, internal/saml/inbound.go), never lifted from imported metadata where a use attribute could disable verification. Unsolicited IdP-initiated responses are refused unless AllowUnsolicited is set for that provider.

RFC 9700 §2 re-verified against current code on 24 August 2026

This pass was run by reading the code as it is now, not by trusting the earlier table:

§2 requirementcodestatus
§2.1 code injection defence: PKCE S256authorize.go:203 requires code_challenge; :215 refuses any method but S256met
§2.1.1 PKCE downgradetoken.go:314 biconditional: code_verifier present iff code_challenge was; both halves are failures (:315 verifier-missing, :332 verifier-without-challenge)met, both halves
§2.2 exact redirect matching, no open redirectauthorize.go exact match; redirect_uri never pattern-matchedmet
§2.2.2 refresh rotation + reuse detectionrefresh.go rotates via consumed_at, revokes the family on reuse, and bounds the family with an absolute expiry ("a family without one would rotate forever")met
§2.3 no resource-owner password granttoken.go:427 refuses it explicitly and says it will not be supportedmet
§2.6 CORS MUST NOT be at the authorization endpointcors.go is an explicit allow-list: * only for discovery/JWKS, origin-echo for token/userinfo/revocation/introspection/PAR/device; the authorization endpoint is absent by construction, not by a prefix rule that could driftmet

Every §2 requirement checked is met, confirmed by reading the current code rather than the prior review. For CORS, an allow-list switch means a new endpoint gets no CORS unless someone adds it. The authorization endpoint can never be added to the * arm without someone writing the line.

Changed Signari v0.2