Repository navigation
fix(#80): authenticate GET /collab/stats with the service-secret guard - #45
Merged
Merged
Conversation
The collab stats route is registered only in the separate CollabAppModule process (collab-main.ts), which the main app's fail-closed PlatformAuthorizationGuard cannot reach — so it leaked aggregate connection/document counts to any caller when COLLAB_SHOW_STATS was enabled. Guard it with CollabServiceSecretGuard (parity with collab-disconnect): it requires the platform's x-authz-service-secret and fails CLOSED (503 when the secret is unconfigured, 401 on missing/invalid). The guard is dependency-free, so a class-level @UseGuards enforces in the collab process without a provider (Nest's scanner auto-registers it — verified against @nestjs/core 11.1.27). Drops the now-closed known-gap ledger entry (the route-inventory fitness test then requires it removed) and records the new upstream->authz seam in the import-boundary allowlist. Adds a security regression test that boots the controller through the real Nest HTTP layer (guard deliberately omitted from providers, mirroring production CollabAppModule wiring): 401 on no/wrong secret, 200 + counts on the correct secret, 503 when the secret is unset. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GET /collab/stats(the collab process's stats endpoint) had no authorization decision — no guard, no@Public. It leaks aggregate live connection/document counts to any caller whenCOLLAB_SHOW_STATSis enabled. It was tracked as a Layer Cknown-gapin the route-inventory ledger (cccvu/wiki-v2#80).The #13 global
PlatformAuthorizationGuardcan't reach it: the route is registered only inCollabAppModule, whichcollab-main.tsboots as a separate process with noAPP_GUARD.Change
Apply a class-level
@UseGuards(CollabServiceSecretGuard)toCollaborationController— the exact auth primitivecollab-disconnect/collab-flushalready use. It requires the platform'sx-authz-service-secret(constant-time compare) and fails closed:503when the secret is unconfigured,401on a missing/invalid secret.@UseGuardsenforces in the collab process without aCollabAppModuleprovider: Nest's scanner auto-registers a@UseGuards-referenced class as a module injectable (verified against@nestjs/core11.1.27, and proven by the boot test, which omits the provider). This keeps the change to a single upstream file (one seam), honoring "modify-minimally".CollaborationController.getStatsknown-gapentry fromintentional-unguarded.ledger.ts— the route-inventory fitness test enforces the biconditional (guarded ⇔ not ledgered).collaboration/server/collaboration.controller.tstoimport-boundary.spec.tsSEAM_ALLOWLIST(the new upstream→authz seam).Not
RemoteOnlyGuardas well: it needs the@GlobalAUTHZ_MODEtoken that isn't wired intoCollabAppModule, it isn't inAUTH_GUARD_NAMES, and stats isn't inherently remote-only.CollabServiceSecretGuardalone is the simplest robust decision.The paired super-repo PR bumps the submodule and documents this seam as
UPSTREAM_MODIFICATIONS.md #163.Tests
New
authz/collab/collab-stats-guard.spec.tsboots the controller through the real Nest HTTP layer (guard deliberately omitted fromproviders, mirroring productionCollabAppModulewiring):x-authz-service-secret→ 401@UseGuards(CollabServiceSecretGuard)Validation (from
apps/server):npx jest authz/collab/collab-stats-guard→ 6/6 passnpx jest authz/route-guard authz/collab/collab-disconnect→ 7 suites / 57 pass (route-inventory + import-boundary green)npx tsc --noEmit -p tsconfig.build.json→ clean;eslint --fix→ clean, no reformattingRelates to cccvu/wiki-v2#80.
🤖 Generated with Claude Code