/

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

  1. Developer App -> Provider Mocks (:4001, :4002, :4003): Untrusted test payloads containing redirect URLs, webhook URLs, query parameters, and fake credentials enter here.
  2. Developer / CI / Dashboard -> Control API (:4000): High-privilege control plane that mutates scenarios, virtual clock, stored resources, and triggers outbound webhook fetches.
  3. Filesystem -> Custom Scenario Loader (./scenarios): Loads YAML/JSON scenario definitions from disk at startup and during hot-reload.
  4. Mocks -> Merchant Webhook Receiver (WebhookDispatcher): Outbound HTTP POST requests to merchant-configured webhook_endpoint / webhook_url / targetUrl.

Threats & Mitigations

#ThreatImpactMitigation ImplementedResidual Risk / Policy
T1SSRF 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 runnerisAllowedWebhookUrl() + 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
T2Open Redirect / XSS via javascript: / data: Return URLsMalicious link execution in developer browser on hosted payment page redirectSafeHttpUrlSchema + 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
T3Response Header Injection via Scenario HeadersHTTP response splitting or overriding Host / Transfer-Encoding / Set-CookiesanitizeHeaderEntry() 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
T4Oversized Payloads & Schema Validation DoSMemory exhaustion via giant request bodies or unbounded collectionszod 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
T5Path Traversal & Symlink Escape in Scenario Loader / LocalesReading 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
T6Secrets Leaked in Control Request LogsExposure of Bearer headers, X-API-Token, SATIM query password=..., card-like PANs, or sk_live_/test_sk_ tokens in /__control/requests or exported bundlesredact.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
T7Network Exposure of Unauthenticated Control APIRemote attackers altering scenarios, resetting state, or abusing webhook dispatcherDefault 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
box.style.display = "block"; if (!hits.length) { box.innerHTML = "
" + noResultsText + "
"; return; } box.innerHTML = hits.map(function (hit) { return "" + hit.title.replace(/" + hit.path + " — " + hit.excerpt.replace(/"; }).join(""); }); })();