Threat Model (dz-sandbox)
This threat model covers the core HTTP/webhook simulation surface, control API, hosted mock pages, scenario loader, and log redaction subsystems.
Trust Boundaries
- Developer App -> Provider Mocks (
:4001,:4002,:4003): Untrusted test payloads containing redirect URLs, webhook URLs, query parameters, and fake credentials enter here. - Developer / CI / Dashboard -> Control API (
:4000): High-privilege control plane that mutates scenarios, virtual clock, stored resources, and triggers outbound webhook fetches. - Filesystem -> Custom Scenario Loader (
./scenarios): Loads YAML/JSON scenario definitions from disk at startup and during hot-reload. - Mocks -> Merchant Webhook Receiver (
WebhookDispatcher): Outbound HTTP POST requests to merchant-configuredwebhook_endpoint/webhook_url/targetUrl.
Threats & Mitigations
| # | Threat | Impact | Mitigation Implemented | Residual Risk / Policy |
|---|---|---|---|---|
| T1 | SSRF via Webhook URLs (169.254.169.254, LAN IPs 10/8, 172.16/12, 192.168/16, file://, redirect bounce, trusted.com.evil.com allowlist bypass) | Metadata credential theft or internal LAN probing when sandbox runs on CI/shared runner | isAllowedWebhookUrl() + security.ts enforce http(s) only, reject embedded creds/CRLF, block IPv4/IPv6 private/link-local/metadata ranges (and integer/octal/hex obfuscated IPs), enforce exact origin+path-boundary allowlist matching, and dispatch fetch(..., { redirect: 'manual' }). Localhost loopback requires DZ_ALLOW_LOCALHOST_WEBHOOKS !== 'false' (or allowlist). | DNS rebinding for public domain names resolving dynamically to private IPs is mitigated only when running with DZ_WEBHOOK_ALLOWLIST in shared/CI environments |
| T2 | Open Redirect / XSS via javascript: / data: Return URLs | Malicious link execution in developer browser on hosted payment page redirect | SafeHttpUrlSchema + isSafeHttpUrl() validate success_url, failure_url, returnUrl, failUrl (http: / https: only, no creds/CRLF), and sanitizeRedirectUrl() validates right before reply.redirect(...). HTML templates escape dynamic values. | Open redirect to another arbitrary public https:// site remains expected behavior because merchants configure their own success_url / returnUrl; sandbox is strictly local dev |
| T3 | Response Header Injection via Scenario Headers | HTTP response splitting or overriding Host / Transfer-Encoding / Set-Cookie | sanitizeHeaderEntry() in http.ts validates RFC 7230 token names, rejects \r, \n, \0 in values, and blocks host, content-length, transfer-encoding, connection, upgrade, set-cookie. | Custom allowed response headers remain bounded to scenario config |
| T4 | Oversized Payloads & Schema Validation DoS | Memory exhaustion via giant request bodies or unbounded collections | zod upgraded to >=4.6.7 (resolving GHSA-mrhx-c7xc-m3w5). Reinforced with explicit Fastify bodyLimit: 256 KiB (Chargily/SATIM), 512 KiB (Yalidine), 1 MiB (Control), and bounded array schemas (items.max(100), bulk parcels max(200), customScenarios.max(200), sequence.max(100)). | Fully resolved with 0 production vulnerabilities in npm audit --omit=dev |
| T5 | Path Traversal & Symlink Escape in Scenario Loader / Locales | Reading arbitrary files on disk or prototype property exposure (/locales/toString.json) | resolvePathInsideDir() resolves realpathSync on both base dir and entries, rejecting .., escapes, directories, and files > 512 KiB. /locales/:lang.json guards with Object.hasOwn(DASHBOARD_LOCALES, key). | File watcher relies on OS filesystem events on the trusted local workspace ./scenarios directory |
| T6 | Secrets Leaked in Control Request Logs | Exposure of Bearer headers, X-API-Token, SATIM query password=..., card-like PANs, or sk_live_/test_sk_ tokens in /__control/requests or exported bundles | redact.ts redacts sensitive headers (Authorization, X-API-ID, X-API-Token, X-API-Key, X-Secret-Key, X-DZ-Control-Token, Cookie), sensitive body/query keys, inline secret prefixes, query credential params in logged URL paths, and 13–19 digit card-like numbers (***1234). | Non-standard custom header names without token/secret keywords are logged; contributors use dz-sandbox record mandatory redactor before sharing fixtures |
| T7 | Network Exposure of Unauthenticated Control API | Remote attackers altering scenarios, resetting state, or abusing webhook dispatcher | Default bind host is 127.0.0.1. createControlServer() checks DZ_CONTROL_TOKEN via timingSafeEqualToken (401) OR blocks non-loopback request.ip (403) unless DZ_ALLOW_UNAUTH_CONTROL=true. runtime.ts warns loudly on non-loopback host without DZ_CONTROL_TOKEN. /__control/openapi.json sanitizes Host header. | When running inside Docker bridge, host port-forwarding uses 127.0.0.1:${PORT}:4000 in docker-compose.yml so external LAN callers cannot reach the container directly |