Skip to content

Commit 5e6118e

Browse files
committed
Added test cases for client-s v2 and v3 sql injection
1 parent 1149617 commit 5e6118e

File tree

1 file changed

+44
-0
lines changed
  • javascript/ql/test/query-tests/Security/CWE-089/untyped

1 file changed

+44
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
const { S3Client, SelectObjectContentCommand } = require("@aws-sdk/client-s3");
2+
const AWS = require('aws-sdk');
3+
const express = require('express');
4+
const bodyParser = require('body-parser');
5+
6+
const app = express();
7+
app.use(bodyParser.json());
8+
9+
app.post('/client/v3/execute', async (req, res) => {
10+
let maliciousInput = req.body.filter; // $ MISSING: Source
11+
const client = new S3Client({ region: "us-east-1" });
12+
const params = {
13+
Bucket: "my-bucket",
14+
Key: "data.csv",
15+
ExpressionType: "SQL",
16+
Expression: "SELECT * FROM S3Object WHERE " + maliciousInput,
17+
};
18+
await client.send(new SelectObjectContentCommand(params)); // $ MISSING: Alert
19+
res.end();
20+
});
21+
22+
app.post('/client/v2/execute', async (req, res) => {
23+
let maliciousInput = req.body.filter; // $ MISSING: Source
24+
const s3 = new AWS.S3({ region: "us-east-1" });
25+
const params = {
26+
Bucket: "my-bucket",
27+
Key: "data.csv",
28+
ExpressionType: "SQL",
29+
Expression: "SELECT * FROM S3Object WHERE " + maliciousInput, // $ MISSING: Alert
30+
};
31+
await s3.selectObjectContent(params).promise();
32+
res.end();
33+
34+
const params1 = {
35+
Bucket: "my-bucket",
36+
Key: "data.csv",
37+
ExpressionType: "SQL",
38+
Expression: "SELECT * FROM S3Object WHERE " + maliciousInput, // $ MISSING: Alert
39+
};
40+
41+
s3.selectObjectContent(params1, (err, data) => {
42+
res.end();
43+
});
44+
});

0 commit comments

Comments
 (0)