Phase-10 live-IdP smoke (Keycloak 26.x via testcontainers-go) revealed
the IdP-bind alg-downgrade check was too strict for real-world IdPs.
6 of the integration tests in internal/auth/oidc/integration_keycloak*_test.go
were failing with:
oidc: IdP advertises weak signing algorithms (HS*/none);
refusing to use as defense against downgrade attacks: HS256
Keycloak 26.x (and several other real-world IdPs — Auth0 when HS-mode is
enabled, some Authentik configs) advertise EVERY alg they're capable of
in the discovery doc's id_token_signing_alg_values_supported field, even
when the realm only signs with RS256 in practice. Pre-fix the IdP-bind
check refused on ANY HS* or 'none' advertisement → no real Keycloak deploy
could ever bind a provider row, hence the integration-test failures.
The strict-deny check was defense-in-depth on top of the load-bearing
per-token alg-pin at sig-verify time (isDisallowedAlg, service.go L1177):
that check rejects every ID token whose JWS header carries an alg outside
DefaultAllowedAlgs, regardless of what the discovery doc advertises.
A forged HS256 token signed with the IdP's RS256 pubkey as HMAC secret
is rejected at sig-verify time → the actual algorithm-confusion attack
is closed by the per-token pin, NOT by the discovery-doc check.
Fix: relax the IdP-bind check to refuse only when the intersection of
advertised vs DefaultAllowedAlgs is EMPTY (the pathological all-weak-alg
IdP case). Keycloak (RS256 + HS256 advertised) now binds successfully;
an HS-only IdP still fails closed.
Changes:
- internal/auth/oidc/service.go: rewrite the alg-check loop at L1067 in
getOrLoad / RefreshKeys to compute the intersection set; refuse only
when no acceptable alg is advertised. ErrIdPDowngradeAdvertised
docstring updated to reflect new contract. DefaultAllowedAlgs
docstring + the package-level design-comment block at L40-72 updated
with v2.1.0-relaxed semantics callouts.
- internal/auth/oidc/test_discovery.go: TestDiscovery dry-run validator
rewritten to surface HS*/none alongside RS* as an informational note
('note: IdP advertises weak algorithms %v alongside acceptable ones')
rather than a hard-fail error. HS-only / none-only still hard-fails.
- internal/auth/oidc/service_test.go: TestService_IdPDowngradeDefense_*
tests updated. Renamed:
- RejectsHSAdvertised → RS256PlusHS256_BindsSuccessfully (positive)
- RejectsNoneAdvertised → RejectsHSOnlyAdvertised (intersection-empty)
- RefreshKeys_CatchesPostLoadDowngrade rotated to HS-only post-load
- internal/auth/oidc/coverage_fill_test.go: TestTestDiscovery_AlgDowngradeDetected
split into _HS256AlongsideRS256_BindsWithNote (positive, asserts note
but no hard-fail) + _HSOnly_StillTrips_HardFail (intersection-empty).
- docs/operator/auth-threat-model.md: OIDC token-validation alg-allow-list
section rewritten to call out the load-bearing-defense hierarchy
(per-token pin first, IdP-bind check defense-in-depth) and document
the v2.1.0 relaxation rationale.
- CHANGELOG.md: ### Security entry under Unreleased.
Verify: go test ./internal/auth/oidc/ -short PASS; gofmt clean; go vet
clean. The Keycloak integration tests should now pass when the operator
re-runs 'make keycloak-integration-test'.
46 KiB
Changelog
Unreleased
Security
- Alg-downgrade defense relaxed for Keycloak-shape IdPs (v2.1.0 pre-tag fix).
Pre-fix, the IdP-bind alg-downgrade check at
internal/auth/oidc/service.gorefused to load any OIDC provider whose discovery doc advertised HS256 / HS384 / HS512 /noneinid_token_signing_alg_values_supported— even if RS256 was ALSO advertised. This broke binding against Keycloak 26.x (and a handful of other real IdPs) which list every alg the codebase is capable of in their discovery doc, regardless of which one the realm actually signs with. The v2.1.0 Phase-10 live-IdP smoke surfaced the regression: 6 testcontainers-Keycloak integration tests failed withoidc: IdP advertises weak signing algorithms (HS*/none); refusing to use as defense against downgrade attacks: HS256. Fix: the check now refuses only when the intersection of advertised vsDefaultAllowedAlgsis EMPTY — an IdP advertising HS256 alongside RS256 binds successfully, but an IdP advertising HS-only / none-only still fails closed. The per-token alg pin at sig-verify time (isDisallowedAlg, service.go ~L1177) remains the load-bearing defense against the actual algorithm-confusion attack (forged HS256 token signed with the IdP's RS256 pubkey as HMAC secret) — go-oidc/v3's verifier rejects any token whosealgheader isn't in the configured allow-list, regardless of what the discovery doc claims. Updates:Service.getOrLoadalg-check loop rewritten to compute intersection;ErrIdPDowngradeAdvertiseddocstring reflects new semantics;TestDiscoverydry-run validator surfaces HS*/none alongside RS* as an informational note (not a hard fail);docs/operator/auth-threat-model.mdalg-allow-list section updated to call out the load-bearing-defense hierarchy. Tests:TestService_IdPDowngradeDefense_RS256PlusHS256_BindsSuccessfully(positive — Keycloak-shape) +TestService_IdPDowngradeDefense_RejectsHSOnlyAdvertised(negative — pathological intersection-empty case) +TestService_RefreshKeys_CatchesPostLoadDowngradeupdated to assert intersection-empty post-rotation;TestTestDiscovery_AlgDowngrade_HS256AlongsideRS256_BindsWithNoteTestTestDiscovery_AlgDowngrade_HSOnly_StillTrips_HardFailpin the dry-run validator's new behavior.
Tests
- Vitest coverage for the 2026-05-10/11 GUI batch (Audit 2026-05-11 Fix 12).
The original GUI-batch commit
661b6dbclaimednpx tsc --noEmit PASSbut shipped no Vitest cases for the new surfaces. The regression- prevention layer was missing — a future refactor ofKeysPage's assign modal could silently drop scope_type handling, the LOW-1 demo banner could be hidden by a stray predicate flip, the LOW-11 hide of the delete button on default roles could disappear and let operators click straight into a backend 409, and nothing would surface in CI. This closure adds 35 new test cases across five files:web/src/pages/auth/UsersPage.test.tsx(new, 8 cases pinning the active/deactivated/reactivate flow + provider filter + empty state + loading state),web/src/pages/auth/AuthSettingsPage.test.tsx(extended +4 cases pinning the MED-12 runtime-config panel — alphabetical sort,(empty)placeholder, 403 silent-hide),web/src/pages/auth/KeysPage.test.tsx(extended +8 cases pinning the HIGH-10 GUI half — scope_type=global/profile/issuer body shape, expires_at omission vs RFC3339 promotion, whitespace-only scope_id rejection, demo-anon row mutation-button hide),web/src/pages/auth/RoleDetailPage.test.tsx(new, 9 cases pinning the MED-8 scope picker + the LOW-11 default-role delete-button hide via theDEFAULT_ROLE_IDSset againstr-admin+r-auditor),web/src/components/AuthProvider.test.tsx(new, 5 cases pinning the LOW-1 demo-banner visibility predicate —authType==='none' && !loading— across happy/api-key/oidc/loading/rejected branches; the rejected-fetch path keeps the banner visible because the catch treats it as an old-server-fallback to demo-mode, and that behavior is pinned here so a future change surfaces in the diff). 40/40 test-file-scoped pass;tsc --noEmitclean.
Security
-
CSRF rotation on logout closes HIGH-2 fourth call site (Audit 2026-05-11 Fix 13). The HIGH-2 closure (
dev/auth-bundle-2) documented fourRotateCSRFTokenForActorcall sites: login completion (fresh by construction), Assign/RevokeRole on role-mutation (wired), Logout, and an explicit operator endpoint. The 2026-05-11 review verified only 3 of the 4 — Logout did NOT rotate the actor's sibling sessions post-revoke, leaving a window where a token captured pre-logout (browser DevTools, malicious extension, session-storage leak) could be replayed against the user's other-device/other-browser sessions until those sessions hit their own idle/absolute expiry.SessionMinterinterface extended withRotateCSRFTokenForActor;Logoutinvokes it afterRevoke(sess.ID)succeeds. Theauth.session_revokedaudit row gains acsrf_rotateddetail key carrying the rotated count so SOC / SIEM can correlate logout events with CSRF churn. The no-cookie + invalid-cookie 204 short-circuit paths skip rotation (no session row to rotate against). 3 regression tests ininternal/api/handler/auth_session_oidc_test.gopin the happy path + the two short-circuit branches. The explicit operator endpoint (4) remains intentionally unbuilt — the three automatic triggers (login + role-mutation + logout) cover the threat model; operators who want a nuclear option can use the existingRevokeAllForActorflow which forces re-login → fresh session → fresh CSRF. HIGH-2 fully closed across all four documented call sites. -
Demo-mode residual-grants detector + cleanup endpoint + CI guard (Audit 2026-05-11 A-8). HIGH-12 (closure
b81588e) added a fail-closed bind-address guard that refuses startup whenCERTCTL_AUTH_TYPE=nonebinds non-loopback withoutCERTCTL_DEMO_MODE_ACK=true. The Phase 2 leg of that spec — production-startup banner whenactor-demo-anonhas residual role grants inactor_rolesplus a CI guard banning new synthetic-admin code paths — was deferred. This closure lands all three deferred legs. (1)cmd/server/preflight_demo_residual.goruns after the DB is open + audit service is constructed, before the HTTPS listener starts; under any non-noneauth type it queriesactor_rolesforactor-demo-anonand emits a WARN log +auth.demo_residual_grants_detectedaudit row when the row is present. The migration 000029 baseline unconditionally seeds thear-demo-anon-adminrow at install time, so EVERY production deploy will see this WARN on first boot — the intended cutover workflow is documented atdocs/operator/security.md. (2)POST /api/v1/auth/demo-residual/cleanupis an admin-class (auth.role.assign) cleanup endpoint that removes everyactor-demo-anonrow fromactor_rolesand returns{"removed": <int64>}; idempotent (a second call returnsremoved:0), refuses 503 underAuth.Type=none(deleting the row would break the demo path), audit-logs every invocation. (3) New env varCERTCTL_DEMO_MODE_RESIDUAL_STRICT(defaultfalse) pivots the WARN to fail-closed startup refusal for operators who want a paranoid hostile-environment posture. (4) CI guardscripts/ci-guards/no-new-synthetic-admin.shpins the 17-entry allowlist of source files that may reference theactor-demo-anonliteral; new runtime code paths that resolve to the synthetic actor are rejected at PR time so the credibility gap stays closed. The closure was framed as "credibility gap, not exploitable vulnerability" — the residue requires a regression elsewhere in the middleware chain to be exploitable. After this fix, the canonical acquisition-readiness narrative ("RBAC primitive with no synthetic-admin fallback") is fully true. Operator runbook atdocs/operator/security.md#demo-to-production-cutover-audit-2026-05-11-a-8. -
OIDC provider "Test connection" panel (Audit 2026-05-11 Fix 09 — MED-5 GUI half). MED-5's backend dry-run endpoint (
POST /api/v1/auth/oidc/test, gatedauth.oidc.create) shipped ondev/auth-bundle-2but had no GUI caller — theauthOIDCTestProviderfunction inweb/src/api/client.tswas dead code. Operators had to complete the create form blind, save, then click "Refresh" to discover whether the issuer URL worked; failures left a broken provider row in the database that had to be deleted before retrying. New shared componentweb/src/pages/auth/OIDCTestConnectionPanel.tsxcalls the backend against the live form state and renders a four-row status panel inline: Discovery fetched, JWKS reachable, supported algs (warns when the IdP advertises none), and RFC 9207 iss-parameter advertisement (informational·glyph, not ✗, because the spec is SHOULD). Backend per-legerrors[]flow into an inline bullet list. The panel is mounted in the OIDCProvidersPage create modal AND the OIDCProviderDetailPage edit form — the edit-form half is load-bearing for verifying IdP rotations (Keycloak realm rename, Okta tenant move) without committing first. Run button is disabled until the issuer URL is non-empty (whitespace-trimmed); the component is read-only — safe to run repeatedly. 8 Vitest tests pin the glyph-vs-glyph contract (✓/✗/⚠/·), the button-disabled-without-issuer shape, and the test-id-suffix collision-prevention when the panel is mounted twice on the same page. -
OIDC JWKS health panel + Refresh-now button (Audit 2026-05-11 Fix 10 — MED-7 GUI half). MED-7's backend endpoint
GET /api/v1/auth/oidc/providers/{id}/jwks-status(commitd85114f) shipped the per-provider verifier counters ondev/auth-bundle-2but the GUI never called it. The audit doc had prematurely flipped the row to CLOSED;authOIDCJWKSStatusin the API client was dead code. Operators investigating "why is login failing for this IdP" couldn't seelast_refresh_at,rejected_jws_count, orlast_errorfrom the GUI — they had to drop to curl. New shared componentweb/src/pages/auth/OIDCJWKSStatusPanel.tsxqueries the endpoint via TanStack Query (30sstaleTime,retry: 0so a 403 hides the panel silently for callers withoutauth.oidc.list) and renders six dt/dd rows: Last refresh (with(never — cold cache)sentinel when the timestamp is empty), Refresh count, Rejected JWS count, Last error (red treatment when non-empty,(none)sentinel otherwise), RFC 9207 iss param ("supported by IdP" / "not advertised"), and Current KIDs ((not exposed — query jwks_uri directly)sentinel when the backend declines to expose the list). A "Refresh now" button invokes the existingPOST .../refresh(RefreshKeys path) and invalidates the panel's query so the freshly-updated counters render without a page reload. The button is hidden for callers withoutauth.oidc.editvia the panel's optionalcanRefreshprop. Mounted onOIDCProviderDetailPage.tsxbetween the read-only field display and the Actions section. 9 Vitest tests pin: loading state, happy-path-all-six-rows, 403-hides-panel, refresh-invalidates- query, refresh-failure-surfaces-inline-without-hiding-panel, never-refreshed-cold-cache-sentinel, current-kids-empty-not- exposed-sentinel, last-error-red-treatment, and canRefresh=false- hides-the-button. -
UsersPage sidebar nav entry (Audit 2026-05-11 Fix 11 — MED-11 discoverability). The MED-11 closure shipped
UsersPage.tsx+ wired the/auth/usersroute inweb/src/main.tsx, but the sidebar navigation never gained a corresponding entry. Operators reached the federated-user-admin surface (used during compliance audits — "show me last login for every IdP-federated user") only by knowing the URL. A page that exists but isn't navigable is a half-finished page. New Users entry under the Auth section inweb/src/components/Layout.tsxsits between Sessions and Roles (federated-identity grouping). Three Vitest tests inLayout.test.tsxpin the link's presence, the/auth/usersdestination, and the DOM ordering relative to Sessions so a future refactor that re-orders or removes the entry surfaces in the diff. -
Scope-aware actor-role revoke (Audit 2026-05-11 A-4). HIGH-10 made it possible to grant the same role to the same actor at multiple scopes (e.g.
r-operatoronprofile=p-acmeANDprofile=p-globex) via the unique constraint extension onactor_roles, butActorRoleRepository.Revokeignored(scope_type, scope_id)and unconditionally deleted every variant. Operators who wanted to drop one scoped grant had to nuke them all and re-grant the remainder — a race window where the actor's access was briefly different. TheDELETE /v1/auth/keys/{id}/roles/{role_id}endpoint now accepts optional?scope_type=/?scope_id=query params that narrow the revoke to a single variant; no-match returns 404. The legacy "revoke every variant" semantic is preserved when the query params are absent, so existing CLI / GUI buttons keep working unchanged. The audit row'sdetailspayload records which mode fired so SOC / SIEM can distinguish wide cleanups from targeted demotions. MCP toolcertctl_auth_revoke_role_from_keygains optionalscope_type+scope_idinput fields with matching semantics. Documented indocs/operator/rbac.mdunder "Revoke: legacy 'all variants' vs scope-selective."
Security (BREAKING — silent-elevation closure)
-
HIGH-10 actor-role scope is now enforced (Audit 2026-05-11 A-1). Pre-fix,
actor_roles.scope_type/scope_id(added in migration 000043 by the HIGH-10 closure) were persisted by Grant + accepted on the handler body + surfaced through the GUI/MCP — but the load-bearingEffectivePermissionsSQL never read them. A profile-scoped grant silently elevated to global at authorization time. Canonical CRIT-5 lying-field shape, replicated. The post-fix authorization narrows correctly: every existingactor_rolesrow withscope_type != 'global'now takes effect.Operator advisory: if you used the HIGH-10 scope-bound role-grant API between commit
551812band the v2.1.0 tag (the column was populated but ignored), the grants were silently global. After upgrading, auditSELECT actor_id, role_id, scope_type, scope_id FROM actor_roles WHERE scope_type != 'global'and confirm the narrowing reflects intent. If an actor was granted a scoped role but expected global behavior, re-grant withscope_type=global.
Security (BREAKING)
- Federated-user deactivation now actually blocks login (Audit 2026-05-11 A-2).
The MED-11 closure shipped
users.deactivated_at+DELETE /api/v1/auth/users/{id}- cascade-session-revoke, but the column was a "lying field" three legs over: the
postgres user repository never SELECTed it (so
User.DeactivatedAtalways read nil), theUpdateSQL never wrote it (so the handler's mutation was a no-op), and the OIDCupsertUserpath never checked it (so the next login under the same(provider, subject)tuple re-minted a session and re-elevated the user). The cascade-revoke remained correct for the current cookie only. Operator advisory: if you deactivated a federated user between the MED-11 closure (Bundle 2 mergedea5053) and the v2.1.0 release tag, verify the user cannot OIDC-log-in after upgrading — the column took no effect at login time before this fix. If needed, re-run the deactivation against the upgraded server. Closure:userColumns+scanUsernow readdeactivated_atviasql.NullTime;Create+Updatewrite it explicitly;upsertUserreturns the newErrUserDeactivatedsentinel before mutating fields (preserveslast_login_atforensics on rejected logins);classifyOIDCFailuresurfaces the rejection as audit categoryuser_deactivated. Self-deactivate guard onDELETE /api/v1/auth/users/{id}returns HTTP 409 + audit rowauth.user_deactivate_self_rejected(prevents an admin from one-way-door locking themselves out via the standard handler — break-glass remains the recovery path). New inverse endpointPOST /api/v1/auth/users/{id}/reactivate(gatedauth.user.deactivate— reactivation is the inverse op, not a separate privilege) clearsdeactivated_at; emits audit rowauth.user_reactivated. Sessions revoked at deactivation stay revoked across reactivation — the user must complete a fresh OIDC login. GUI:UsersPage.tsxnow renders a Reactivate button on deactivated rows. CWE-862 (missing authorization at the user-state boundary). SOC 2 CC6.3 + ISO 27001 A.9.2.6 compliance-table-flipping fix.
- cascade-session-revoke, but the column was a "lying field" three legs over: the
postgres user repository never SELECTed it (so
__Host-cookie prefix on all three auth cookies (Audit 2026-05-10 MED-14). The session cookie, CSRF cookie, and OIDC pre-login cookie are renamed fromcertctl_session/certctl_csrf/certctl_oidc_pendingto__Host-certctl_session/__Host-certctl_csrf/__Host-certctl_oidc_pendingto gain browser-enforced subdomain-takeover protection (a__Host-*cookie can only be set withPath=/+Secure+ noDomainattribute, and the browser rejects subdomain attempts to overwrite it). Active sessions invalidate on the rolling deploy that lands this change — operators must re-authenticate once after upgrading. The GUI's CSRF cookie reader was updated in lockstep. Seedocs/migration/oidc-enable.mdfor operator-facing detail.
Security
-
OIDC
allowed_email_domainsnow editable in the GUI (Audit 2026-05-11 A-3). The backend gate that rejects logins whose email domain is outside the configured allowlist landed in v2.1.0 (CRIT-5 closure, 2026-05-10), but the GUI never exposed the field — GUI-driven operators had to use the API directly to configure tenant isolation against multi-tenant IdPs (Auth0, Azure AD common endpoint, Google Workspace). The OIDCProvidersPage create modal and OIDCProviderDetailPage detail view now render a chip-style multi-input with client-side validation that mirrors the backend rules (no@, no whitespace, no wildcards, lowercase-only FQDNs). The read-only view renders an explicit "any (no gate configured)" sentinel when the list is empty so operators can tell "not configured" apart from "field is invisible." A "Clear all" button on the edit form is gated by a confirm dialog that warns about removing the tenant gate. Operator advisory: if you provisioned OIDC providers via the GUI between v2.1.0 and this fix, verifyallowed_email_domainsmatches your tenant policy — the field was configurable only via API / MCP / direct SQL during that window. Per-IdP runbooks for multi-tenant IdPs indocs/operator/oidc-runbooks/already documented the field; the GUI now matches. -
Approval payload preview (Audit 2026-05-11 A-5). The MED-10 closure claim ("PARTIAL: raw JSON preview; diff library deferred") was inaccurate —
ApprovalsPage.tsxrendered no payload at all, so approvers were clicking Approve / Reject without seeing the change they were authorizing. That defeats the entire four-eyes primitive: an approver who can't see what they're approving is rubber-stamping. Each row now carries a Preview toggle that expands an inline panel dispatching by kind:profile_editshows a field-level before/after diff (changed-only rows, red/green cells,(unset)sentinel for added/removed fields);cert_issuanceshows a definition list of CN / SANs / profile / key algo / must-staple / validity (catches the wildcard-against-corp-internal-profile attack at review time); unknown kinds render a generic JSON preview for forward-compat with future approval kinds. The base64-encoded JSON payload is decoded via the newdecodePayloadhelper; malformed inputs render an explicit decode-error fallback — silent failure on the payload preview is what produced this bug in the first place. -
Strict pre-login UA/IP binding (Audit 2026-05-11 A-6). The MED-16 closure left a request-side empty-header bypass: when the pre-login row carried a User-Agent or client-IP binding but the
/auth/oidc/callbackrequest omitted the corresponding value, the binding check was silently skipped.curldoesn't send User-Agent by default; many programmatic clients omit it. An attacker who acquired a pre-login cookie could replay it without the bound header and bypass the RFC 9700 §4.7.1 defense. The check is now strict-when-stored — an empty request-side value with a non-empty stored binding rejects with HTTP 400 and the new audit failure categoriesprelogin_ua_missing/prelogin_ip_missing(distinct from the existing*_mismatchcategories so SIEM rules can alert specifically on bypass attempts). Operator advisory: environments where the User-Agent is stripped in transit (some debug proxies, a handful of CDN configurations) must setCERTCTL_OIDC_PRELOGIN_REQUIRE_UA=falseto keep logins working; symmetricCERTCTL_OIDC_PRELOGIN_REQUIRE_IP=falseexists for the IP-side. The legacy-row compat window — pre-migration rows with no stored binding — still passes through unchecked, but that window is bounded by the 10-minute pre-login TTL. -
OIDC provider Advanced fields are now editable in the GUI (Audit 2026-05-11 A-7). The MED-4 row had been DEFERRED to v3 with the rationale "backend already accepts these fields." The verifier hit the GUI and found that the read-only display claimed the values were editable, but the edit form had no inputs — the save handler passed
provider.scopes/provider.groups_claim_path/provider.groups_claim_format/provider.iat_window_seconds/provider.jwks_cache_ttl_secondsunchanged from the loaded object. Operators who wanted to bump the IAT window or change the groups-claim path had to drop to curl / MCP and trust the GUI's display matched what they'd set elsewhere. Lying UX. The OIDCProviderDetailPage edit form now has a collapsible Advanced section with five inputs (scopes as a space-separated text field; groups-claim path; groups-claim format select with the backend'sstring-array/json-pathenum; IAT window number input bounded 1–600; JWKS cache TTL number input with floor 60). Client-side validation mirrors the backendValidaterules so common operator mistakes (IAT > 600, JWKS TTL < 60, empty scopes, empty groups-claim-path) reject inline instead of round-tripping a 400. The read-only<dl>also gained the previously-invisiblejwks_cache_ttl_secondsrow. -
Pre-login cookie Path widened from
/auth/oidc/to/(Audit MED-14 follow-on). Required to satisfy the__Host-prefix'sPath=/rule. The cookie lifetime is unchanged (10 minutes) and only the callback handler consumes it; the wider path scope is harmless. -
RFC 9207
issURL parameter check on OIDC callback (Audit 2026-05-10 MED-17). When the matched IdP's discovery doc advertisesauthorization_response_iss_parameter_supported: true, certctl now requires theissquery parameter on/auth/oidc/callbackand enforces a constant-time compare against the configured provider'sIssuerURL. Mismatch rejects with HTTP 400; the audit row'sfailure_categorydistinguishesiss_param_missing/iss_param_mismatch(RFC 9207 leg) from the existingid_token_iss_mismatch(in-token iss claim leg). Closes the mix-up-attack defense for modern Keycloak, Authentik, and public-trust CAs that ship RFC-9207 discovery. Providers that don't advertise support (the majority today) keep pre-fix behavior — back-compat is preserved. -
Auth GUI batch (Audit 2026-05-10 MED-4/7/8/10/11/12 + LOW-1/11/12 + HIGH-10 GUI). New backend endpoints land alongside their GUI consumers:
GET /api/v1/auth/users+DELETE /api/v1/auth/users/{id}(auth.user.read / auth.user.deactivate; migration 000045 addsusers.deactivated_atplus the two new permissions);GET /api/v1/auth/runtime-config(auth.role.assign) returning a sanitized flat-map of deployed CERTCTL_* values (no secrets leaked — only set/unset booleans and counts);GET /api/v1/auth/oidc/providers/{id}/jwks-status(auth.oidc.list) returning the per-provider verifier counters (refresh count, last refresh / error timestamps, rejected JWS count, RFC 9207 iss-param flag). NewUsersPagelists federated identities + soft-deactivates.AuthSettingsPagegains the runtime-config panel.KeysPage's assign-role modal now collectsscope_type/scope_id/expires_at.RoleDetailPage's add-permission form gains the same scope picker, and the Delete button is hidden on the 7 default system roles (server already rejected, this is pure UX).AuthProviderrenders a sticky red demo-mode banner whenauth_type=none.actor-demo-anonrows onKeysPagealready had buttons disabled. -
11 new MCP tools (Audit 2026-05-10 MED-13). Approval workflow (
certctl_approval_list/_get/_approve/_reject), break-glass credential admin (certctl_breakglass_list/_set_password/_unlock/_remove), bootstrap status + consume (certctl_bootstrap_status/_consume), and audit category filter (certctl_audit_list_with_category). All route through the existing HTTP client so server-side permission gates fire unchanged.certctl_bootstrap_consume's tool description carries an explicit "NEVER WIRE THIS TO AUTONOMOUS OPERATION" warning — a leaked bootstrap token mints a fresh admin API key bypassing every other access-control gate, so the tool is for one-shot manual operator invocation only. -
JWKS auto-refresh on cache-miss (Audit 2026-05-10 MED-6). When the IdP rotates its signing key between pre-login + callback, the cached JWKS no longer contains the kid referenced by the inbound ID token's JWS header. Pre-fix, the verify failed with a generic error and the operator had to manually call
POST /api/v1/auth/oidc/providers/{id}/refresh. The service now detects the kid-not-in-cache shape (isKidMismatchError) and runs a one-shotRefreshKeys(evict cache → re-fetch discovery + JWKS → re-run alg-downgrade defense) before retrying the verify exactly once. Bounded recovery: a second failure surfaces asErrJWKSUnreachableper the original branches; no retry loop. A separate matcher (isKidMismatchError) is intentionally narrow so generic signature failures don't trigger refresh. -
OIDC provider test endpoint (Audit 2026-05-10 MED-5). New
POST /api/v1/auth/oidc/testdry-runs an OIDC provider configuration without persisting: fetches the discovery doc, runs the alg-downgrade defense, detects RFC 9207 iss-parameter advertisement, and confirms JWKS reachability. ReturnsTestDiscoveryResult{discovery_succeeded, jwks_reachable, supported_alg_values, iss_param_supported, errors[]}so the GUI (forthcoming) can render per-check status rows. Per-leg failures ride in the response body'serrorsarray; only a malformed request body trips 400. Gate:auth.oidc.create. Audit rowauth.oidc_provider_testedcarries the success/failure summary. -
Pre-login UA / source-IP binding on OIDC callback (Audit 2026-05-10 MED-16). RFC 9700 §4.7.1 defense against stolen-pre-login-cookie replay by a different browser / source. Migration
000044_prelogin_uaipaddsclient_ip+user_agenttooidc_pre_login_sessions; values captured at/auth/oidc/loginare constant-time compared at/auth/oidc/callback. Mismatches return HTTP 400 with auditfailure_category=prelogin_ua_mismatchorprelogin_ip_mismatch. Two operator escape hatches:CERTCTL_OIDC_PRELOGIN_REQUIRE_UAandCERTCTL_OIDC_PRELOGIN_REQUIRE_IP(both defaulttrue) — operators on enterprise proxies that rewrite UA, or dual-stack v4/v6 environments where source IP routinely flips, can disable the affected leg. The binding column is persisted even when enforcement is off, so retroactive forensics remain possible. Empty values on either side pass through (rolling-deploy + headless-proxy compat).
v2.1.0 - Auth Bundles 1 + 2: RBAC primitive + OIDC SSO + sessions ⚠️
SECURITY: AUDIT YOUR API KEYS.
Bundle 1 ships role-based authorization. Every existing API key configured via
CERTCTL_API_KEYS_NAMED(or the legacyCERTCTL_AUTH_SECRET) is mapped to the r-admin role on the first upgrade boot so existing automation keeps working unchanged. Most keys do NOT need full admin power; downgrade them before tagging the next release.Recommended post-upgrade flow:
# 1. List every key with its current role: certctl-cli auth keys list # 2. Walk an interactive prompt that downgrades each key: certctl-cli auth keys scope-down # 3. Or get a heuristic suggestion based on 30 days of audit history: certctl-cli auth keys scope-down --suggest certctl-cli auth keys scope-down --suggest --apply # applies the suggestion # 4. Or drive scope-down from a JSON config (Helm post-upgrade hook): certctl-cli auth keys scope-down --non-interactive ./scope-down.jsonThe synthetic
actor-demo-anonactor (used whenCERTCTL_AUTH_TYPE=noneis configured) is system-managed and excluded from the prompt loop.
What else changed in v2.1.0:
-
Audit 2026-05-10 CRIT-1 closure — wire-layer RBAC enforcement. The Bundle 1 + Bundle 2 audit surfaced that the permission catalogue was enforced on ~24 admin-only routes only; the bulk of state-changing routes (
POST /api/v1/certificates,PUT /api/v1/profiles/{id},DELETE /api/v1/issuers/{id},POST /api/v1/agents/{id}/csr, evenPOST /api/v1/auth/roles+POST /api/v1/auth/keys/{id}/roles) had norbacGatewrap. Ar-viewerBearer was essentiallyr-adminminus five fine-grained verbs at the wire layer (CWE-862). This release wraps every state-changing + read endpoint withrbacGate(global scope) orrbacGateScoped(per-profile / per- issuer scope-bound grants), and adds an AST-level CI guard (TestRouterRBACGateCoverage) that fails when a new route is registered without enforcement. Catalogue extended via migration 000039 with 30 permissions coveringcert.edit,job.*,approval.*,policy.*,team.*,owner.*,notification.*,discovery.*,network_scan.*,healthcheck.*,digest.*,verification.*,stats.read,metrics.read. AUDIT YOUR KEYS (the scope-down call-out above) now translates to real reduction in blast radius. Auditor pin preserved at exactly{audit.read, audit.export}. -
RBAC primitive shipped.
tenants,roles,permissions,role_permissions,actor_rolestables (migration 000029); 33-permission canonical catalogue; 7 default roles (admin,operator,viewer,agent,mcp,cli,auditor); per-handler permission gates viaauth.RequirePermissionmiddleware (replaces the legacyIsAdminboolean check on the 5 admin-only handlers). -
Day-0 admin bootstrap. Set
CERTCTL_BOOTSTRAP_TOKENon a fresh deploy and POST a single curl call against/api/v1/auth/bootstrapto mint the first admin API key; one-shot, never logged, and locks closed once any admin actor exists. Migration 000031 ships theapi_keystable that stores the SHA-256 hash; the plaintext is shown in the response body once and never persisted. -
Auditor role split. New
auditorrole holds onlyaudit.readaudit.export. Compliance reviewers can read the audit trail without holding mutation power. Migration 000032 addsaudit_events.event_categoryso auditors can filter to authentication-related events specifically.
-
/v1/auth/checkenrichment. Response now includes the actor's standing roles and effective permissions, so the GUI gates affordances from a single fetch on app boot. -
Approval-bypass closure. Edits to a profile that has (or would have)
RequiresApproval=truenow route through theApprovalServicetwo-person integrity gate (Phase 9). Migration 000033 addsapproval_kind+payloadtoissuance_approval_requestsso cert-issuance and profile-edit approvals share the same workflow. Same-actor self-approve is rejected withErrApproveBySameActorfor both kinds. Closes the flip-flop loophole where an admin could disable approval, mutate, re-enable. Documented atdocs/reference/profiles.md. -
GUI: Roles / API Keys / Auth Settings / Approvals queue. Four new pages under
/auth/*consume/v1/auth/mefor permission-aware rendering. The Approvals queue blocks self-approve at the client layer (Approve/Reject buttons hidden when requested_by == current actor_id) on top of the server-side enforcement. AuditPage gains a category filter (cert_lifecycle / auth / config) for the auditor view. -
MCP server gains 12 RBAC tools. Operators driving certctl from Claude / VS Code / any MCP client get parity with the GUI
- CLI. Each tool routes through the same HTTP handler; permission gates fire server-side.
-
OpenAPI catalogues every new route. Every Bundle 1 endpoint ships with an
operationId; the parity test guards against drift. -
Coverage gates.
internal/auth/andinternal/service/auth/now have ≥85% coverage floors in.github/coverage-thresholds.yml. The 12-path negative-test list from the Bundle 1 prompt is fully covered (path #12 deferred with in-tree TODO). -
Protocol-endpoint allowlist pinned at three layers. The middleware bypass (
auth.IsProtocolEndpoint), the router-levelAuthExemptRouterRoutesconstant, and a newphase12_protocol_allowlist_test.goAST scan all guard against accidentally wrapping ACME / SCEP / EST / OCSP / CRL routes inrbacGate. -
Bundle 2: OIDC + sessions + back-channel logout + break-glass. Auth Bundle 2 ships in the same v2.1.0 release. Operators get OIDC SSO support for Keycloak / Authentik / Okta / Auth0 / Microsoft Entra ID / Google Workspace (via Keycloak broker), HMAC-signed session cookies with idle/absolute timeouts + CSRF defense, back-channel logout per OpenID Connect Back-Channel Logout 1.0, and a default-OFF break-glass admin path with Argon2id passwords for SSO-broken incidents. API-key auth keeps working unchanged alongside; existing automation needs no changes. Migration walkthrough at
docs/migration/oidc-enable.md; per-IdP setup guides atdocs/operator/oidc-runbooks/index.md. -
OIDC token validation pinned at three layers. Algorithm allow-list (RS256/RS512/ES256/ES384/EdDSA only) with HS-family +
nonerejected at the service-layer sentinel; IdP-downgrade-attack defense at provider creation AND every JWKS RefreshKeys (intersects the IdP's advertisedid_token_signing_alg_values_supportedagainst the allow- list, rejects providers that advertise weak algs even before any token is signed); OIDC Core §3.1.3.7 re-verification ofiss/aud/azp/at_hash(REQUIRED-when-access_token-present per Phase 3 tightening of the spec MAY → MUST) /exp/iatwindow /nonceconstant-time-compare. PKCE-S256 mandatory;plainrejected. Single-use state + nonce via atomicDELETE...RETURNINGon consume. -
Session cookies use length-prefixed HMAC. The cookie wire format is
v1.<session_id>.<signing_key_id>.<base64url-no-pad(HMAC-SHA256)>with HMAC inputlen:sid:len:kid(NOT bare-concat) to defeat concatenation collisions.HttpOnly+Secure+SameSite=Laxdefault;SameSite=Strictconfigurable viaCERTCTL_SESSION_SAMESITE. Idle timeout 1h / absolute 8h defaults; scheduler GC sweeps expired rows hourly. Signing keys rotate via the newRotateSigningKeyprimitive; the old key stays valid forCERTCTL_SESSION_SIGNING_KEY_RETENTION(default 24h) so existing cookies validate during rollover. -
CSRF defense via double-submit-cookie + hashed-token-on-row. Plaintext CSRF token in the JS-readable
certctl_csrfcookie (intentionallyHttpOnly=falsefor the GUI to echo into theX-CSRF-Tokenheader); SHA-256 hash on the session row;subtle.ConstantTimeComparein the newCSRFMiddleware. API-key actors are CSRF-exempt (no session row in context). -
OIDC
client_secretencrypted at rest. AES-256-GCM v3 blob format (magic 0x03 + salt(16) + nonce(12) + ciphertext+tag) using the existingCERTCTL_CONFIG_ENCRYPTION_KEY. Encryption invariant pinned by an integration test asserting ciphertext != plaintext + v3 blob shape + round-trip recovery + wrong-passphrase fails. -
OIDC first-admin bootstrap. New
CERTCTL_BOOTSTRAP_ADMIN_GROUPSCERTCTL_BOOTSTRAP_OIDC_PROVIDER_IDenv vars: the first OIDC-authenticated user with a matching group claim becomes admin per tenant. Coexists with the Bundle 1 env-var-token bootstrap; the admin-existence probe ensures only one wins. Audit row (bootstrap.oidc_first_admin) on every grant.
-
Break-glass admin (default-OFF). New
CERTCTL_BREAKGLASS_ENABLEDenv var (defaultfalse). When enabled, the local Argon2id-password admin path bypasses OIDC + group-claim layers — intended ONLY for SSO-broken incidents. Argon2id with OWASP 2024 params (m=64 MiB, t=3, p=4); lockout after 5 failures (configurable); constant-time across all failure paths viaverifyDummy; surface invisibility (HTTP 404 on every endpoint when disabled, NOT 403). WARN log at server boot when enabled. WebAuthn/FIDO2 second factor pairing on the v3 roadmap (Decision 12). -
GUI: OIDC Providers + Group → Role Mappings + Sessions + login buttons. Four new pages under
/auth/*consume the Bundle 2 API surface. Login page renders one "Sign in with X" button per configured OIDC provider (in addition to the API-key form, which remains as a fallback for Bearer-mode + break-glass paths). Sessions page exposes own-sessions + admin all-actors view. Every actionable element is permission-gated server-side viaauth.oidc.*andauth.session.*perms; client-side hide is UX layer. Logout button in the sidebar firesPOST /auth/logoutto clear the session server-side before redirecting to login. -
MCP server gains 11 OIDC + session tools.
certctl_auth_list_oidc_providers,_get_oidc_provider,_create_oidc_provider,_update_oidc_provider,_delete_oidc_provider,_refresh_oidc_provider,_list_group_mappings,_add_group_mapping,_remove_group_mapping,_list_sessions,_revoke_session. Operator-facing MCP tool count goes 12 (Bundle 1 RBAC) → 23 across the auth surface. Total MCP tool count:grep -cE 'mcp\.AddTool\(' internal/mcp/tools*.go≈ 150. -
Per-IdP runbooks: 6 production-tier setup guides at
docs/operator/oidc-runbooks/. Each runbook follows a consistent five-section layout (Prerequisites / IdP-side config / certctl-side config / Verification / Troubleshooting + Validation checklist with operator sign-off line). Keycloak is the canonical reference; Authentik / Okta / Auth0 / Entra ID / Google Workspace document the IdP-specific deltas (Auth0's namespaced custom claims; Entra ID's group OBJECT IDs; Google Workspace's missing-groups-claim limitation- the recommended Keycloak broker pattern).
-
Threat model extended.
docs/operator/auth-threat-model.mdships 5 new "Defenses Bundle 2 ships" subsections + 8 new threat- catalogue subsections (OIDC token forgery / session hijacking / IdP compromise / back-channel logout failure modes / group-claim manipulation / bootstrap risks / break-glass risks / token-leak hygiene). 6 new SQL-shaped operator-facing checks. New "Threats Bundle 2 does NOT close" section enumerating the 8 v3-backlog items (WebAuthn / JIT elevation / SAML / multi-tenant activation / HSM-FIPS / OIDC RP-initiated logout / Playwright / per-IdP external-tester sign-off). -
Performance baselines documented.
docs/operator/auth-benchmarks.mdships four benchmarks with measured baselines on a 4 vCPU / 8 GiB / Postgres 16 / Go 1.25 floor:BenchmarkSession_SteadyStatep99 5 µs (target < 1 ms; 200× under),BenchmarkSession_ColdProcessp99 7.1 ms (target < 10 ms),BenchmarkOIDC_SteadyStatep99 1.5 ms (target < 5 ms),BenchmarkOIDC_ColdCacheoperator-runs against live Keycloak viamake benchmark-auth-coldcache. -
Standards + RFC implementation table.
docs/reference/auth-standards-implemented.mdships 13 RFC / standard rows + 14 CWE rows with concrete file paths- negative-test anchors per row. NOT a compliance-mapping doc per the operator's 2026-05-05 retired-compliance-docs decision; the doc explicitly says "build the framework mapping yourself against the rows here using the framework-mapping methodology your audit firm prescribes; this project does not own that mapping."
-
Coverage gates held at floor 90 across all four Bundle 2 packages.
internal/auth/oidc/93.7%,internal/auth/session/94.9%,internal/auth/breakglass/91.5%,internal/auth/user/domain/96.4%. NO held-low-with-rationale entry — the Phase 13 prompt's anti-Bundle-1-mistake rule held. Bundle 1's existing 85% floors forinternal/auth/+internal/service/auth/stay 85 (already-shipped-and-accepted) per the prompt's explicit inheritance rule. -
Multi-tenant query CI guard. New
scripts/ci-guards/multi-tenant-query-coverage.sh(ratchet-style, baseline 32 at v2.1.0 close): greps every SELECT/UPDATE/DELETE ininternal/repository/postgres/against 10 tenant-aware tables, fails on regression OR improvement (forces the operator to lift / lower the baseline visibly). Forward-compat protection so a future Bundle 3 / managed-service multi-tenant activation can flip the switch without finding silent tenant-data-leak bugs in shipped queries. -
Phase 10 Keycloak testcontainers integration test. New build-tag- gated suite at
internal/auth/oidc/testfixtures/+integration_keycloak_test.godrives the full OIDC flow against a live Keycloak container booted by testcontainers-go. 5-test matrix: discovery + JWKS load, full PKCE auth-code happy path with HTTP form scraping, logout-revokes- session, JWKS rotation, unmapped-groups-fails-closed. Reuses one container across the matrix to amortize the 60-90s boot. Optional Okta smoke test (build-taggedintegration && okta_smoke) for live tenant validation. New Makefile targets:make keycloak-integration-testmake okta-smoke-test+make benchmark-auth-coldcache.
-
OpenAPI surface extended. New
cookieAuthsecurity scheme (apiKey/cookie/certctl_session) alongside the existingbearerAuth. 13 new Bundle 2 endpoints across the OIDC + session- group-mapping CRUD surface; 4 break-glass endpoints with
surface-invisibility framing. The N-bundle-2-security-empty-preserved
CI guard locks the
security: []opt-out count at ≥ 14 so existing public endpoints stay public.
- group-mapping CRUD surface; 4 break-glass endpoints with
surface-invisibility framing. The N-bundle-2-security-empty-preserved
CI guard locks the
-
Bundle-1-only compat regression CI guard. New
scripts/ci-guards/bundle-1-compat-regression.shasserts the load-bearing invariants that protect the Bundle-1-only-deploy case (session middleware defers-to-next, CSRF passthrough on missing session row, ChainAuthSessionThenBearer wired, public OIDC routes in AuthExempt allowlist, AuthInfo guards on OIDCProvidersResolver != nil). Siblingbundle-1-to-2-upgrade-regression.shasserts the upgrade-path invariants (migrations 000034..000038 are CREATE TABLE IF NOT EXISTS- BEGIN/COMMIT-wrapped + no DROP TABLE / ALTER...DROP COLUMN against 19 protected Bundle-1 tables + ON CONFLICT DO NOTHING on permission seed).
Migration ordering, idempotency, and downgrade are documented in
docs/migration/api-keys-to-rbac.md
(API-key → RBAC, Bundle 1) and docs/migration/oidc-enable.md
(API-key → OIDC, Bundle 2). The threat model lives at
docs/operator/auth-threat-model.md.
Day-2 RBAC operations live at docs/operator/rbac.md.
RFC + CWE evidence at docs/reference/auth-standards-implemented.md.
v2.0.68 - Image registry path changed ⚠️
Image registry path changed. Starting this release, container images publish to
ghcr.io/certctl-io/certctl-serverandghcr.io/certctl-io/certctl-agent. Existing pulls fromghcr.io/shankar0123/certctl-{server,agent}:<tag>continue to work for previously-published tags (the registry never deletes images), but the:latesttag at the old path stops moving forward at this release. Update yourdocker pullpaths,docker-compose.ymlimage:keys, or Helmimage.repositoryvalues to receive future updates. Oldgit clone/git push/ install-script / API URLs continue to redirect forever - only the container-registry path changed.
This is the only operator-action-required change in v2.0.68. Other changes in this release are cosmetic URL refreshes after the GitHub-org transfer from shankar0123/certctl to certctl-io/certctl (HTTP redirects mean no other operator action is required) plus an internal contextcheck lint fix in the agent. Full commit list is on the GitHub release page.
certctl no longer maintains a hand-edited per-version changelog. Per-release notes are auto-generated from commit messages between consecutive tags.
Where to find what changed in a given release:
- GitHub Releases - every tag has an auto-generated "What's Changed" section pulled from the commits between that tag and the previous one, plus per-release supply-chain verification instructions (Cosign / SLSA / SBOM).
git log <prev-tag>..<this-tag> --oneline- same content, locally.
Why no hand-edited CHANGELOG.md:
certctl is solo-developed and pushes directly to master. Maintaining a
hand-edited CHANGELOG meant the file drifted (entries piled into
[unreleased] and never got promoted to per-version sections when tags were
cut). A stale CHANGELOG is worse than no CHANGELOG - it signals abandoned
maintenance to security-conscious operators doing diligence.
The auto-generated release notes work here because commit messages follow a
descriptive convention: <area>: <summary> with a longer body for non-trivial
changes (see git log v2.0.50..HEAD for the established pattern). Anyone
reading the GitHub Releases page can see exactly what landed in each version
without depending on the author to manually update a separate file.
For the historical record: earlier versions (pre-v2.2.0 and the [2.2.0] tag itself) had a hand-edited CHANGELOG. That content is preserved in git history at the v2.2.0 tag.