Safeguard
Application Security•

CWE-1094 Excessive Index Range Scans on Large Tables

CWE-1094 is an index range scan that can cover a huge number of rows in a large table. Slow queries are the symptom, and attackers can trigger them on purpose.

Safeguard Security Team
2 min read

CWE-1094, Excessive Index Range Scan for a Data Resource, applies when a product contains an index range scan for a large data table, but the scan can cover a large number of rows.

MITRE notes that the definition of large depends on the team. The CISQ standard recommends thresholds of 1000000 table rows and an index range of 10. MITRE marks the entry as a quality issue with no direct security implications, and prohibits it for mapping real vulnerabilities.

How it happens

A query filters on a range, such as dates or ids, and the range is not bounded tightly. On a small table that is fine. On a table with millions of rows, the database walks through a large slice of the index on every call.

-- Smell: caller controls both ends of the range, no upper limit on width
SELECT * FROM events
WHERE created_at BETWEEN :start AND :end
ORDER BY created_at;

If a request lets the user pick any start and end, one call can ask for the whole table.

What an attacker gains

MITRE lists reduced performance, and notes that if an attacker can reach the code, the performance problem might introduce a vulnerability. The realistic one is denial of service by expensive query: a few wide range requests keep the database busy and starve other users.

How to find it

  • Review queries with range filters on large tables, especially those driven by request parameters.
  • Look at the database query plan and at slow query logs for scans that touch many rows.
  • Load test with the widest range your API accepts.

How to fix it

  1. Cap the range width a caller can request.
  2. Paginate results and always apply a row limit.
  3. Make sure the range column has a suitable index, and use keyset pagination for deep paging.
  4. Set statement timeouts in the database, so no single query runs unbounded.
  5. Rate limit endpoints that run heavy queries.

Quick check

How can a user control the cost of a range query?

If the API accepts arbitrary start and end values with no limit, a caller can request nearly the whole table in one call.

Sources

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.