Fix client crash when reading deeply nested Lua tables#5051
Open
HeresHavi wants to merge 1 commit into
Open
Conversation
Limit recursive Lua table argument reads and safely reject excessive nesting before it can exhaust the Lua or native stack.
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.
Summary
Added a 64-level nesting limit to the client and server Lua table readers.
Failed reads now stop safely, clean up partially copied arguments, and return a normal Lua error instead of continuing with invalid stack data.
Motivation
toJSONcopies Lua tables into native arguments before serializing them. A deeply nested but valid table could exceed the Lua stack limit, but the failed stack check was ignored. The nextlua_pushnilcall then accessed invalid memory and crashed the client.For example, a client resource might build or receive a deeply nested configuration table and pass it to
toJSON. If the table contains enough nested levels, the resource could crash the player's client instead of receiving a normal error.Crash Stack
Test plan
Runtime
toJSONcaused an access violation inlua_pushnil.nilin 0 ms, and the client stayed open.nil, and the client stayed open.Builds and Tests
Debug | Win32: Full build passed.Debug | x64: Full build passed.clang-format.Checklist