InBrott
target://chained-ssti-rce
extremeOPEN

Template Preview Gateway

extremechained-bugssstiauth-bypass

// Scenario (Chained Vulnerabilities)

PreviewGateway renders admin email templates from a request dict req = {"headers": ..., "template": ..., "context": ...}.

// The Chained Bugs

  1. Header Auth Bypass: is_authorized trusts x-forwarded-role: admin if x-internal-proxy is present (without verifying an HMAC signature on a canonical header string), AND uses prefix/substring checks on x-api-key.
  2. Server-Side Template Injection (SSTI) -> Code Execution: Once past the gate (or even if someone calls render_template directly), {{ expr }} placeholders are evaluated with eval() / new Function(...), allowing attackers to leak GATEWAY_SECRET or execute arbitrary code via __builtins__ / constructor.constructor.

// Your Task

Fix both links in the chain:

  1. Enforce strict constant-time HMAC-SHA256 verification of x-gateway-sig over "{role}:{timestamp}" (with header keys case-insensitive, timestamp freshness check abs(now_ts - ts) <= 60, and role == "admin") — ignore spoofable forwarding headers.
  2. Eliminate eval / new Function completely: render {{ key }} placeholders strictly by looking up allowlisted plain string/number keys in context (HTML-escaped), rejecting nested dunder/prototype property access.

Sample Sanity Checks (1)

  • Authorized HMAC preview renders safe template
    Valid x-gateway-ts + x-gateway-sig renders {{name}}
Hints (0/3)
initializing editor...

[idle] Press RUN to execute visible sample checks, or SUBMIT to run hidden exploit & functionality suites.