Skip to content

Commit 6c18b4d

Browse files
committed
JS: Add test case for graph ql variableValues injection
1 parent 6d461d6 commit 6c18b4d

File tree

1 file changed

+20
-0
lines changed
  • javascript/ql/test/query-tests/Security/CWE-094/CodeInjection

1 file changed

+20
-0
lines changed

javascript/ql/test/query-tests/Security/CWE-094/CodeInjection/graph-ql.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,24 @@ app.post('/graphql', async (req, res) => {
3333
variableValues: variables
3434
});
3535
res.json(result);
36+
37+
const root1 = {
38+
greet: ({ name, title }) => {
39+
return eval(name + title).toString(); // $ MISSING: Alert[js/code-injection]
40+
}
41+
};
42+
graphql({
43+
schema: buildSchema(`
44+
type Query {
45+
greet(name: String!, title: String): String
46+
}
47+
`),
48+
source: `
49+
query GreetUser($name: String!, $title: String) {
50+
greet(name: $name, title: $title)
51+
}
52+
`,
53+
rootValue: root1,
54+
variableValues: variables
55+
});
3656
});

0 commit comments

Comments
 (0)