Skip to content

CLI error-envelope URL redaction uses a quadratic regex on server-controlled text (CodeQL, ReDoS) #2540

Closed

Description

@cliffhall

Problem

CodeQL flagged this on the v2.9.0 milestone-merge PR (#2536) as high severity: "Polynomial regular expression used on uncontrolled data". I confirmed it in the running CLI.

clients/cli/src/error-handler.ts:169 strips trailing punctuation off every URL embedded in an error message with TRAILING_PUNCTUATION = /[.,;:!?)\]']+$/. A […]+$ with no start anchor is quadratic: on a long run of those characters that does not end the string, the engine rescans the run from every start position.

The input is uncontrolled. The CLI copies an HTTP error body into its error message (Error POSTing to endpoint: <body>), so the server under inspection chooses it.

Measured

  • The regex alone on http://a/? + n × ! + x: 5k → 17 ms, 10k → 61 ms, 20k → 238 ms, 40k → 857 ms (quadratic).
  • End to end, a server answering 400 with see http://a/? + 60,000 × ! + x: the RC CLI took 3 s to emit its error envelope, against 0 s on 2.8.0. A larger body hangs the CLI for minutes.

Regression in this milestone: it came in with #2423's envelope redaction (PR #2488).

Expected

The trailing-punctuation split is linear: scan back from the end over the punctuation set instead of using an unanchored +$ regex. Behavior is otherwise unchanged (…?code=abc. keeps its full stop, a '…'-quoted URL loses its closing quote).

Activity

  1. added this to the v2.9.0 milestone on Sep 30, 2026
  2. self-assigned this
    on Sep 30, 2026
  3. added
    bugSomething isn't working
    v2Issues and PRs for v2
    on Sep 30, 2026
  4. cliffhall commented on Sep 30, 2026

    @cliffhall
    MemberAuthor

    Triage: Priority High (total 11)

    • Severity 3 — a server can stall the CLI's error path (DoS), and a regression introduced this milestone
    • Urgency 5 — blocking the v2.9.0 release (a high-severity CodeQL alert on the merge PR)
    • Bonuses: +1 bug label, +1 milestoned (v2.9.0), +1 assigned

    Board: #28, Status In Progress.

  5. cliffhall commented on Sep 30, 2026

    @cliffhall
    MemberAuthor

    Shipped in #2541 (merged to v2/main).

  6. added a commit that references this issue on Oct 4, 2026
    66dae5c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingv2Issues and PRs for v2

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions