Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
category: minorAnalysis
---
* Added modeling of `GraphQLObjectType` resolver function parameters as remote sources.
5 changes: 5 additions & 0 deletions javascript/ql/lib/ext/graph-ql.model.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ extensions:
extensible: summaryModel
data:
- ["graphql", "Member[graphql]", "Argument[0].Member[source,variableValues]", "Argument[0].Member[rootValue].AnyMember.Parameter[0]", "taint"]
- addsTo:
pack: codeql/javascript-all
extensible: sourceModel
data:
- ["graphql", "Member[GraphQLObjectType].Argument[0].Member[fields].AnyMember.Member[resolve].Parameter[1]", "remote"]
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
| fastify.js:108:28:108:50 | reply.l ... tedCode | fastify.js:94:29:94:51 | request ... plyCode | fastify.js:108:28:108:50 | reply.l ... tedCode | This code execution depends on a $@. | fastify.js:94:29:94:51 | request ... plyCode | user-provided value |
| graph-ql.js:20:19:20:22 | expr | graph-ql.js:28:32:28:39 | req.body | graph-ql.js:20:19:20:22 | expr | This code execution depends on a $@. | graph-ql.js:28:32:28:39 | req.body | user-provided value |
| graph-ql.js:39:19:39:30 | name + title | graph-ql.js:28:32:28:39 | req.body | graph-ql.js:39:19:39:30 | name + title | This code execution depends on a $@. | graph-ql.js:28:32:28:39 | req.body | user-provided value |
| graph-ql.js:66:23:66:27 | value | graph-ql.js:65:22:65:30 | { value } | graph-ql.js:66:23:66:27 | value | This code execution depends on a $@. | graph-ql.js:65:22:65:30 | { value } | user-provided value |
| module.js:9:16:9:29 | req.query.code | module.js:9:16:9:29 | req.query.code | module.js:9:16:9:29 | req.query.code | This code execution depends on a $@. | module.js:9:16:9:29 | req.query.code | user-provided value |
| module.js:11:17:11:30 | req.query.code | module.js:11:17:11:30 | req.query.code | module.js:11:17:11:30 | req.query.code | This code execution depends on a $@. | module.js:11:17:11:30 | req.query.code | user-provided value |
| react-native.js:8:32:8:38 | tainted | react-native.js:7:17:7:33 | req.param("code") | react-native.js:8:32:8:38 | tainted | This code execution depends on a $@. | react-native.js:7:17:7:33 | req.param("code") | user-provided value |
Expand Down Expand Up @@ -173,6 +174,8 @@ edges
| graph-ql.js:39:19:39:22 | name | graph-ql.js:39:19:39:30 | name + title | provenance | |
| graph-ql.js:39:26:39:30 | title | graph-ql.js:39:19:39:30 | name + title | provenance | |
| graph-ql.js:54:21:54:29 | variables | graph-ql.js:38:13:38:27 | { name, title } | provenance | |
| graph-ql.js:65:22:65:30 | { value } | graph-ql.js:65:24:65:28 | value | provenance | |
| graph-ql.js:65:24:65:28 | value | graph-ql.js:66:23:66:27 | value | provenance | |
| react-native.js:7:7:7:13 | tainted | react-native.js:8:32:8:38 | tainted | provenance | |
| react-native.js:7:7:7:13 | tainted | react-native.js:10:23:10:29 | tainted | provenance | |
| react-native.js:7:17:7:33 | req.param("code") | react-native.js:7:7:7:13 | tainted | provenance | |
Expand Down Expand Up @@ -323,6 +326,9 @@ nodes
| graph-ql.js:39:19:39:30 | name + title | semmle.label | name + title |
| graph-ql.js:39:26:39:30 | title | semmle.label | title |
| graph-ql.js:54:21:54:29 | variables | semmle.label | variables |
| graph-ql.js:65:22:65:30 | { value } | semmle.label | { value } |
| graph-ql.js:65:24:65:28 | value | semmle.label | value |
| graph-ql.js:66:23:66:27 | value | semmle.label | value |
| module.js:9:16:9:29 | req.query.code | semmle.label | req.query.code |
| module.js:11:17:11:30 | req.query.code | semmle.label | req.query.code |
| react-native.js:7:7:7:13 | tainted | semmle.label | tainted |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ edges
| graph-ql.js:39:19:39:22 | name | graph-ql.js:39:19:39:30 | name + title | provenance | |
| graph-ql.js:39:26:39:30 | title | graph-ql.js:39:19:39:30 | name + title | provenance | |
| graph-ql.js:54:21:54:29 | variables | graph-ql.js:38:13:38:27 | { name, title } | provenance | |
| graph-ql.js:65:22:65:30 | { value } | graph-ql.js:65:24:65:28 | value | provenance | |
| graph-ql.js:65:24:65:28 | value | graph-ql.js:66:23:66:27 | value | provenance | |
| react-native.js:7:7:7:13 | tainted | react-native.js:8:32:8:38 | tainted | provenance | |
| react-native.js:7:7:7:13 | tainted | react-native.js:10:23:10:29 | tainted | provenance | |
| react-native.js:7:17:7:33 | req.param("code") | react-native.js:7:7:7:13 | tainted | provenance | |
Expand Down Expand Up @@ -224,6 +226,9 @@ nodes
| graph-ql.js:39:19:39:30 | name + title | semmle.label | name + title |
| graph-ql.js:39:26:39:30 | title | semmle.label | title |
| graph-ql.js:54:21:54:29 | variables | semmle.label | variables |
| graph-ql.js:65:22:65:30 | { value } | semmle.label | { value } |
| graph-ql.js:65:24:65:28 | value | semmle.label | value |
| graph-ql.js:66:23:66:27 | value | semmle.label | value |
| module.js:9:16:9:29 | req.query.code | semmle.label | req.query.code |
| module.js:11:17:11:30 | req.query.code | semmle.label | req.query.code |
| react-native.js:7:7:7:13 | tainted | semmle.label | tainted |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const express = require('express');
const { graphql, buildSchema } = require('graphql');
const { graphql, buildSchema, GraphQLObjectType, GraphQLString } = require('graphql');

const app = express();
app.use(express.json());
Expand Down Expand Up @@ -53,4 +53,30 @@ app.post('/graphql', async (req, res) => {
rootValue: root1,
variableValues: variables
});

const MutationType = new GraphQLObjectType({
name: 'Mutation',
fields: {
runEval: {
type: GraphQLString,
args: {
value: { type: GraphQLString }
},
resolve: (_, { value }, context) => { // $ Source[js/code-injection]
return eval(value); // $ Alert[js/code-injection]
}
}
}
});

const schema = new GraphQLSchema({
query: QueryType,
mutation: MutationType
});

await graphql({
schema,
source: query,
variableValues: variables
});
});