Skip to content

guard repeat-end against empty stack in _yr_re_fiber_sync - #2240

Merged
plusvic merged 1 commit into
VirusTotal:masterfrom
jmestwa-coder:re-repeat-end-underflow
Aug 19, 2026
Merged

guard repeat-end against empty stack in _yr_re_fiber_sync#2240
plusvic merged 1 commit into
VirusTotal:masterfrom
jmestwa-coder:re-repeat-end-underflow

Conversation

@jmestwa-coder

Copy link
Copy Markdown
Contributor

The RE_OPCODE_REPEAT_END handler in _yr_re_fiber_sync does fiber->stack[fiber->sp]++ without checking that sp is not negative:

  • sp starts at -1 and only a preceding REPEAT_START advances it to 0
  • a hand-crafted .yrc can reach REPEAT_END with no matching REPEAT_START, so stack[-1]++ writes into the fiber's next pointer and the later fiber traversal follows the corrupted value
  • the REPEAT_START push already carries the paranoid upper-bound guard, only this lower bound was missing

Added the sp < 0 guard under YR_PARANOID_EXEC. A regexp of a single REPEAT_END opcode gives an ASAN SEGV in _yr_re_fiber_split before the patch and a clean ERROR_INTERNAL_FATAL_ERROR after; regression test added in test-re-split.c.

@plusvic
plusvic merged commit 46bf55b into VirusTotal:master Aug 19, 2026
12 of 14 checks passed
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.

2 participants