Repository navigation
fix(io): harden the binary FBX parser against hostile files - #7
Merged
Merged
Conversation
Every length and offset read from an FBX file is now validated before use. Previously a crafted file could: - overflow the stack via unbounded record nesting (uncatchable; kills the process) - send the parser backwards with an end offset before the record start - force huge allocations from a declared array length (incl. zlib bombs) - crash with ArgumentOutOfRange/IndexOutOfRange instead of a clean error Now: nesting is capped at 64, record offsets must move forward and stay in the file, arrays are capped at 512 MB and must be reachable at DEFLATE's max ratio, inflated size is verified, and any malformed input throws InvalidDataException. Adds hostile-input tests for each case. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S5ts9QgA8bk8NBJJuMyTKr
…iles A GLB chunk with a negative length left the read position unchanged and looped forever. Accessor counts from the JSON sized arrays before checking the binary chunk could back them. Chunk lengths and accessor extents are now validated first. Adds hostile-input tests (the hang case times out on the old reader). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S5ts9QgA8bk8NBJJuMyTKr
Owner
Author
|
Added a second fix to this PR: the glTF (.glb) reader. A chunk with a negative length left the read position unchanged and looped forever (the new test times out on the old reader), and accessor counts sized arrays before checking the binary chunk could back them. Both are now validated first; see |
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.
What and why
The binary FBX parser trusted the lengths and offsets inside the file. A crafted
.fbxcould hang the parser, exhaust memory, or overflow the stack, and a stack overflow kills the host process outright in .NET. These are denial-of-service bugs for anyone who embeds the library and opens untrusted files.InvalidDataException, depth capped at 64int.MaxValueArgumentOutOfRangeExceptionInvalidDataExceptionHow it was tested
FbxHostileInputTestsbuild each hostile file by hand. Against the old parser, the 5 runnable cases fail; the nesting case is not run against the old code because it would kill the test host.Checklist
dotnet testpasses locally🤖 Generated with Claude Code
https://claude.ai/code/session_01S5ts9QgA8bk8NBJJuMyTKr