Fix stack buffer overflow in ADMesh stl_read (unbounded solid name) - #233
Open
MAVProxyUser wants to merge 1 commit into
Open
Fix stack buffer overflow in ADMesh stl_read (unbounded solid name)#233MAVProxyUser wants to merge 1 commit into
MAVProxyUser wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Fix stack buffer overflow in the ADMesh ASCII-STL loader (
stl_read)Summary
stl_read()insrc/admesh/stlinit.cppcopies the ASCII-STLsolidname into a fixed 256-byte stack buffer (solid_content[256]) with anfscanfscanset that has no field width, so asolidname longer than 255 bytes overruns the buffer and the adjacent saved stack state, including the saved return address. Reachable simply by opening a.stlfile.Why QIDI is affected
QIDI forked BambuStudio directly, so it inherited the ADMesh loader (
src/admesh/stlinit.cpp) and with it the unboundedsolid-namefscanf. The defect is present at HEAD on the default branch.Impact
arm64slice is plainarm64(notarm64e), so the saved return address is a raw, directly-usable code pointer..stla user received from a third party (marketplace, shared project, print farm).Vulnerable code
Proof — return address in control
Generate a cyclic (De Bruijn)
solidname, open the file, and read the crash report's own backtrace; the saved return-address slot (frame #1) contains the pattern bytes, decoding to solid-name offset 368. A plain 20000×'A'name puts0x414141414141in the same slot. (Full reproducer and analysis: see the companion BambuStudio and OrcaSlicer reports linked below.)Suggested fix (applied in this PR)
Bound every conversion with an explicit field width matching the destination:
%255[^\n]keeps the existing behavior (the name is still read) while making overflow impossible. As general hardening, every%s/%[scanset targeting a fixed buffer in this file should carry an explicit maximum field width.Companion reports
MWoverflow): Fix two stack buffer overflows in ADMesh stl_read (unbounded solid name + MW metadata parse) OrcaSlicer/OrcaSlicer#15594🤖 Generated with Claude Code