Skip to content

Unbounded pagination loop in loadCronJobForShow can hang indefinitely #83856

@davinci282828

Description

@davinci282828

Severity: high / Confidence: high / Category: bug
Triage: confirmed-bug
Detected against: openclaw v2026.5.18 (latest stable at time of scan, 2026-05-18)
Tooling: clawpatch 0.3.0 + acpx/claude-sonnet-4-5 via Brad Mills protocol (https://x.com/bradmillscan/status/2056377217437909178)

Evidence

  • src/cli/cron-cli/register.cron-simple.ts:103-123 (loadCronJobForShow)
for (;;) {
    const res = await callGatewayFromCli("cron.list", opts, {
      includeDisabled: true,
      limit: CRON_SHOW_PAGE_SIZE,
      offset,
    });
    const page = res as {
      jobs?: CronJob[];
      hasMore?: boolean;
      nextOffset?: number | null;
    };
    const jobs = page.jobs ?? [];
    const job = findCronJobInPage(jobs, idOrName);
    if (job) {
      return { job, deliveryPreview: coerceCronDeliveryPreviews(res).get(job.id) };
    }
    if (!page.hasMore || typeof page.nextOffset !== "number") {
      return {};
    }
    offset = page.nextOffset;

Reasoning

loadCronJobForShow uses an unbounded for (;;) loop with no max-pages guard and no check that nextOffset advances. If the gateway returns a page where nextOffset equals the current offset (misbehaving server or a bug), the loop spins forever issuing identical RPC calls. The sibling function loadCronJobForEditSchedulePatch has CRON_EDIT_LOOKUP_MAX_PAGES=50 guard and an advancement check, but loadCronJobForShow omits both.

Reproduction

Start a gateway that returns hasMore=true but nextOffset stays at 0. Run openclaw cron show <name>. The CLI loops forever.

Recommendation

Mirror the guard from loadCronJobForEditSchedulePatch: add a CRON_SHOW_LOOKUP_MAX_PAGES constant, assert nextOffset > offset, and throw when the limit is exceeded.

Why existing tests miss this

No tests are present for this feature group (tests array is empty in the feature manifest).

Suggested regression test

Unit test loadCronJobForShow with a mock callGatewayFromCli that always returns hasMore=true and nextOffset=0; assert it throws rather than looping.

Minimum fix scope

Add a page counter and advancement assertion to loadCronJobForShow, matching the existing pattern in loadCronJobForEditSchedulePatch.


Standardized clawpatch finding submission. Persistent across v2026.5.12 → v2026.5.18 — not resolved by upgrading. Finding ID: fnd_sig-feat-cli-command-1de66cf308-_e2f98649e2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:crash-loopCrash, hang, restart loop, or process-level availability failure.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions