[3.x] Verify GLTF indices to prevent crash with corrupt files #94972
+33
−0
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.
Also verify prior to vertex optimization.
Fixes #94696
Error reporting is now:
Notes
ERR_FAIL
prior to attempting the optimization.Other similar vulnerabilities
Although the linked bug (#94696) in GLTF import is closed by this PR, it is possible that a similar crash can still occur if
add_surface_from_arrays()
is called with invalid data from elsewhere in the source code.We could in the long term decide to play it safe and verify all input indices during
add_surface_from_arrays()
(instead of during the GLTF import), however I'm not yet clear whether this could cause performance impact unnecessarily, so it may be worth waiting to see if we have any reports of similar crashes from elsewhere (I haven't seen any recently on github, and this vulnerability is not new, it has probably existed for years).It would be very simple to move the verification check to
add_surface_from_arrays()
in a follow up PR if we later decide that would be better approach.