Docs / SECURITY-DOCS-SWARM

Security-report reconciliation against main (SWARM H10)

Source: docs/SECURITY-DOCS-SWARM.md

Ownership: this file is the only file authored in this worktree. Read-only review: no source edits, no push, no merge, no deploy, no running containers, no HTTP requests or exploit attempts.

Reviewed ref: main = 536879a08b8150d77bed6e16ddfe53f9960bbc41 (origin/main, in sync). All file contents and line numbers below are from git show main:<path>. Reports were written against 321e188727d82dca419181c143d700a8f66febc3; the relevant source files are compared at that revision and at main.

Classification used here

  • Confirmed — the exact condition the report describes is present in the code on main and was verifiable by direct inspection. "Confirmed" means code state, not a live exploit: no dynamic test was run.
  • Advisory — a hardening recommendation, a trust-boundary/operational note, or a remediation that has already landed. These are not open defects in the reviewed code.

Reports reviewed and provenance

Report (on main) Added by Merge into integration Notes
docs/SECURITY-REVIEW.md 272387f378f0a0897de30e02c9e0f8e881918c7b (item 159 / H8) 04d1ca3e7a32b6b12dd72a8477d5ccd8e1a97da7 5 Medium, 6 Low, 2 Info; static + read-only Python YAML probes
docs/SECURITY-REVIEW-GC3.md 69e8f481c8d969a28fab93486edc4b3eb0ffbee7 04d1ca3e7a32b6b12dd72a8477d5ccd8e1a97da7 3 Medium, 8 Low, 1 Info; static, file:line findings
docs/SECURITY-INDEPENDENT-REVIEW.md ec721ed via integration merges 1 conditional Medium (redirect SSRF)
docs/OVERALL-REVIEW.md 4c9684f via integration merges E2E + security; adds deployment-context gates

All four report commits are ancestors of main. This document addresses the three requested themes only: serve.py Host header, checkpoint, and token redaction.


1. serve.py Host header

Confirmed

Report ID Severity Finding Evidence on main
SECURITY-REVIEW S3 Medium Origin validation derives the trusted origin from the request-supplied Host header; no fixed allowlist, no Sec-Fetch-Site check. examples/nes/image/serve.py:18-19: self.headers.get("Origin") != "http://" + self.headers.get("Host", ""). The file is byte-identical to the reviewed revision (git diff --quiet 321e188 main -- examples/nes/image/serve.py passes).
SECURITY-REVIEW-GC3 S1 Medium Same Host-header/DNS-rebinding weakness; additionally the sibling GET route has no origin check. POST gate as above; serve.py:13-14 registers /checkpoint in the public route table, and :36-50 (do_GET) applies no origin or Host check. :16 defines only do_POST/do_GET, so the CORS preflight barrier is incidental (OPTIONS → 501), not the stated defence.

The two independent reviews converge on the same code condition: a rebound page can present matching Host/Origin and the static X-Game-Composer: checkpoint header, passing the gate. Severity is unchanged from the reports (Medium in the intended loopback deployment).

Advisory

  • Both reports' fixes — fixed Origin allowlist (http://127.0.0.1:<port>, http://localhost:<port>), reject unexpected Host, require Sec-Fetch-Site: same-origin, explicitly reject OPTIONS — are recommendations, not applied changes. No authentication or origin-allowlist code exists on main.
  • Binding context: examples/nes/image/serve.py:52 and examples/snes/image/serve.py:36 bind 0.0.0.0:8080; the reference runtime publishes to host loopback (gamecomposer/runtime.py:392 on main; reports cited :311-312 at 321e188). The SNES server changed after review (added do_HEAD and X-Content-Type-Options: nosniff) but its bind address did not. "Bind 127.0.0.1 by default" is deployment guidance; it does not change the NES origin-check finding.
  • SECURITY-REVIEW-GC3 S12 (Info) — a player URL was taken from arbitrary Kiri output and passed to webbrowser.open. On main the CLI now filters it through _local_player_url() (gamecomposer/cli.py:6-23, scheme http, hostname 127.0.0.1, numeric port, no credentials), so that concern is largely addressed; gamecomposer/desktop.py still uses a looser if "http://127.0.0.1:" in line filter. This is adjacent hardening, not a Host-header defect.
  • OVERALL-REVIEW S2 (High) — bridge networking, default container privileges, and in-container 0.0.0.0 bind make this a local single-user boundary, not a hardened sandbox. Trust-boundary note; no code change on main.
  • No DNS-rebinding or cross-origin request was executed; the conclusion is static.

2. Checkpoint

Confirmed

Report ID Severity Finding Evidence on main
SECURITY-REVIEW S1 / SECURITY-REVIEW-GC3 S1 Medium Checkpoint POST has CSRF-style checks but no authentication; any non-browser client can satisfy all three. serve.py:17-21. X-Game-Composer is a static header; Origin equals http:// + attacker-supplied Host.
SECURITY-REVIEW S2 / SECURITY-REVIEW-GC3 S2 Medium Stored checkpoint bytes are neither validated at write nor at read; arbitrary bytes reach the emulator. serve.py:22-32 writes the body verbatim after a 1–4,000,000-byte Content-Length check; :13-14 serves the same file as application/json; examples/nes/image/player.html:20-22 passes await reply.json() straight into player.nes.fromJSON() with no shape check (only a try/catch around the call).
SECURITY-REVIEW-GC3 S8 / SECURITY-REVIEW S9 Low NES checkpoint/player responses lack nosniff and any CSP; checkpoint has no no-store header. NES serve.py:46-49 sets only Content-Type and Content-Length. The SNES server now emits nosniff, so the two servers are inconsistent. The player mitigates caching client-side with cache:'no-store' (player.html:20).
SECURITY-REVIEW-GC3 S9 / SECURITY-REVIEW S8 Low No socket timeouts or connection limits; 0.0.0.0 bind broadens exposure. serve.py:52 ThreadingHTTPServer(("0.0.0.0",8080), Player).serve_forever() with no timeout or thread cap.
SECURITY-REVIEW-GC3 S10 Low Temp file can be orphaned and is not fsynced before the atomic swap. serve.py:30-32: NamedTemporaryFile(..., delete=False), temp.write(data), replace(temp.name, save) — no try/finally, flush(), or os.fsync().
SECURITY-REVIEW S10 Low Excess POST body bytes remain unread. serve.py:26 reads exactly Content-Length. Not request smuggling today because protocol_version defaults to HTTP/1.0 and the connection closes.

