Skip to content

safe-bash test/[: deeply nested \( \) hits a raw stack overflow reported as "Maximum call stack size exceeded" #668

Description

@kamilio

Where: packages/safe-bash/src/commands/predicates.ts — the recursive test/[ expression parser has no depth cap; argv is bounded only by the 64 KB cap / maxExpansionFields.

PoC:

test \( \( … ×3000 a \) \) … ×3000; echo rc=$?

Measured: script exit 0, rc=1, stderr test: Maximum call stack size exceeded, 31 ms, no crash.

Impact: (e) — error-contract wart only: a raw RangeError is caught and surfaced as a test failure rather than a classified diagnostic. Analogous to closed #583 (arithmetic).

Fix: depth counter (e.g. 256) → test: too many arguments / syntax error before recursion.

Found in security audit v3 (2026-09-07).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions