Skip to content

Commit 28ae679

Browse files
committed
Explicitly state the safe/unsafe reason and add some documentation
1 parent dc42b54 commit 28ae679

File tree

2 files changed

+158
-132
lines changed

2 files changed

+158
-132
lines changed

javascript/frameworks/cap/lib/advanced_security/javascript/frameworks/cap/CAPCqlInjectionQuery.qll

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,26 @@ class CqlClauseParserCallWithStringConcat instanceof CqlClauseParserCall {
159159
string toString() { result = super.toString() }
160160
}
161161

162+
/**
163+
* A data flow configuration from a remote flow source to a handful of sinks that run a CQL
164+
* query, either directly or indirectly by assembling one under the hood.
165+
*
166+
* The CQL injection happens if a fluent API builder (`SELECT`, `INSERT`, ...) or a
167+
* shortcut method call (`srv.read`, `srv.create`, ...) are called with a string
168+
* concatentation as one of its argument, which in practice can take one of its
169+
* following forms:
170+
*
171+
* 1. Concatentation with a string value with the `+` operator:
172+
* - Concatenation with a string: `"ID=" + expr`
173+
* - Concatenation with a template literal: `` `ID=` + expr ``
174+
* 2. Template literal that interpolates an expression in it but is not a tagged
175+
* template literal: `` SELECT.from`Entity`.where(`ID=${expr}`) ``
176+
*
177+
* The second case should be distinguished from the ones that have tagged template literals
178+
* for all of its builder calls: if the example were `` SELECT.from`Entity`.where`ID=${expr}` ``
179+
* instead (notice the lack of parentheses around the template literal), then the `where` call
180+
* becomes a parser call of the template literal following it and thus acts as a sanitizer.
181+
*/
162182
class CqlInjectionConfiguration extends TaintTracking::Configuration {
163183
CqlInjectionConfiguration() { this = "CQL injection from untrusted data" }
164184

0 commit comments

Comments
 (0)