Safeguard
Application Security•

CWE-1060 Excessive Inefficient Server-Side Data Accesses

Too many queries in one function slows the product and can open a denial of service path. CWE-1060 explains the pattern and the fix.

Safeguard Security Team
2 min read

CWE-1060 is about a product that makes too many data queries without using efficient processing such as stored procedures. It hits any application with a database behind it, especially those built on an ORM where each property access can quietly run a query.

How it happens

A function loops over a list and issues a query for each item. Fifty items, fifty round trips. MITRE notes that what counts as "too many" varies by product, and that CISQ recommends a default maximum of 5 data queries for an inefficient function or procedure.

# Pattern to avoid: one query per order
for order_id in order_ids:
    rows = db.execute("SELECT * FROM items WHERE order_id = %s", (order_id,))
# Better: one query for the whole set
rows = db.execute(
    "SELECT * FROM items WHERE order_id = ANY(%s)", (order_ids,)
)

What an attacker gains

MITRE lists reduced performance due to computational expense. If an attacker can reach the code, the slowdown "might introduce a vulnerability." A request that triggers hundreds of queries is cheap to send and costly to serve.

How to find it

The record lists no detection methods. Turn on query logging in a test environment and count queries per request. Any endpoint whose query count grows with the input size is a candidate.

How to fix it

  1. Replace loops of queries with a single set-based query or a join.
  2. Move heavy multi-step data work into a stored procedure when it fits your design.
  3. Cap the size of lists a caller may submit.

Quick check

What default threshold does MITRE cite?

CISQ recommends a default maximum of 5 data queries for an inefficient function or procedure, though interpretation varies by product.

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.