Files
stack/docs/scratchpads/1179-required-security-di.md
T
coder2 4c50a07ba2
ci/woodpecker/pr/ci Pipeline was successful
fix(#1179): require security authority wiring
2026-08-12 19:58:13 -05:00

3.5 KiB

#1179 — Required security DI wiring

Objective

Eliminate the shared fail-open defect class absence read as permission:

  • FL-01: missing CommandAuthorizationService must refuse Nest startup and must not permit command effects.
  • FL-11: missing SystemOverrideService must refuse Nest startup and must not omit stored instruction authority while allowing provider/session effects.

Tracking

  • Issue: #1179, child of #1156
  • Branch: fix/1179-required-security-di
  • Base: origin/next at 216cd72226cd9ee17eea461cfe7cd0e010a22f02

Plan

  1. RED: compile the real AppModule graph with each required provider independently removed, with a positive control for each intact binding.
  2. RED: directly exercise each malformed absence path and assert zero command/provider/session effects.
  3. Stop and report RED to the coordinator before production implementation.
  4. After authorization, make both constructor injections required, remove absence-as-permission branches, and update explicit legitimate optional test seams.
  5. Run focused Gateway tests, typecheck, lint, format, build, independent exact-head verification, and focused security review.

Immutable path fence

Production changes are confined to:

  • apps/gateway/src/commands/command-executor.service.ts
  • apps/gateway/src/agent/agent.service.ts

Tests and task evidence are confined to:

  • apps/gateway/src/__tests__/required-security-wiring.test.ts
  • existing direct-constructor specs that require explicit required arguments
  • docs/scratchpads/1179-required-security-di.md

No files in #1178, #1072, #1080, or #1054 lanes are in scope. docs/TASKS.md is orchestrator-owned and will not be modified.

Budget

No explicit token ceiling was provided. Working assumption: one narrow Gateway security packet; split and stop if either arm requires unrelated module rewiring.

Progress

  • Intake read from #1179 and parent #1156.
  • Base independently resolved from the issue's pre-native-stage ordering and repository origin/next ref; branch HEAD verified byte-for-byte against the remote ref.
  • Real consumers and direct constructors inventoried.

Tests

RED

  • required-security-wiring.test.ts: 4 failed, 2 passed before implementation.
  • Both real-graph negative controls showed module compilation accepted the missing target binding.
  • Direct FL-01 showed one unauthorized command effect; direct FL-11 showed one provider prompt and one session counter mutation.

GREEN

  • required-security-wiring.test.ts: 6/6 passed.
  • FL-01-only production revert: exactly the two FL-01 test cases failed; all four other cases, including FL-11, passed.
  • FL-11-only production revert: exactly the two FL-11 test cases failed; all four other cases, including FL-01, passed.
  • Full Gateway suite: 74 files passed, 7 skipped; 831 tests passed, 17 skipped.
  • Gateway typecheck: passed.
  • Gateway lint: passed.
  • Gateway build: passed.
  • Changed-file Prettier check: passed.

Review

  • Codex code review: APPROVE, 0 findings.
  • Codex focused security review: risk none, 0 findings.
  • Independent exact-head review remains assigned to Scrappy through the coordinator.

Risks / blockers

  • AgentModule / CommandsModule / ChatModule contain a production cycle; the module test therefore uses the real top-level AppModule and replaces only storage/network leaves, preserving the target service in each arm while isolating the separate required consumer that would otherwise mask that arm's defect.
  • No broad module rewrite was required.