The platform is dropping Caddy: Atrium's backend becomes the front door and
forwards /counsel/* with the prefix stripped, so Counsel must answer for
everything Caddy did for it.
- app/edge.py: SecurityHeaders (pure ASGI, so every response is stamped,
404/405/413/500 included) with Caddy's exact set: nosniff, no-referrer,
the same CSP with frame-ancestors from FRAME_ANCESTORS, X-Frame-Options
DENY or SAMEORIGIN to match, HSTS only over https. BodySizeLimit caps a
request at 100 MB, by Content-Length and while reading a chunked body.
SpaStaticFiles is try_files {path} /index.html. ConsoleUnlessApi keeps
/api and /healthz from ever falling to the console (405 with Allow, or
404), comparing route paths, never the prefixed URL.
- FRAME_ANCESTORS: 'none' (default, unframable) or 'self' (Atrium's frame);
anything else refuses to start.
- GET/HEAD /healthz answers 200 without the database; GZipMiddleware.
- Dockerfile: the frontend comes in as a named build context; uvicorn runs
with --proxy-headers, --forwarded-allow-ips and --no-server-header.
- Standalone compose: no Caddy, the backend is published on :80; TLS is
the operator's own terminator in front. Caddyfile deleted.
- README, CLAUDE.md, SECURITY.md and .env.example follow.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2.4 KiB
Security policy
Reporting a vulnerability
Please report security issues privately — do not open a public issue.
- Preferred: GitHub private vulnerability reporting — the repo's Security tab → Report a vulnerability (opens a private advisory).
- Or contact the maintainer @Alpaq92 directly.
Include reproduction steps, the affected component, and the impact. Expect an initial response within a few days; please allow time for a fix before any public disclosure.
Scope & threat model
A self-hosted, single-tenant app. The model assumes a trusted operator and a private deployment
with the backend as its own edge (it serves the console and sets the security headers; Postgres is expose-only, never published; TLS is terminated in front of it or by the platform's front door). Of particular interest:
authentication/session handling, the RBAC checks, the append-only audit trail, hand-written SQL
(pg8000 paramstyle), and the static frontend's XSS / token-handling posture.
Security invariants (must hold)
Enforced in the codebase and documented in CLAUDE.md:
- Backend — append-only
audit_log(runtimeapprole has noUPDATE/DELETE); least-privilege DB roles (app= DML,migrator= DDL); Argon2id + app-level login lockout; server-side sessions (instant kill-switch); RFC 9457 errors with stack traces hidden in production; in-app regex email validation;FORWARDED_ALLOW_IPSscoped to the trusted proxy subnet. - Frontend —
esc()on every interpolated value; the bearer token is kept in memory only (neverlocalStorage);sanitizeBase()restricts the API base to relative / same-origin / localhost.
A regression test (backend/tests/test_smoke.py::test_frontend_xss_tripwires) guards the frontend
invariants, and the CI license gate fails the build on any GPL/AGPL/SSPL dependency.
Branch protection
main is protected by the ruleset in .github/rulesets/main.json:
require a pull request, require the test CI check to pass (strict), resolve review threads,
no force-push, no deletion.
GitHub rulesets require GitHub Pro or a public repo. Once that's available, apply it with:
gh api repos/Alpaq92/CounselScorecard/rulesets --method POST --input .github/rulesets/main.json
…or Settings → Rules → Rulesets → New ruleset → Import a ruleset.