font/sfnt: add bounds checks in GPOS parsing to prevent OOM#26
Open
ZephrFish wants to merge 1 commit into
Open
font/sfnt: add bounds checks in GPOS parsing to prevent OOM#26ZephrFish wants to merge 1 commit into
ZephrFish wants to merge 1 commit into
Conversation
8f0ca81 to
2a64e6d
Compare
A crafted font file can trigger a multi-gigabyte allocation when parsing GPOS PairPos tables. In parsePairPosFormat2, numClass1 and numClass2 are read as uint16 from the font and their product is passed unchecked to source.view. With both values at 65535, the product times 2 reaches ~8 GiB, OOM-killing the process. Validate the class count product against maxTableLength before allocating. Also add bounds checks in makeCachedPairPosGlyph and makeCachedPairPosClass to verify that indices derived from the font file do not exceed the parsed buffer, and add an overflow check in source.varLenView for the computed total length. Fixes golang/go#78382
2a64e6d to
a03464d
Compare
Contributor
|
This PR (HEAD: a03464d) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/image/+/759520. Important tips:
|
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.
A crafted font file can trigger a multi-gigabyte allocation when
parsing GPOS PairPos tables. In parsePairPosFormat2, numClass1 and
numClass2 are read as uint16 from the font and their product is
passed unchecked to source.view. With both values at 65535, the
product times 2 reaches ~8 GiB, OOM-killing the process.
Only the io.ReaderAt path is affected (the []byte path is bounded
by the slice length).
This was previously reported to the Go security team via
security@golang.org and has been designated for the PUBLIC track.
Changes:
allocating in parsePairPosFormat2
does not exceed buffer
indices fall within the parsed buffer before indexing
total length
Fixes golang/go#78382