diff --git a/.planning/phases/32.2-mcp-oauth-with-administrator-subjects/32.2-REVIEW-DISPOSITION.md b/.planning/phases/32.2-mcp-oauth-with-administrator-subjects/32.2-REVIEW-DISPOSITION.md index c08c005c..583f62f4 100644 --- a/.planning/phases/32.2-mcp-oauth-with-administrator-subjects/32.2-REVIEW-DISPOSITION.md +++ b/.planning/phases/32.2-mcp-oauth-with-administrator-subjects/32.2-REVIEW-DISPOSITION.md @@ -22,7 +22,7 @@ One row per finding, defaulting to `open`. Edit the disposition (fixed / accepte | FW-IN-03 | info | Item actions can answer 409, but the OpenAPI annotation does not document it | open | — | | FW-IN-04 | info | The new literal admin API routes shadow controller routes of a vendor named `mcp` or `account` | open | — | | FW-IN-05 | info | Dispatched calls of administrator OAuth grants carry no credential, so `interactiveOnly` cannot tell them from a cookie session | open | — | -| PA-CR-01 | critical | App master pins oauthserver v0.1.7, which ignores `mcp.subject`/`oidc.enabled`, and check-deploy cannot tell | deferred | detection in 2190109 (app); fix is the held release pointer bump, UAT item 4 | +| PA-CR-01 | critical | App master pins oauthserver v0.1.7, which ignores `mcp.subject`/`oidc.enabled`, and check-deploy cannot tell | fixed | detection 2190109 (app); pointer bump e60eb13 to v0.1.8 | | PA-WR-01 | warning | Administrator refresh asks the pool for a second connection while holding the rotation transaction | fixed | 32.2-REVIEW-FIX-plugin-app.md 1f872f6 | | PA-WR-02 | warning | A transient failure in the administrator lookup becomes a terminal `invalid_grant` or 401 | fixed | 32.2-REVIEW-FIX-plugin-app.md 7873a2a | | PA-WR-03 | warning | The consent decision and the code exchange never re-validate the administrator under the lock | fixed | 32.2-REVIEW-FIX-plugin-app.md c99e7e5 | diff --git a/.planning/phases/32.2-mcp-oauth-with-administrator-subjects/32.2-SECURITY.md b/.planning/phases/32.2-mcp-oauth-with-administrator-subjects/32.2-SECURITY.md new file mode 100644 index 00000000..7a94904b --- /dev/null +++ b/.planning/phases/32.2-mcp-oauth-with-administrator-subjects/32.2-SECURITY.md @@ -0,0 +1,109 @@ +--- +phase: "32.2" +slug: "mcp-oauth-with-administrator-subjects" +status: verified +# threats_open = count of OPEN threats at or above workflow.security_block_on severity (the blocking gate) +threats_open: 0 +asvs_level: 1 +created: "2026-11-21" +--- + +# Phase 32.2 — Security + +> Per-phase security contract: threat register, accepted risks, and audit trail. Evidence paths: F = `summercms.go` (v0.6.7), O = `sm-oauthserver-plugin` (v0.1.8), G = `sm-grzybyfunkcjonalne-app` (e60eb13), all under `../`. block_on: high. + +--- + +## Trust Boundaries + +| Boundary | Description | Data Crossing | +|----------|-------------|---------------| +| MCP client → wristband authorize | Untrusted scope, redirect and request values; the browser is handed off to the consent path | OAuth request parameters | +| Browser (admin SPA) → cabana consent API | Cookie-authenticated, same-origin; decides which scopes an agent gets | Admin session, consent decision | +| cabana consent endpoint → plugin provider | The administrator id comes from cabana's authenticated principal, never from the request body | Administrator identity | +| Server-issued redirect_uri → browser navigation | The SPA navigates cross-origin to a URI validated against the client's registered list | Authorization code | +| Server data → DOM | Client name, admin name/email, scope labels and item titles are untrusted text | Display strings | +| MCP token endpoint → store | Code and refresh lookups decide whose subject a token names | Codes, refresh tokens | +| MCP bearer → verifier / pier backend guard | A verified grant becomes a backend subject acting as an administrator | Access tokens | +| cabana admin saves → plugin listeners | In-transaction revocation event; a listener can veto the save | Access changes | +| Admin list and My account → revoke | Revoking another administrator's agent | Grant ids | +| Internet → nginx → Go | New public OAuth endpoints on the first consumer | OAuth traffic | +| Test output, smoke output and changelog notes | Tokens, codes, passwords and the journal token must not reach logs or the public post | Secrets | +| git push of release tags | What other repositories will require | Release refs | + +--- + +## Threat Register + +| Threat ID | Category | Component | Severity | Disposition | Mitigation | Status | +|-----------|----------|-----------|----------|-------------|------------|--------| +| T-32.2-01 | Elevation of privilege | pier resolveOAuth backend branch | high | mitigate | Subject switch, unknown subject refused (F `modules/pier/identity.go:218-229,262-264,278`); TestBackendOnlyGrant, TestBackendSubjectSmoke | closed | +| T-32.2-02 | Information disclosure | pier session binding | high | mitigate | Binding `oauth:backend::` (F `identity.go:269`); `backend_only_grant_test.go:104,126-130` | closed | +| T-32.2-03 | Elevation of privilege | pier linked user-mode grants | medium | mitigate | Only the backend branch sets ScopeLimited (F `identity.go:278`, `backend_guard.go:112`); filter.go untouched; TestLinkedGrantNoScopeLimit | closed | +| T-32.2-04 | Tampering (CSRF) | cabana POST /mcp/consent/{request} | high | mitigate | `interactiveOnly(requireAjax(...))` (F `modules/cabana/http.go:355`), 16 KiB cap, unknown fields refused (`mcp_consent.go:17,194-198`), SameSite=Strict (`auth.go:253`) | closed | +| T-32.2-05 | Elevation of privilege | consent scope selection | high | mitigate | submitted ∩ grantable(principal, requested) then validateTokenScopes (F `mcp_consent.go:219-240`) | closed | +| T-32.2-06 | Spoofing | wristband handoff | medium | mitigate | Exact redirect match and S256 PKCE before handoff; `CheckConsentPath` (F `modules/wristband/authorize.go:85,100-107,167,214-225`); boot check O `servers.go:269` | closed | +| T-32.2-07 | Elevation of privilege | account item action | high | mitigate | 404 for unknown action or unlisted item before Run, Run in a transaction (F `account_contributions.go:301-340`); TestAccountItemsSmoke | closed | +| T-32.2-08 | Repudiation / Elevation | D-13 revocation (framework) | high | mitigate | Nil tx refused, listener errors returned (F `admin_events.go:62-85`); fired at every site; TestBackendAccessRevokedSmoke, TestBackendAccessRevokedNeedsTransaction | closed | +| T-32.2-09 | Spoofing (open redirect) | ConnectView navigation | high | mitigate | Only a 2xx decision's URI via `safeDestination`, scheme deny-list and redirect-host check (F `admin/src/views/ConnectView.vue:192,200-236,267-274`); server backstop `mcpConsentSameRedirect` | closed | +| T-32.2-10 | Spoofing (phishing) | ConnectView fact box | medium | mitigate | Redirect host always shown, never truncated; logo same-origin or https (F `ConnectView.vue:65-77,469`) | closed | +| T-32.2-11 | Tampering (XSS) | ConnectView, AccountContributions | high | mitigate | No `v-html`; text interpolation only (F `AccountContributions.vue:166-170`, `ConfirmDialog.vue:88`) | closed | +| T-32.2-12 | Elevation of privilege (click-through) | ConnectView | medium | mitigate | `*` unticked unless sole scope, no autofocus or hotkeys, Allow only on submit (F `ConnectView.vue:118-124,310-334,429`) | closed | +| T-32.2-13 | Elevation of privilege | store MarkIssued/Mint/Create | critical | mitigate | Backend writes leave user_id NULL (O `classes/mcp_store.go:344-347,399-403,619-623`); CHECK constraints in migration 202611200001; TestBackendSubjectMigration | closed | +| T-32.2-14 | Elevation of privilege | user consent routes in backend mode | high | mitigate | `/oauth/mcp/requests/*` mounted only in user mode (O `routes.go:93-96`); smoke asserts 404 | closed | +| T-32.2-15 | Elevation of privilege | verifier backend branch | high | mitigate | BackendSubjects gate, BackendPrincipal and cutoff on every verification and refresh, re-check under lock (O `classes/mcp_verifier.go:127-131,177-186,232`, `mcp_store.go:478-492`) | closed | +| T-32.2-16 | Tampering (race) | consent allow vs revoke | medium | mitigate | Per-administrator advisory lock in its own namespace; issue only from pending (O `mcp_backend_subject.go:57,159`, `mcp_store.go:230,355-364,442`); TestMCPMarkIssuedOnlyOnce | closed | +| T-32.2-17 | Repudiation / Elevation | D-13 revocation (plugin) | high | mitigate | Revoke in `ev.Tx`, nil Tx refused, after-commit MCPSubjectChanged (O `classes/backend_cascade.go:40-53`); TestBackendRevocationSmoke, TestBackendCascadeRefusesNoTx | closed | +| T-32.2-18 | Elevation of privilege | My account revoke | medium | mitigate | Revocation scoped to `in.AdminID`, 404 when nothing revoked (O `account.go:123-128`); cross-admin 404 smoke | closed | +| T-32.2-19 | Elevation of privilege | admin-wide list and bulk revoke | medium | mitigate | `manage_mcp_connections` required, no default role; backend rows only (O `controllers/mcp_connections.go:55-56,76,95`) | closed | +| T-32.2-20 | Information disclosure | application logs | medium | mitigate | Log lines carry ids and errors only (O `mcp_verifier.go:194,221`; F `mcp_consent.go:128-263`) | closed | +| T-32.2-21 | Denial of service | migration on existing installs | low | accept | DROP NOT NULL, NOT VALID CHECKs, partial indexes | closed | +| T-32.2-22 | Elevation of privilege | OIDC provider surface | medium | mitigate | `oidc.enabled: false` (G config), OIDC routes only when enabled (O `routes.go:45`), no nginx location; live `/.well-known/openid-configuration` 404 | closed | +| T-32.2-23 | Denial of service | /oauth/mcp/register and /token | medium | mitigate | Plugin throttles and DCR cap; nginx `limit_except GET POST`, 64k body (G `production.conf:249-253`, `check-deploy.sh:364`) | closed | +| T-32.2-24 | Information disclosure | smoke-mcp-oauth.sh output | medium | mitigate | umask 077, labels and status codes only, secrets via env or files (G `scripts/smoke-mcp-oauth.sh:48,56-63,224,348-396`) | closed | +| T-32.2-25 | Tampering | security headers | low | mitigate | No `add_header` in new locations; enforced by `check-deploy.sh:318-330` | closed | +| T-32.2-26 | Information disclosure | tests, smoke output, changelog-post.py | medium | mitigate | Smoke and changelog script never print secrets. Gap: two failing-test messages in O `backend_mode_smoke_test.go:121,200` would print issued tokens (throwaway testcontainers DB only) | open — below high threshold (non-blocking) | +| T-32.2-27 | Tampering | release tags | medium | mitigate | v0.6.7 and v0.1.8 annotated, next patches, on master and origin, all earlier tags ancestors; fast-forward pushes, plugin before app bump | closed | +| T-32.2-28 | Spoofing | sm-bm-app regression scratch workspace | low | accept | Scratch go.work only; sm-bm-app tree unchanged | closed | +| T-32.2-SC | Tampering | go/npm installs (plans 01–05) | low | accept | No new third-party dependency; lockfiles unchanged v0.6.6→v0.6.7 | closed | + +*Status: open · closed · open — below high threshold (non-blocking)* +*Severity: critical > high > medium > low — only open threats at or above workflow.security_block_on count toward threats_open* +*Disposition: mitigate (implementation required) · accept (documented risk) · transfer (third-party)* + +--- + +## Accepted Risks Log + +| Risk ID | Threat Ref | Rationale | Accepted By | Date | +|---------|------------|-----------|-------------|------| +| AR-32.2-01 | T-32.2-21 | Migration avoids rewrites and scans; indexes empty on user-mode installs | plan 32.2-03 register | 2026-11-20 | +| AR-32.2-02 | T-32.2-28 | Regression workspace is a temp go.work; consumer files untouched | plan 32.2-05 register | 2026-11-20 | +| AR-32.2-03 | T-32.2-SC | No third-party dependency added by any plan | plans 32.2-01..05 registers | 2026-11-20 | + +--- + +## Notes + +- T-32.2-26 follow-up: make the two plugin `t.Fatalf` messages print the status and `access != ""` / `refresh != ""` instead of token values, in the next plugin patch. +- Review info items next to closed threats, none a bypass today: PA-IN-06 (CHECKs allow user_id 0, never written), FW-IN-02 (`backend:` client-id collision, ids are server-generated), FW-IN-05 (dispatched OAuth calls carry no credential), PA-IN-04 (32-bit lock keys), PA-IN-03 (narrow check-deploy OIDC regex). +- nginx access logs record the single-use pending request id in `/gfadmin/connect?request=`; deciding it needs a signed-in administrator plus X-Requested-With. + +--- + +## Security Audit Trail + +| Audit Date | Threats Total | Closed | Open | Run By | +|------------|---------------|--------|------|--------| +| 2026-11-21 | 33 | 32 | 1 (medium, non-blocking) | msd-security-auditor | + +--- + +## Sign-Off + +- [x] All threats have a disposition (mitigate / accept / transfer) +- [x] Accepted risks documented in Accepted Risks Log +- [x] `threats_open: 0` confirmed +- [x] `status: verified` set in frontmatter + +**Approval:** verified 2026-11-21