Skip to main content
MediumAPIOWASP A04:2021CWE-799

How to fix: GraphQL batch (array) queries accepted

Accepting an array of queries lets a single HTTP request fan out to N independent operations, multiplying rate-limit cost and bypassing per-request throttles.

Why it matters

A single batched HTTP request containing 100 queries executes 100 independent resolver trees while consuming only 1 unit of any per-request rate limit: a cheap amplification attack that can exhaust database connections and CPU without triggering throttling.

Accepting an array of queries lets a single HTTP request fan out to N independent operations, multiplying rate-limit cost and bypassing per-request throttles.

How to fix it

  1. 1Disable batching if not required by clients
  2. 2If batching is needed, cap the array size (e.g., max 10 items) and charge each item against the rate-limit budget
  3. 3In Apollo Server: set allowBatchedHttpRequests: false in the HTTP handler options

Code examples

Apollo Server: disable batching

JavaScript
import { expressMiddleware } from '@apollo/server/express4';

app.use('/graphql', expressMiddleware(server, {
  allowBatchedHttpRequests: false,
}));

Custom batch size limit middleware

JavaScript
app.use('/graphql', (req, res, next) => {
  if (Array.isArray(req.body) && req.body.length > 10) {
    return res.status(400).json({
      errors: [{ message: 'Batch size limit exceeded (max 10).' }],
    });
  }
  next();
});

References

Detected automatically by VulnRadar. The check id is api-graphql-batch-queries, stable across every scan so you can filter or diff on it.

See every api check

Questions

How severe is GraphQL batch (array) queries accepted?
VulnRadar rates this medium severity in the api category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
Does VulnRadar check for this automatically?
Yes. It runs as part of every scan under the check id api-graphql-batch-queries, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does GraphQL batch (array) queries accepted map to?
It maps to CWE-799. In the OWASP Top 10 it falls under A04:2021.

Missing a check?

The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.

Propose a checkHow a check is built

Scan your own site for graphql batch (array) queries accepted

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

GraphQL batch (array) queries accepted fix | VulnRadar