Repository navigation
compile.c: reject negative object index in the IBF loader (pinned_list_store / pinned_list_fetch) - #17452
Merged
Conversation
Gengyskan
force-pushed
the
ibf-pinned-list-negative-index
branch
from
June 23, 2026 17:45
dd8d360 to
fe48d5d
Compare
pinned_list_store and pinned_list_fetch validated only the upper bound (offset >= ptr->size) on a signed long index, so a malformed or truncated IBF blob with a negative object index caused an out-of-bounds write/read through ptr->buffer[negative] instead of failing cleanly. Add the missing lower-bound check, raising the same IndexError already used for the upper bound.
Gengyskan
force-pushed
the
ibf-pinned-list-negative-index
branch
from
June 23, 2026 18:25
fe48d5d to
5506c54
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
compile.c: reject negative object index in the IBF loader (pinned_list_store / pinned_list_fetch)
pinned_list_storeandpinned_list_fetchincompile.cvalidate only the upper boundof the object index (a signed
long):They accept negative offsets, so a malformed or truncated IBF blob whose object index
(e.g. the
TS_CDHASHoperand inibf_load_code) is negative causes an out-of-boundswrite (
pinned_list_store) or read (pinned_list_fetch) throughptr->buffer[negative]instead of failing cleanly.
This is not a security boundary (
load_from_binaryis documented as requiring trustedinput, per https://hackerone.com/reports/3816955), but in practice the loader is reached by
caching layers (e.g. Bootsnap) on possibly-corrupted on-disk caches, so a clean exception is
much friendlier than an OOB access when debugging a corrupted cache, and is consistent with
the existing upper-bound check.
The fix adds a lower-bound check to both functions, turning the OOB access into the same
IndexErroralready raised for the upper bound:Verification:
test/ruby/test_iseq.rbpasses with the change, and a crafted IBF blob with anegative object index now raises
IndexErrorinstead of performing a silent out-of-boundswrite.
(I initially included a regression test using a fixed crafted blob, but dropped it: IBF
binaries are platform-specific (endianness / word size), so the blob was rejected as
"broken binary format" on big-endian / 32-bit CI before reaching the code path. Happy to add
a regression test that constructs the malformed input at test time if you'd like one.)