Skip to content

fix vtable offset truncation in .NET verifier - #9312

Open
Usamak06 wants to merge 1 commit into
google:masterfrom
Usamak06:dotnet-verifier-vtable-offset
Open

Usamak06 wants to merge 1 commit into
google:masterfrom
Usamak06:dotnet-verifier-vtable-offset

Conversation

@Usamak06

@Usamak06 Usamak06 commented Oct 8, 2026

Copy link
Copy Markdown

Verifier.GetVRelOffset truncates a table's absolute vtable position to 16 bits with Convert.ToInt16, so for any table past offset 32767 the conversion throws, the catch swallows it, and every field of that table is treated as absent. The runtime Table.__offset reads the same position as an int, so a well-formed buffer whose tables cross the 32KB mark is wrongly rejected, and a malformed field in such a table is skipped instead of verified. Store the vtable position in an int to match the accessor; the added regression test verifies the same valid Monster below and above the boundary.

Verifier.GetVRelOffset narrowed a table's absolute vtable position to 16 bits via Convert.ToInt16. For any table located past offset 32767 (common once a buffer exceeds ~32KB) the conversion throws, the surrounding try/catch swallows it, and GetVRelOffset returns 0 so every field of that table is treated as absent. The runtime accessor Table.__offset reads the same position as an int, so the verifier and the reader disagree: a well-formed buffer whose tables cross the 32KB mark is wrongly rejected, and a malformed field in such a table is skipped instead of verified. Store the vtable position in an int to match Table.__offset. Tested with the existing FlatBuffers.Test suite plus a new regression (TestVerifierVtableBeyond32k) that verifies an identical valid Monster both below and above the 32KB boundary; it fails before the change and passes after.
@Usamak06
Usamak06 requested a review from dbaileychess as a code owner October 8, 2026 16:52
@github-actions github-actions Bot added the c# label Oct 8, 2026
@stefan301

Copy link
Copy Markdown
Contributor

@dbaileychess

Could you please look at these PRs that want to fix the same Bug in GetVRelOffset in FlatBufferVerify.cs:

[#8975]
[#9242]
[#9312]

Thanks

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants