This closes #GHSA-5h23-36rv-pm65, fix panic on negative style index - #2367
Merged
xuri merged 2 commits intoJul 31, 2026
Merged
Conversation
The fill, border and font conditions in extractStyleCondFuncs bounded only the top of the range, so a cellXfs entry carrying fillId="-1", borderId="-1" or fontId="-1" satisfied the guard and GetStyle then indexed the fill, border or font table with a negative value. Reading cell styling from an untrusted workbook panicked with index out of range [-1]. Add the lower bound to all three, matching the check GetStyle already applies to the style index itself a few lines above. Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2367 +/- ##
=======================================
Coverage 99.62% 99.62%
=======================================
Files 32 32
Lines 26979 26979
=======================================
Hits 26877 26877
Misses 53 53
Partials 49 49
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
The
fill,borderandfontconditions inextractStyleCondFuncsbounded only the top of the range:Any negative value satisfies that, so a
cellXfsentry carryingfillId="-1",borderId="-1"orfontId="-1"passed the guard andGetStylethen indexed the fill, border or font table with-1. Reading cell styling out of an untrusted workbook panicked withindex out of range [-1].GetStylealready checks the low end for the style index itself a few lines above, so this just brings the three table lookups in line with it:Behaviour for valid workbooks is unchanged. A negative id now makes the condition false and the style keeps its default, which is what already happened for an out-of-range positive id.
The regression test writes the styles part directly so the negative attribute goes through the real XML unmarshal rather than being set on the struct, and covers all three ids. Reverting the
styles.gochange makes it panic atstyles.go:1683, and the full suite passes with the change in.Same shape as the shared string index fix in #2366, in a different file.