Spaces:
Sleeping
Sleeping
|
Download docs/SECURITY.md from EnergyVenom/patch-testing-coworker: direct link, hf CLI and curl.
- Browser
- Download file 8.36 kB
-
https://huggingface.co/spaces/EnergyVenom/patch-testing-coworker/resolve/main/docs/SECURITY.md
- Command line
-
hf download hf://spaces/EnergyVenom/patch-testing-coworker/docs/SECURITY.md
-
curl -L -o SECURITY.md https://huggingface.co/spaces/EnergyVenom/patch-testing-coworker/resolve/main/docs/SECURITY.md
8.36 kB
| # Security | |
| Report a vulnerability privately to the repository owner; do not open a public issue. | |
| ## Controls in place | |
| | Area | Control | Where | | |
| |---|---|---| | |
| | Passwords | argon2id; at most `FPT_HASH_CONCURRENCY` hashes at once (memory-exhaustion guard) | `platform/users.py` | | |
| | Sign-in | 5 failed attempts per user and visitor in 5 minutes, then paused; per-visitor through a trusted proxy (`FPT_TRUST_PROXY`) | `platform/users.py`, `__main__.py` | | |
| | Sessions | server-side, httpOnly cookie, SameSite Strict (None only when embedded), Secure behind https; browser-session cookie unless "keep me signed in" (7 days); password change or reset ends other sessions | `api/routes/auth.py` | | |
| | CSRF | double-submit token checked on every unsafe cookie request | `api/auth.py` | | |
| | Authorization | role permissions enforced server-side on every route (`require(perm)`) | `platform/users.py` PERMISSIONS | | |
| | Registration | new accounts are viewers; admin list applies only to confirmed addresses; can be switched off | `api/routes/auth.py`, feature switches | | |
| | Input | pydantic `Strict` models on all request bodies | `api/schemas.py` | | |
| | Output | errors in one format `{detail, code, request_id}`; 500s carry no stack trace | `api/errors.py` | | |
| | Headers | CSP, X-Frame-Options, nosniff, Referrer-Policy, Permissions-Policy, HSTS behind https | `api/middleware.py` | | |
| | CORS | none needed in production (`FPT_CORS_ORIGINS=[]`) | `config.py` | | |
| | Outbound calls | one egress gate, host-pinned, audited, kill switch | `platform/egress.py` | | |
| | Notifications | webhook to the configured host only (https), HMAC-SHA256 signed, retried then given up; payload is plain words, run names, area names and counts, never secrets, test data or screenshots; errors redacted | `platform/notify.py` | | |
| | Telegram notifications | sent only to api.telegram.org through the egress gate; the bot token is a secret (vault / Space secret) that is never logged or returned: the audit shows `api.telegram.org/bot(hidden)/...`, error texts have it removed, and refused requests are audited with the hidden address too; same message content rules as the webhook; only administrators choose the chat | `platform/notify.py` | | |
| | Two-way bot (Telegram, Teams next) | a chat is linked to one Patchwise account by a one-time code made by that signed-in person (hashed, single use, 10 minutes, 5 tries per 10 minutes); the bot then acts as that person with their role: free text and /run go through the Ask service (propose, then the person's button press re-checks RBAC and state through api/actions.py); buttons carry only a random id, stored server-side and bound to chat, person, 24-hour expiry and single use; sign-off, failure verdicts, the kill switch and administration are never offered (links only); every step audited as `channel.*`; notifications reach a linked person only for runs they may read, from when they linked; the bot token is masked in HTTP client logs as well | `channels/`, `api/routes/channels.py`, docs/CHANNELS.md | | |
| | MCP connector | personal access tokens (`pwt_`, shown once, SHA-256 at rest, compared in constant time, 1 to 365 days, revocable by the owner or an administrator), accepted only on `/mcp` and refused on `/api`; always the owner's current role (disabled owners refused); scopes `read` or `read,act`; acting is propose → `confirm` (single use, 10 minutes, same person and token, re-checks role, run state and the emergency stop); sign-off, verdicts, the emergency stop and administration never offered; 60 requests a minute per token, 64 KB bodies, foreign browser origins refused, no CORS, cookies ignored; tokens masked in logs, never in the audit (`token.*`, `mcp.*` events) | `api/mcp.py`, `platform/api_tokens.py`, docs/MCP.md | | |
| | A2A agent | the same personal access tokens, scopes, per-token rate limit (shared with `/mcp`), origin guard and propose → confirm path as MCP, at `/a2a` (bodies up to 256 KB, 20 parts, 8,000 characters of text, 50 cases); the agent card at `/.well-known/agent-card.json` is public and holds no secrets; tasks are bound to their owner and token (admins can read, not act); a caller can never approve custom cases, scenarios or failures, sign off, waive or touch the emergency stop; caller facts (pod, patch changes) are stored as untrusted data, never sent to an LLM as instructions, and their URLs are displayed only, never fetched; every task, state change, proposal, confirm, run, refusal and cancel is audited as `a2a.*` without tokens | `api/a2a.py`, docs/A2A.md | | |
| | Secrets | env or encrypted vault; never in API answers, logs or child processes | `platform/vault.py`, `platform/procs.py` | | |
| | Fusion | production pods refused; read-only except seeding and cancelling test data; password kept out of traces | `platform/pods.py`, `automation/src/fusion/ui.ts` | | |
| | Audit | append-only, hash-chained, verifiable (`/api/audit/verify`) | `platform/audit.py` | | |
| | Public surface | anonymous `/api/ready` shows no internals; API docs off in production | `api/routes/admin.py` | | |
| | Exports | CSV cells that start with `= + - @` are neutralised | `api/routes/runs.py` | | |
| ## Known residual risks (decisions recorded in docs/AUDIT.md) | |
| - The backup archive key is derived from the Supabase service key unless `FPT_STATE_KEY` is set (S8). | |
| - Supabase "Confirm email" must stay on for the admin list to be safe (S5). | |
| - react-router 6 has two moderate advisories fixed only in 7.x; the open-redirect one is not reachable here (the | |
| return path after sign-in is checked). | |
| - A Copilot Studio agent using a personal token acts as that one person for everyone who uses the agent; use a `read` | |
| token from a least-privileged account until OAuth (docs/MCP.md, phase 2). | |
| - Python dependencies are pinned at top level only; base images are not digest-pinned. | |
| ## Rotating secrets | |
| Set the new value in the platform's secret store and restart. For the Fusion test user also update the user in | |
| Fusion first. Exposed keys must be revoked at the provider (NVIDIA, Hugging Face, Supabase), not only replaced here. | |
| ## Incoming-webhook integrations (Slack, Teams, Google Chat, Discord) | |
| - The webhook address is a bearer credential. It is accepted only from administrators, validated against the service's own | |
| host and path (https, no user info, standard port), stored in the vault, registered with the redactor, and never returned. | |
| - The server log masks webhook paths and query strings for all four services (and Telegram bot tokens) in every line the | |
| HTTP client writes; the audit records only the host. Delivery errors are stored and printed with the address removed. | |
| - Message text from the app is neutralised per service: Slack `& < >` escaped, Google Chat angle brackets replaced, Discord | |
| `allowed_mentions` empty, so nothing the app writes can mention a whole channel or inject links. | |
| - Messages carry run names, areas and counts only (the same outbox rules as the other channels: no secrets, credentials, | |
| test data values or screenshots). | |
| ## Custom test cases (Excel, text, JSON) | |
| - Consultants and above only (`run.start`); approving or rejecting needs `gate.approve_cases`, the same as approving | |
| scenarios. Nothing runs before a person approves a scenario whose dry run passed; there is no automatic approval, also | |
| not for agents. A run accepts approved keys only and goes through the normal run path (kill switch included). | |
| - Uploads: `.xlsx` only, at most 2 MB, must be a zip container; opened read-only with cached values only, so formulas are | |
| never evaluated and macros never loaded. The uploaded file name is never used as a path; batch ids are checked against | |
| `[A-Za-z0-9_-]` and area codes against `[A-Z][A-Z0-9]{1,5}`, so staged and promoted paths can't be steered. | |
| - Limits: 50 scenarios × 40 steps per batch, 50,000 characters of text, 500 characters per step. JSON is strict (unknown | |
| fields refuse the batch). | |
| - Custom cases may contain client data, so they are never sent to an AI model (neither frontier nor local): steps are | |
| mapped by a fixed grammar, and steps it can't map are returned to be reworded. Text is stored and returned as data; | |
| the web app renders it escaped. | |
| - Drafts live in `FPT_HOME/staging` until approval. Parsing, building, the dry run, approval, rejection and runs are | |
| audited (`custom_cases.*`). | |