Skip to content

fix(inspection): read the signatory line in linear time - #67

Merged
devin-ai-integration[bot] merged 2 commits into
mainfrom
devin/1795451153-signed-redos
Nov 23, 2026
Merged

devin-ai-integration[bot] merged 2 commits into
mainfrom
devin/1795451153-signed-redos

Conversation

@shmindmaster

@shmindmaster shmindmaster commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

What changes

Fixes CodeQL js/polynomial-redos alert 3 in src/inspection/fields.mjs.

/^Signed:\s*(.+)$/ let \s* and .+ both match leading whitespace, so a Signed: line of many spaces that fails to match (e.g. ends in \n\n) backtracks quadratically. The pattern is now /^Signed:\s*(\S.*)$/: the value must start with a non-space character, which leaves one way to split the line.

Behavior: unchanged for every real signature (same captured value, trailing spaces included). A whitespace-only Signed: line used to yield a signatory of " "; it now yields null, so the conformance-signature rule treats it as missing (fail-closed). PDF inputs already trim such lines to Signed:, so this only affects raw line inputs.

New tests/fields.test.mjs: signatory read with cite, whitespace-only signature is null, and a 200,000-space pathological line read in under 2,000 ms (the old regex takes ~21 s on it; the bound leaves headroom for loaded runners).

Evidence

  • docker compose run --build --rm verify (ALL GREEN, 16 steps), gate (RELEASE ALLOWED, docs/TESTING.md unchanged) and drill (2/2 regressions blocked) pass
  • Positive and refusal paths are covered where relevant
  • A changed or new guard has a mutation that proves it can fail — n/a, no guard changed
  • Generated data was changed through its generator — n/a, no data changed
  • No secrets, customer data, proprietary prompts, or real operational records are included

Regression test against the old regex vs the fix:

old: ✖ a pathological signature line is read in linear time — readFields took 21363.6 ms
new: ✔ a pathological signature line is read in linear time (1.13801ms)

Boundary impact

none


Product Engineer opened this PR for Sarosh
Implemented in session Fix heatlot polynomial ReDoS CodeQL alert
Review with Devin · Open in Devin Desktop


The /^Signed:\s*(.+)$/ pattern let \s* and .+ both match leading
whitespace, so a signature line of many spaces that failed to match
backtracked quadratically (CodeQL js/polynomial-redos). Require the
captured value to start with a non-space character; a whitespace-only
signature now reads as no signatory.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

devin-ai-integration[bot]
devin-ai-integration Bot previously approved these changes Nov 23, 2026

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin autoapproved this pull request: Regex fix preserves real signatures and rejects blank ones without adding dependencies.
Warning: CI checks and external Devin Review findings are not visible, so their approval restrictions were not applied.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration
devin-ai-integration Bot dismissed their stale review November 23, 2026 16:35

Devin withdrew its approval: Autoapprover no longer classifies this pull request as safe to merge without human review.

  • Intent: The performance test allows slower reads than the PR description promises.
    Warning: CI checks and external Devin Review findings are not visible, so their approval requirements were not applied.
devin-ai-integration[bot]

This comment was marked as outdated.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 findings. Devin automatically fixed all 2 findings.

Fixed by Devin (2)
  • Load-sensitive signature regression test — Bound widened to 2000 ms; the old regex takes ~21 s on this input, so the test still discriminates with 10x margin.
  • Mismatch in documented test budget — PR description updated to the 2,000 ms bound; no code change needed.

View findings in Devin Review · Follow Devin's work

Devin Review

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin autoapproved this pull request: A focused regex fix preserves real signatures and adds regression tests.
Warning: CI checks and external Devin Review findings are unavailable, so their approval instructions were not applied.

@devin-ai-integration
devin-ai-integration Bot merged commit dc60419 into main Nov 23, 2026
4 checks passed
@shmindmaster
shmindmaster deleted the devin/1795451153-signed-redos branch November 24, 2026 23:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant