Skip to content

Validate DS ROM binary ranges without overflow - #2714

Open
acts-1631 wants to merge 1 commit into
melonDS-emu:masterfrom
acts-1631:fix/ds-rom-range-validation
Open

Validate DS ROM binary ranges without overflow#2714
acts-1631 wants to merge 1 commit into
melonDS-emu:masterfrom
acts-1631:fix/ds-rom-range-validation

Conversation

@acts-1631

Copy link
Copy Markdown

NDSCart::ValidateROM checked ARM9 and ARM7 binary ranges by adding the
header-provided offset and size before comparing the result with the ROM
length. A wrapped addition could pass that check even though the binary range
was outside the ROM.

NDS::Reset later loads these binaries in 32-bit words, so non-word-aligned
sizes could also make the final load extend beyond an accepted image. The
special ARM9 secure-area path similarly expects a complete 0x800-byte region.

Validate ranges by subtraction after checking the offset, require word-aligned
binary sizes, and reject incomplete secure areas before the load paths run.

DS ROM validation added attacker-controlled offsets and lengths before
checking the result against the ROM size. Wrapped additions passed the
validation and later reached raw ROM loads. Non-word-aligned binary
lengths also let the word-at-a-time loader read past the image.

Validate each range by subtraction, require word-aligned binary lengths,
and require the complete secure area when its special load path applies.
@acts-1631
acts-1631 force-pushed the fix/ds-rom-range-validation branch from 64a256a to f15cc60 Compare July 29, 2026 18:19
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