SLICE-001 — Secure baseline: resolve-and-confine statement archive - #2
Merged
Conversation
Deliver the secure baseline (SLICE-001): a fully fictional, container-only multi-tenant statement archive that handles user-supplied filenames safely by resolving the candidate path and then confining it to its base directory. - Deterministic fixtures recreated on every start: per-tenant archives, an out-of-root integration key with a DEMO_SENTINEL, a branding config read at request time, and a planted symlink escaping the archive root. - Demo bearer auth mapping one token to one user/tenant; generic 401 otherwise. - Secure API: resolve-and-confine retrieval, all-or-nothing confined import, opaque catalog-id indirection, statement summary, and a generic rejection audit event that leaks no name, base path, token, or secret. - Every unsafe or missing name returns an indistinguishable generic 404; every unsafe archive is rejected whole with a 400, writing no entry. - Docker Compose is the only host workflow (secure app, one-shot demo, verify); GitHub Actions runs the same Compose verification boundary. No vulnerable code is introduced in this slice. Refs #1 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Avoid duplicate workflow runs on same-repo feature-branch PRs (both the push and pull_request events fired). The pull_request event still gates every PR. Refs #1 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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
Delivers the secure baseline (SLICE-001): a fully fictional, container-only
multi-tenant statement-archive service that handles a user-supplied filename the safe
way — resolve the candidate path, then confine it to its base directory — for both
reading a document and importing an archive. No vulnerable code is introduced.
Highlights:
archive directories, an out-of-root integration key carrying a
DEMO_SENTINEL, abranding config read at request time, and a planted symlink escaping the archive root.
GET /documents?name=…—resolve()+is_relative_to()confinement; everytraversing, absolute, percent-encoded, double-encoded, symlink-escaping, and
well-formed-but-missing name returns an indistinguishable generic
404.POST /documents/import— all-or-nothing: every entry confined (and links,absolute, and non-regular entries refused) before any byte is written; a bad
archive is rejected whole with a generic
400, leaving the tree byte-for-byteunchanged.
GET /documents/{document_id}— opaque catalog-id indirection (no path componentaccepted);
GET /statements/summaryreads the footer at request time.tenant, operation, outcome, and nothing else (no submitted name, base path, token, or
secret).
secure, one-shotdemo,verify);GitHub Actions runs the identical Compose verification boundary.
Verification
All run inside the container through the same boundary as CI:
docker compose run --rm verify→ green:ruff check,ruff format --check,mypy src tests(strict), andpytest(41 passed).docker compose run --rm demo→ 16/16 checks passed over real localhost HTTP:"secure baseline behaves as specified" (exit 0). Exercises legitimate reads/import/
summary, every secure rejection, catalog id, and the generic
401cases against therunning hardened container.
Acceptance criteria → evidence
Dockerfile,docker-compose.yml.—
docker compose run --rm demo.404for all unsafe + missing names —tests/test_secure_retrieval.py, scenario.400, no entry written —tests/test_secure_import.py,tests/test_fixture_integrity.py.200, unknown →404—tests/test_catalog.py.tests/test_audit.py.tests/test_summary.py.401for missing/malformed/unknown auth —tests/test_auth.py.verifyservice,.github/workflows/ci.yml.rejected path — secure-only;
tests/test_fixture_integrity.py.Risks / follow-ups
write) and the full comparison CLI are intentionally out of scope here and arrive in
later slices.
StarletteDeprecationWarningabouthttpxunder its TestClient; itdoes not affect results.
Safety
Wholly synthetic and local. Executes no command. This slice introduces no vulnerable code
path. The secure service runs non-root, all caps dropped,
no-new-privileges, read-onlyroot filesystem, loopback-only, with its disposable fixture tree on tmpfs.
Closes #1