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
- SQL injection: read or delete the whole database.
- XSS: run JavaScript in other users' browsers and act as them.
- Command injection: run commands on the server.
Example: SQL injection
// email = "' OR '1'='1" returns every user.
const rows = await db.query(
"SELECT * FROM users WHERE email = '" + email + "'"
);// 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)
// comment = "<img src=x onerror=alert(document.cookie)>"
<div dangerouslySetInnerHTML={{ __html: comment }} />// React escapes text by default.
<div>{comment}</div>If you really need HTML, sanitise it first (for example with DOMPurify).
How to prevent it
- Parameterised queries or an ORM. Never build queries with string +.
- Validate input with a schema (zod) on the server.
- Let the framework escape output. Avoid dangerouslySetInnerHTML.
- Add a Content-Security-Policy as a second layer.
What CrimsonScan checks
Detected by CrimsonScanCore 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.