Skip to content

PromQL query_range step-count guard is bypassed by long overflow, wedging an Undertow worker thread in an unbounded loop #6807

Closed

Description

@ruispereira

Summary

The PromQL query_range step-count guard is computed in signed 64-bit arithmetic. A span wider than Long.MAX_VALUE milliseconds makes endMs - startMs overflow negative, the guard passes, and the per-step loop then runs unbounded, wedging an Undertow worker thread for the life of the process.

Where (HEAD 9c9d024db)

server/src/main/java/com/arcadedb/server/http/handler/GetPromQLQueryRangeHandler.java:68 - no range check on the inputs:

final long startMs = (long) (Double.parseDouble(startStr) * 1000);
final long endMs = (long) (Double.parseDouble(endStr) * 1000);

engine/src/main/java/com/arcadedb/engine/timeseries/promql/PromQLEvaluator.java:151 - the only protection:

final long maxSteps = (endMs - startMs) / stepMs + 1;
if (maxSteps > MAX_RANGE_STEPS) throw ...

PromQLEvaluator.java:161 - the loop it is supposed to bound:

for (long t = startMs; t <= endMs; t += stepMs)

Repro

GET /api/v1/ts/mydb/prom/api/v1/query_range?query=up&start=-9e15&end=9e15&step=60

startMs = -9e18, endMs = 9e18, the difference overflows, maxSteps comes out negative, the MAX_RANGE_STEPS (1,000,000) check passes, and the per-step loop begins. For a non-existent metric each step is cheap (evaluateVectorSelector returns new InstantVector(List.of()), PromQLEvaluator.java:201), so nothing throws and nothing bounds it: the request never returns and the worker thread is lost, since there is no query timeout or cancellation on this path. Repeat once per worker thread and the HTTP listener is down.

Reachable by any authenticated principal that passes checkAuthorizationOnDatabase for one time-series database. Note that endMs < startMs (:146) does not catch it (both operands are in order) and stepMs <= 0 is rejected earlier in the handler.

Suggested fix

Compute the span with Math.subtractExact/Math.floorDiv inside evaluateRange (or reject the request when the subtraction overflows), and additionally validate in the handler that start/end parse to a finite, sane epoch range before the multiplication by 1000 saturates.

Scope / confidence

High. Verified at HEAD, including that the missing-type fast path returns an empty vector rather than throwing, so the loop is not aborted on the first step.

Activity

  1. added this to the 26.9.1 milestone on Aug 27, 2026
  2. added
    server
    on Aug 27, 2026
  3. added
    in progress
    on Aug 28, 2026
  4. self-assigned this
    on Aug 28, 2026
  5. added 2 commits that reference this issue on Aug 28, 2026
  6. lvca commented on Aug 28, 2026

    @lvca
    Member

    Fixed in #6866, milestone 26.9.1.

    A PromQL range query with an extremely wide time span (for example start=-9e15&end=9e15) overflowed the internal step counter, so the check that limits how many points a query may produce was bypassed and the query looped forever. The request never returned and the server thread handling it was lost; repeating the call enough times could make the HTTP interface stop answering.

    The span and step count are now computed in a way that cannot overflow, and start, end, step and time are validated before the query runs: a value that is not a number, is infinite, or is outside a sensible date range is refused with 400 bad_data instead of a 500 or a hang. Both /query and /query_range behave the same way.

    What you may notice: malformed time-range parameters now return a clear 400 error instead of failing later or hanging.


    ❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.

  7. removed
    in progress
    on Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugserver

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions