Skip to content

fix(ansi): u16 overflow on oversized CSI parameters - #108

Merged
im-nymii merged 1 commit into
Auri-OS:developfrom
kudasaixc:fix/ansi-param-overflow
Jul 24, 2026
Merged

fix(ansi): u16 overflow on oversized CSI parameters#108
im-nymii merged 1 commit into
Auri-OS:developfrom
kudasaixc:fix/ansi-param-overflow

Conversation

@kudasaixc

Copy link
Copy Markdown
Contributor

The CSI parameter accumulator multiplied and added with no overflow protection. A sequence like ESC[99999m overflows the u16 parameter and, since the Zig objects are built with -O ReleaseSafe, trips the safety check and lands in the panic handler: the kernel silently freezes. Saturating arithmetic clamps oversized parameters to 65535 instead of bringing the machine down.

The CSI parameter accumulator multiplied and added with no overflow
protection. A sequence like ESC[99999m overflows the u16 parameter
and, since the Zig objects are built with -O ReleaseSafe, trips the
safety check and lands in the panic handler: the kernel silently
freezes. Use saturating arithmetic so oversized parameters clamp to
65535 instead of bringing the machine down.
@kudasaixc

Copy link
Copy Markdown
Contributor Author

PoC

The CSI parameter accumulator has no overflow guard:

val.params[val.param_index] = (val.params[val.param_index] * 10) + n;

params is [8]u16. A big numeric parameter overflows it, and since the Zig objects are built -O ReleaseSafe, the overflow hits a runtime safety check that calls the panic handler (cli; hlt) — a silent, unrecoverable freeze. It is reachable from any text routed through the terminal:

echo \x1b[99999m

99999 > 65535, so the * 10 overflows the u16 and the kernel locks up. Attacker-influenced output — echo, shell error messages echoing a bad command, and any future serial/pipe input — can hard-freeze the machine with a single escape sequence, i.e. a trivial denial of service on the console.

Fix uses saturating arithmetic (*|, +|) so oversized parameters clamp to 65535 instead of trapping.

@im-nymii

Copy link
Copy Markdown
Member

LGTM !

@im-nymii
im-nymii merged commit 17d21e4 into Auri-OS:develop Jul 24, 2026
3 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