Files
Jalil 04909d5fcb fix(den): stop slow regular expressions from stalling the API (#7389)
Security hardening. A regular expression matches synchronously, so no
timer, including a Workflow's own timeout, can stop one that backtracks
exponentially. Den now stops caller-supplied patterns itself.

- time-limit.ts: runWithTimeLimit runs synchronous work under Node's
  script timeout, whose watchdog thread can end a match in progress.
- JSON Schema checks for Workflow input and output and for remote MCP
  tool arguments run under it (250 ms) and report a check that took too
  long as a validation failure.
- Programs match through a RegExp subclass that allows 250 ms of
  matching per event-loop turn, so slow matches in a loop stop too. The
  program gets a RangeError it can read or catch.
- Both engines build program regular expressions through one hook:
  host-regexp.ts in @openwork/codemode and a two-line patch to
  @opencode/codemode 2.2.5. Hosts that install no constructor are
  unchanged.

Signed-off-by: Jalil <reachjalil@gmail.com>
2026-11-13 13:31:53 -08:00
..