Controls that the reports credit and that are still present on main (verified): exact-match route lookup (serve.py:37), fail-closed 403/413/400, a 1–4 MB per-request bound (:23), atomic os.replace with a temp file in the target directory (:30-32), and no URL-path traversal. These limit impact but do not address the authentication/validation gaps above.

Advisory

  • All checkpoint recommendations remain unimplemented: authenticate/authorize writes; per-session unguessable token or SameSite cookie; validate JSON and a bounded state schema before write and before fromJSON(); total size quota and rate limit; flush()/fsync() with try/finally cleanup; add nosniff, Cache-Control: no-store, CSP; bind to loopback; set socket timeouts and a connection cap. These are the reports' proposed fixes, not current defects beyond those listed as Confirmed.
  • docs/acceptance.md:33 states that an authenticated local host API with project authorization and origin checks is not implemented and must be verified when built; this is a gate, not a finding.
  • The checkpoint is only reachable inside the container on 0.0.0.0:8080, with host publication constrained to loopback by the reference manifest (gamecomposer/runtime.py:392 on main). Exposing the port with a broad publish raises several Low items to Medium/High — a deployment caveat repeated by all three reports.
  • No live save corruption, volume exhaustion, or rebinding exploit was reproduced.

3. Token redaction

Confirmed

  • Completed remediation (already on main): f98cded55177dda88f3aa5719493344c28e17ae2 ("Redact signed release-asset URL tokens from rom-identity.json") is an ancestor of main. In examples/nes/evidence-real/rom-identity.json on main, effectiveUrl is reduced to the bare https://release-assets.githubusercontent.com/github-production-release-asset/260893085/2ba75680-9692-11ea-8187-2f8050e8b030 (the time-limited SAS sig, jwt, skoid, sktid, skt/ske query values are gone), fetchCommand's absolute temp download path is replaced with <redacted temp download path>, and a redaction note records the change. pinnedUrl, httpStatus, sizes, SHA-256 digests, sha256Match, verification, and outcome are unchanged. No signed-URL token remains in that file.
  • Open, low severity: SECURITY-REVIEW S12 (Info) — declared environment.env values are echoed to stdout, logs, and the desktop UI. On main, gamecomposer/api.py:13 serialises the whole service (including env) in config output, gamecomposer/cli.py:40-41 prints the result, and gamecomposer/desktop.py:158,182 displays it. No redaction exists in the source path. The code condition is confirmed; the originating severity is Informational.
  • Residual path disclosure (not a token): rom-identity.json still contains an absolute workspace path in savedAs (/Users/mac/orca/workspaces/.../table_tennis_v1.0.nes) and makeRomPySha256-style provenance in the synthetic-evidence file. Worth noting for shared evidence, but no credential is exposed.

Advisory

  • Recommendation from SECURITY-REVIEW S12 to redact env values in config output or use secret references resolved only at runtime — not applied on main.
  • Recommendations in both NES reviews to add a per-session checkpoint token (or SameSite cookie) — not applied; see theme 2.
  • tests/e2e-strategy/STRATEGY.md:32 ("Redact secrets from shared logs while retaining local raw evidence securely") is process guidance for evidence handling, not a code defect.
  • A source scan across main for token|secret|redact|api_key found no secret-management code; the only match outside evidence is a note in tests/e2e-snes-real/fetch-assets.py:5 that no secrets or signed URLs are involved. There is no token-validation surface on main to audit beyond the static checkpoint header.

Summary

Theme Confirmed (present on main) Advisory / resolved
serve.py Host header Host-derived Origin gate (S3 / GC3 S1); GET /checkpoint unguarded Fixed allowlist, Sec-Fetch-Site, OPTIONS rejection, loopback bind, container hardening; CLI URL filter already tightened
Checkpoint No auth; arbitrary bytes written and replayed; missing response hardening, timeouts, fsync/cleanup; body remainder Token/CSRF, schema validation, quota/rate limit, header/cap changes are proposed fixes; loopback-publish caveat
Token redaction Signed-URL tokens already redacted in committed evidence (f98cded); env values still echoed via config output Env redaction/secret references, per-session token, evidence-handling guidance

Bottom line: the three reports are consistent with the code on main for the three requested themes. Two Medium code-level weaknesses remain confirmed and open (Host-derived origin check and unauthenticated/unvalidated checkpoint). The signed-URL token redaction is a completed, verifiable remediation; the only confirmed token-adjacent gap is Informational (manifest env echoed by config). Everything else in these themes is a recommendation or deployment caveat rather than a newly discovered defect.

Limits

Static read-only review at main 536879a; the reports targeted 321e188. examples/nes/image/serve.py is byte-identical between those revisions; examples/snes/image/serve.py changed (HEAD support and nosniff) but keeps the 0.0.0.0 bind. No dynamic testing, no containers, no network calls, no source edits, no push, and no merge were performed. This document does not assert playability or that Kiri enforces the declared isolation.

Back to all docs