Skip to content

fix(authz): harden PLATFORM_AUTHZ_TIMEOUT_MS parse (empty/typo → deny-all self-DoS) - #4

Merged
PMQ9 merged 1 commit into
wiki-v2from
feat/issue-14-authz-timeout-hardening
Aug 31, 2026
Merged

PMQ9 merged 1 commit into
wiki-v2from
feat/issue-14-authz-timeout-hardening

Conversation

@PMQ9

@PMQ9 PMQ9 commented Aug 31, 2026

Copy link
Copy Markdown

What this does

Hardens the CCC authz client's per-request timeout parse in apps/server/src/authz/platform-authz.client.ts.

Number(process.env.PLATFORM_AUTHZ_TIMEOUT_MS ?? DEFAULT_TIMEOUT_MS) parsed an empty string to 0 and a
non-numeric string to NaN. Either makes the AbortController fire immediately, so every PEP→platform
authz call aborts → this fail-closed client returns null → denies all access. An empty value is easy to
produce from IaC templating an unset env var, so this was a latent self-inflicted deny-all outage.

Adds sanitizeAuthzTimeoutMs(raw, fallback) — falls back on any non-finite / <= 0 value and clamps to
[250, 60000] ms — mirroring the platform's own config.sanitizeTimeoutMs. Duplicated here because the fork
cannot import platform code across the submodule boundary. Includes a regression test in
platform-authz.client.spec.ts (runs in the docmost-authz CI job).

Why

Part of cccvu/wiki-v2 issue 14 (production configuration fail-fast). Surfaced by that issue's repo-wide
config-hazard audit as the one fork-side instance of the same "unsafe default parsing" pattern.

Testing

  • New sanitizeAuthzTimeoutMs unit cases: undefined/''/'abc'/'-10'/'0' → fallback (never 0/NaN);
    '1' → 250 (clamp floor); '600000' → 60000 (clamp cap); '2000' → passthrough.
  • Verified the same logic standalone in node; no behavior change on valid values (the default 1500 ms).

Risk & rollback

Low. Pure hardening of one field parse; no signature/behavior change on valid input. Revert the single commit
to roll back.

🤖 Generated with Claude Code

…nger deny-all

`Number(process.env.PLATFORM_AUTHZ_TIMEOUT_MS ?? default)` parsed `''` -> 0 and
`'abc'` -> NaN, either of which fires the AbortController immediately so every
PEP->platform authz call aborts and this fail-closed client denies ALL access
(a self-inflicted outage from an empty IaC-templated value). Add
`sanitizeAuthzTimeoutMs` (fallback on non-finite/<=0, clamp to [250, 60000] ms)
mirroring the platform's `config.sanitizeTimeoutMs`, with a regression test.

Part of cccvu/wiki-v2 issue 14 (production config fail-fast).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@PMQ9
PMQ9 merged commit a75c31b into wiki-v2 Aug 31, 2026
PMQ9 added a commit that referenced this pull request Sep 16, 2026
Takes docmost#319 (magic-link token in the URL fragment + ResponseHeadersModule) and docmost#320 (raw transport
evidence with audit events). The one conflict is app.module.ts seam #4, where both sides registered a
CCC module next to CollabDisconnectModule; both are kept (ConditionalPageModule adds a controller,
ResponseHeadersModule a global response hook, so order is immaterial). The import-boundary spec's
seam #4 comment now names ConditionalPageModule alongside the modules docmost#319 listed.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
PMQ9 added a commit that referenced this pull request Sep 19, 2026
…at the platform (docmost#310)

CI's fork boot smokes caught that the NODE_ENV-gated posture + boot validator
refused to boot legitimate http deployments: the documented standalone self-host
(native, NODE_ENV=production required for migrations/start:prod, APP_URL=http://
localhost:3000) and both fork CI smokes (the contract smoke boots a remote fork
over http and carries a plain cookie across its native->remote flip). Upstream
Docmost derives cookie Secure from isHttps() precisely so http self-hosting works.

- Posture now gated on isHttps() (restores upstream's `secure: isHttps()` and adds
  the __Host- prefix over https). Name + secure share the one isHttps() authority,
  so prefix<=>Secure still holds by construction. Over http -> plain authToken.
- Remove the fork boot validator (validate-cookie-posture.ts + session-cookie.module.ts
  + app.module seam #4 addition): a fork boot check cannot tell the CCC https
  deployment from a legitimate http self-host/CI config (all are NODE_ENV=production).
- Fail-closed protection for the CCC deployment moves to the PLATFORM (super repo):
  it authoritatively knows it is production and observes the fork's real Set-Cookie,
  so it rejects a non-__Host- fork session cookie in production posture.
- Reword seam comments + service-bridge OpenAPI ("in production" -> "over https").

Fork server jest (session-cookie/route-guard/ws/service-bridge, 33 suites) green;
tsc clean.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@PMQ9
PMQ9 deleted the feat/issue-14-authz-timeout-hardening branch November 4, 2026 19:20
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.

1 participant