ΣύνδεσηΕγγραφή
A05 · 2025

Injection

User input is run as code: SQL, NoSQL, shell commands or HTML (XSS).

What it is

Injection happens when input is glued into something that gets interpreted, like a SQL query, a shell command, or HTML. The attacker's text stops being data and becomes instructions.

What can happen

Example: SQL injection

✕ Vulnerable
// email = "' OR '1'='1" returns every user.
const rows = await db.query(
  "SELECT * FROM users WHERE email = '" + email + "'"
);
✓ Fixed
// Parameterised: the driver sends email as data, never as SQL.
const rows = await db.query(
  "SELECT * FROM users WHERE email = $1",
  [email]
);

MongoDB has the same problem: validate types with zod so { "$ne": null } can't reach a query.

Example: Cross-site scripting (XSS)

✕ Vulnerable
// comment = "<img src=x onerror=alert(document.cookie)>"
<div dangerouslySetInnerHTML={{ __html: comment }} />
✓ Fixed
// React escapes text by default.
<div>{comment}</div>

If you really need HTML, sanitise it first (for example with DOMPurify).

How to prevent it

What CrimsonScan checks

Detected by CrimsonScan

Core feature. The light scan runs Nuclei sqli, xss and lfi templates. The heavy scan (ZAP active scan) tries injection payloads on every form and parameter it finds.

Read more on owasp.org ↗