Skip to content

Commit b1525fa

Browse files
authored
Merge pull request #1162 from HackTricks-wiki/research_update_src_network-services-pentesting_pentesting-web_graphql_20250721_082948
Research Update Enhanced src/network-services-pentesting/pen...
2 parents ce2f61c + 431cd23 commit b1525fa

File tree

1 file changed

+74
-0
lines changed
  • src/network-services-pentesting/pentesting-web

1 file changed

+74
-0
lines changed

src/network-services-pentesting/pentesting-web/graphql.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,78 @@ curl -X POST -H "User-Agent: graphql-cop/1.13" -H "Content-Type: application/jso
600600
'https://example.com/graphql'
601601
```
602602

603+
## Recent Vulnerabilities (2023-2025)
604+
605+
> The GraphQL ecosystem evolves very quickly; during the last two years several critical issues were disclosed in the most-used server libraries. When you find a GraphQL endpoint it is therefore worth fingerprinting the engine (see **graphw00f**) and checking the running version against the vulnerabilities below.
606+
607+
### CVE-2024-47614 – `async-graphql` directive-overload DoS (Rust)
608+
* Affected: async-graphql < **7.0.10** (Rust)
609+
* Root cause: no limit on **duplicated directives** (e.g. thousands of `@include`) which are expanded into an exponential number of execution nodes.
610+
* Impact: a single HTTP request can exhaust CPU/RAM and crash the service.
611+
* Fix/mitigation: upgrade ≥ 7.0.10 or call `SchemaBuilder.limit_directives()`; alternatively filter requests with a WAF rule such as `"@include.*@include.*@include"`.
612+
613+
```graphql
614+
# PoC – repeat @include X times
615+
query overload {
616+
__typename @include(if:true) @include(if:true) @include(if:true)
617+
}
618+
```
619+
620+
### CVE-2024-40094 – `graphql-java` ENF depth/complexity bypass
621+
* Affected: graphql-java < 19.11, 20.0-20.8, 21.0-21.4
622+
* Root cause: **ExecutableNormalizedFields** were not considered by `MaxQueryDepth` / `MaxQueryComplexity` instrumentation. Recursive fragments therefore bypassed all limits.
623+
* Impact: unauthenticated DoS against Java stacks that embed graphql-java (Spring Boot, Netflix DGS, Atlassian products…).
624+
625+
```graphql
626+
fragment A on Query { ...B }
627+
fragment B on Query { ...A }
628+
query { ...A }
629+
```
630+
631+
### CVE-2023-23684 – WPGraphQL SSRF to RCE chain
632+
* Affected: WPGraphQL ≤ 1.14.5 (WordPress plugin).
633+
* Root cause: the `createMediaItem` mutation accepted attacker-controlled **`filePath` URLs**, allowing internal network access and file writes.
634+
* Impact: authenticated Editors/Authors could reach metadata endpoints or write PHP files for remote code execution.
635+
636+
---
637+
638+
## Incremental delivery abuse: `@defer` / `@stream`
639+
Since 2023 most major servers (Apollo 4, GraphQL-Java 20+, HotChocolate 13) implemented the **incremental delivery** directives defined by the GraphQL-over-HTTP WG. Every deferred patch is sent as a **separate chunk**, so the total response size becomes *N + 1* (envelope + patches). A query that contains thousands of tiny deferred fields therefore produces a large response while costing the attacker only one request – a classical **amplification DoS** and a way to bypass body-size WAF rules that only inspect the first chunk. WG members themselves flagged the risk.
640+
641+
Example payload generating 2 000 patches:
642+
643+
```graphql
644+
query abuse {
645+
% for i in range(0,2000):
646+
f{{i}}: __typename @defer
647+
% endfor
648+
}
649+
```
650+
651+
Mitigation: disable `@defer/@stream` in production or enforce `max_patches`, cumulative `max_bytes` and execution time. Libraries like **graphql-armor** (see below) already enforce sensible defaults.
652+
653+
---
654+
655+
## Defensive middleware (2024+)
656+
657+
| Project | Notes |
658+
|---|---|
659+
| **graphql-armor** | Node/TypeScript validation middleware published by Escape Tech. Implements plug-and-play limits for query depth, alias/field/directive counts, tokens and cost; compatible with Apollo Server, GraphQL Yoga/Envelop, Helix, etc. |
660+
661+
Quick start:
662+
663+
```ts
664+
import { protect } from '@escape.tech/graphql-armor';
665+
import { applyMiddleware } from 'graphql-middleware';
666+
667+
const protectedSchema = applyMiddleware(schema, ...protect());
668+
```
669+
670+
`graphql-armor` will now block overly deep, complex or directive-heavy queries, protecting against the CVEs above.
671+
672+
---
673+
674+
603675
## Tools
604676

605677
### Vulnerability scanners
@@ -641,5 +713,7 @@ https://graphql-dashboard.herokuapp.com/
641713
- [**https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/GraphQL%20Injection/README.md**](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/GraphQL%20Injection/README.md)
642714
- [**https://medium.com/@the.bilal.rizwan/graphql-common-vulnerabilities-how-to-exploit-them-464f9fdce696**](https://medium.com/@the.bilal.rizwan/graphql-common-vulnerabilities-how-to-exploit-them-464f9fdce696)
643715
- [**https://portswigger.net/web-security/graphql**](https://portswigger.net/web-security/graphql)
716+
- [**https://github.com/advisories/GHSA-5gc2-7c65-8fq8**](https://github.com/advisories/GHSA-5gc2-7c65-8fq8)
717+
- [**https://github.com/escape-tech/graphql-armor**](https://github.com/escape-tech/graphql-armor)
644718

645719
{{#include ../../banners/hacktricks-training.md}}

0 commit comments

Comments
 (0)