Skip to content

der: fix stack overflow decoding nested BER indefinite lengths - #2490

Merged
tarcieri merged 1 commit into
masterfrom
der/fix-ber-stack-overflow
Oct 24, 2026
Merged

tarcieri merged 1 commit into
masterfrom
der/fix-ber-stack-overflow

Conversation

@tarcieri

Copy link
Copy Markdown
Member

The indefinite-length scanner recursively decoded nested headers without enforcing the reader's nesting limit, allowing untrusted BER input to overflow the stack and abort the process.

Replace recursive scanning with an allocation-free loop that tracks open indefinite-length values and enforces the shared 64-level nesting limit.

Add regression tests for excessive depth, valid nesting, sibling values, and malformed encodings.

The indefinite-length scanner recursively decoded nested headers without
enforcing the reader's nesting limit, allowing untrusted BER input to
overflow the stack and abort the process.

Replace recursive scanning with an allocation-free loop that tracks open
indefinite-length values and enforces the shared 64-level nesting limit.

Add regression tests for excessive depth, valid nesting, sibling values,
and malformed encodings.
@tarcieri
tarcieri force-pushed the der/fix-ber-stack-overflow branch from 1e5bb7e to 5d90299 Compare October 24, 2026 20:10
@tarcieri
tarcieri merged commit 922e331 into master Oct 24, 2026
117 checks passed
@tarcieri
tarcieri deleted the der/fix-ber-stack-overflow branch October 24, 2026 21:45
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