Commit dcf2095
authored
PLU-354: prevent batched queries in operations (#789)
## Problem
We previously disabled batching multiple operations in a single HTTP
request. However, we still allow multiple root level fields in a single
operation. It was flagged out during VAPT that this might facilitate
potential DOS attacks and should only be enabled when strictly
necessary.
## Solution
Create a custom apollo plugin to detect if there are multiple root level
fields. If there are, throw a `BadUserInputError`.
## How to test
1. Run dev server and open http://localhost:3000/graphql to access the
sandbox
2. Test with the following query
```
query Batch {
h1: healthcheck {
version
}
h2: healthcheck {
version
}
}
```
3. You should be able to see the relevant error.1 parent 1460a33 commit dcf2095
File tree
2 files changed
+55
-1
lines changed- packages/backend/src/helpers
- __tests__
2 files changed
+55
-1
lines changedLines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| 11 | + | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
| |||
42 | 44 | | |
43 | 45 | | |
44 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
45 | 70 | | |
46 | 71 | | |
47 | 72 | | |
48 | 73 | | |
49 | 74 | | |
50 | 75 | | |
51 | 76 | | |
52 | | - | |
| 77 | + | |
53 | 78 | | |
54 | 79 | | |
55 | 80 | | |
56 | 81 | | |
57 | 82 | | |
58 | 83 | | |
59 | 84 | | |
| 85 | + | |
60 | 86 | | |
| 87 | + | |
| 88 | + | |
61 | 89 | | |
62 | 90 | | |
63 | 91 | | |
| |||
0 commit comments