SiteShadow
Back to vulnerability library

CWE-94 Code Injection

What this means

SiteShadow flagged a pattern where untrusted input may be interpreted and executed as code (directly or indirectly). Examples include eval, dynamic language execution, expression languages, or template engines used unsafely.

Why it matters

Code injection can lead to full system compromise.

Safer examples

1) Don't evaluate untrusted input

// Bad: eval(req.body.expr)
// Good: parse a known format instead
const n = Number.parseInt(req.body.count, 10);
if (!Number.isFinite(n)) throw new Error("Invalid count");

2) Use allowlists for "dynamic" behavior

handlers = {"csv": handle_csv, "pdf": handle_pdf}
handler = handlers.get(kind)
if not handler:
    raise ValueError("Unsupported kind")
handler(payload)

3) Lock down template/expression features

Use frameworks that escape by default and avoid exposing expression evaluation to user-controlled strings.

How SiteShadow detects it (high level)

References

---

← Back to Vulnerability Library

Request access View coverage