Skip to content

Commit 7b80925

Browse files
committed
waterline-sequel-0.5.0: complete and verified
1 parent 403e536 commit 7b80925

3 files changed

Lines changed: 190 additions & 0 deletions

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/**
2+
* PoC: SQL Injection in waterline-sequel 0.5.0
3+
*
4+
* Vulnerability: when parameterized: false, prepareCriterion() for
5+
* startsWith/contains/endsWith/like uses utils.escapeName() (meant
6+
* for SQL identifiers) to escape string values, allowing SQL injection.
7+
*/
8+
9+
var Sequel = require('waterline-sequel');
10+
var Symbolic = require('esl_symbolic');
11+
12+
// --- waterline-sequel setup ---
13+
14+
var schema = {
15+
foo: {
16+
tableName: 'foo',
17+
attributes: {
18+
color: 'string',
19+
id: { type: 'integer', primaryKey: true, autoIncrement: true, unique: true }
20+
}
21+
}
22+
};
23+
24+
var options = {
25+
parameterized: false,
26+
caseSensitive: false,
27+
escapeCharacter: '`',
28+
casting: false,
29+
canReturnValues: false,
30+
escapeInserts: true
31+
};
32+
33+
var sequel = new Sequel(schema, options);
34+
35+
// 1. Safe query (normal startsWith)
36+
console.log('[1] Safe query: color startsWith "red"');
37+
var safeResult = sequel.find('foo', {
38+
where: { color: { startsWith: 'red' } },
39+
instructions: {}
40+
});
41+
console.log(' Generated SQL: ' + safeResult.query[0]);
42+
43+
// 2. Vulnerable query: SQL injection via startsWith
44+
console.log('[2] VULNERABLE query: color startsWith malicious payload');
45+
var payload = Symbolic.string('payload');
46+
Symbolic.assume(payload !== '');
47+
var vulnResult = sequel.find('foo', {
48+
where: { color: { startsWith: payload } },
49+
instructions: {}
50+
});
51+
console.log(' Generated SQL: ' + vulnResult.query[0]);
52+
53+
Symbolic.sinkCall("sql-injection", "sequel.find", vulnResult.query[0]);

bench/packages/waterline-sequel-0.5.0/package-lock.json

Lines changed: 121 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"dependencies": {
3+
"waterline-sequel": "0.5.0"
4+
},
5+
"vulnerability": {
6+
"type": "sql-injection",
7+
"ghsa": "https://github.com/advisories/GHSA-cgpp-wm2h-6hqx",
8+
"snyk": null,
9+
"sink": {
10+
"file": null,
11+
"code": null,
12+
"line": null
13+
}
14+
}
15+
16+
}

0 commit comments

Comments
 (0)