Threat model
Scope: the SPIDER gateway, workers, stored data and the sources it reads. Method: assets → adversaries → threats by trust boundary → controls → residual risk. "Tested" points to the test that proves the control; controls without a test are marked as such.
Assets
- The internal network (MacLustr LAN, WireGuard 10.67/10.68/10.70, cloud metadata, other apps).
- Tenants' collected data, schemas, keys and webhooks.
- The sources: their availability, their terms, their users' personal data.
- The operator's reputation (the outbound address and the bot's name).
- Secrets: signing secret, API keys, worker keys, database credentials.
Adversaries
A. A client with a valid key trying to reach internal services or another tenant's data. B. A hostile web page (scripts, redirects, DNS tricks, huge or malformed content, prompt injection, content that becomes active when displayed in the dashboard). C. A network attacker between workers and gateway, or on the public route. D. A compromised worker node. E. An honest client asking for something a source forbids.
Boundary 1 — client → gateway
| Threat | Control | Status |
|---|---|---|
| Unauthenticated or under-scoped use | Hashed keys (SHA-256 of a 256-bit secret), scopes, expiry, revocation, rotation; 401/403 structured errors | tested (tests/integration/test_api_*) |
| Session theft / CSRF on the dashboard | HttpOnly SameSite=Strict cookie, per-session CSRF token on every state-changing request, 12 h expiry, sessions deleted on key revocation | tested |
| Cross-tenant read | every query filtered by tenant; other tenants' ids answer 404; signed artifact URLs bind artifact + tenant + expiry | tested |
| Existence leak through deduplication | references are per tenant; no answer depends on prior existence of a blob | tested |
| Abuse / exhaustion | per-key rate limit, quotas on active and daily jobs, body size limits, bounded budgets validated server-side | tested |
| Disabling safety by request | mandatory policies are part of the contract; false is a validation error |
tested |
| Replay of a submission | idempotency keys unique per tenant; conflict on a different body | tested |
Residual: rate limiting is per gateway process (in memory). Dashboard authentication is by API key, not passkeys or an identity provider (ADR-0006).
Boundary 2 — worker → Web (SSRF and hostile content)
| Threat | Control | Status |
|---|---|---|
| Fetch of internal addresses | http/https only; no userinfo; denied ports; loopback, private, link-local (metadata), CGNAT, multicast, reserved, and their IPv6 forms (mapped, 6to4, NAT64, Teredo, compatible) refused; internal name suffixes refused | tested (tests/security/test_netguard.py) |
| DNS rebinding | every address of a name must be public; the connection is made to the validated address (pinned resolver), never re-resolved | tested |
| Redirect to internal or out-of-scope target | redirects followed manually; each hop re-validated (guard, scope, robots) | tested (fixture /r/internal, /r/metadata, /r/external) |
| Browser sub-resources, scripts, iframes reaching inside | browsers are launched with a loopback egress proxy as their only route (loopback not bypassed); the proxy applies the same rules and opens the upstream socket to the validated address; main-frame navigation restricted to allowed hosts | proxy tested; browser path tested in tests/unit/browser |
| Side effects on the source | no form submission; unsafe or ambiguous controls skipped with a reason; every non-GET request aborted at the network layer; dialogs dismissed; downloads and permissions denied | tested on the fixture /ui/danger (zero POST received) |
| Decompression bombs, endless bodies | cap on decoded size while streaming; sitemap gzip unpacked once with a cap; no archive unpacking | tested (/err/big, /err/gzip-bomb) |
| Malicious documents | PDF: text layer only, JavaScript/attachments flagged and never executed | tested (extract unit tests) |
| Browser escape / resource exhaustion | fresh context per page, no persistent profile, recycle by count and memory, hard time-out watchdog, only PIDs spawned by the pool are killed | tested for time-out and recycling; no OS sandbox profile beyond the browser's own (residual) |
| Prompt injection against the vision model | image content declared untrusted in the prompt; model has no tool, no network, no SPIDER secret in its environment; output parsed as JSON, only requested scalar fields, coerced to the schema; a value is accepted only if OCR shows it in the capture | tested with a real model run |
| Injection through extracted text | extraction is deterministic parsing; page text is data; nothing extracted is executed or used as an instruction | tested (fixture /product/5) |
Residual: the egress proxy trusts the host resolver of the worker node. Workers run as the node's normal user, not in a container; filesystem isolation relies on per-task temporary directories. CPU/RAM limits are those of the browser pool, not cgroups.
Boundary 3 — stored content → dashboard and exports
| Threat | Control | Status |
|---|---|---|
| Stored XSS from snapshots | HTML/SVG artifacts served as text/plain or attachment with CSP: sandbox; nosniff; the dashboard writes API data with textContent only; replay is a neutralised document in a sandboxed iframe |
tested |
| Replay contacting the source or running its scripts | scripts, handlers, javascript: URLs, meta refresh, <base> removed; external URLs neutralised; strict CSP in the document |
tested (replay unit tests) |
| Spreadsheet formula injection | CSV cells beginning with = + - @ are prefixed |
tested |
| Leak of signed URLs | 5-minute expiry; exports never contain them | tested |
Boundary 4 — gateway ↔ workers, secrets
| Threat | Control | Status |
|---|---|---|
| Rogue worker | worker keys (hashed, revocable, rotatable); a worker acts only on tasks it holds the lease and fencing token for; uploads are hash-verified; input artifacts served only to the lease holder of the same tenant | tested |
| Stale worker overwriting results | fencing tokens | tested |
| Interception | private network (WireGuard / LAN); no mTLS (residual, ADR-0006) | not tested |
| Secret disclosure | secrets outside Git (0600 files, environment), secret scan before every commit and push; logs carry no key; console/network captures redacted | redaction tested |
A compromised worker node can read the pages it is given and its worker key; it cannot read the
database or other tenants' stored artifacts. Revocation: DELETE /v1/keys/{id}.
Boundary 5 — SPIDER → sources (compliance)
| Risk | Control | Status |
|---|---|---|
| Ignoring robots.txt | checked in the worker before every fetch and redirect hop; 5xx on robots = disallow | tested (zero requests to disallowed fixture paths) |
| Hammering a host | one request in flight per host for the whole fleet, minimum delay, Crawl-delay, Retry-After, adaptive back-off on 429 |
tested |
| Working around a refusal | CAPTCHA, login wall, paywall, 401/403 → URL blocked; CAPTCHA or three consecutive denials → host suspended for everyone (1 h, doubling, 7 days max); no stealth, no solving, no rotation | tested |
| Unbounded exploration | budgets on pages, depth, states, actions, bytes, duration; trap heuristics and per-pattern budgets | tested |
| Personal data | no logged-in collection; mask=pii on exports; retention with deletion and garbage collection |
masking and GC tested; no automatic PII classifier (residual) |
| Rights on content | captures and text are stored for the tenant that collected them; search indexes only what noindex does not exclude |
partly tested |
Kill switches: per source and global (PUT /v1/policies), effective at once for queued work and
propagated to workers at their next heartbeat.
Incident procedure (summary; runbook in docs/RUNBOOKS.md)
- Engage the global kill switch. 2. Revoke the suspected keys. 3. Drain or stop the affected
workers. 4. Read
/v1/auditand the gateway logs byrequest_id. 5. Rotate the signing secret if the gateway host is in doubt (invalidates sessions and signed URLs). 6. Restore from backup if data integrity is in doubt (scripts/restore.sh).
Supply chain
Dependencies are pinned by uv.lock; scripts/sbom.sh writes docs/sbom.cdx.json and a licence
table; pip-audit is run on the lock file. Browser binaries come from Playwright's distribution.
The vision model is loaded from the local cache only, offline.