| 1 |
From 9468e96cc40f6c18e62caf9a4b4a0a700fa7f24a Mon Sep 17 00:00:00 2001 |
| 2 |
From: Alexis Cruz-Ayala <[email protected]> |
| 3 |
Date: Fri, 17 Jul 2026 09:55:43 -0400 |
| 4 |
Subject: [PATCH] [Security] Added checks to MakeFromBuffer for Cluster size |
| 5 |
|
| 6 |
If a renderer is compromised, an OOB cluster index can be provided, which would then lead to an OOB memory read if it underflows / overflows. |
| 7 |
|
| 8 |
The solution is to check each glyph within the clusters array (buf->clusters) when deserializing such taht all cluster indices are not greater than textsize. Otherwise return nullptr. |
| 9 |
|
| 10 |
Bug: https://issues.chromium.org/issues/524864599 |
| 11 |
Change-Id: Ib30a36a42ff4509533297eabd4eadfd6168f349a |
| 12 |
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/1295057 |
| 13 |
Reviewed-by: Florin Malita <[email protected]> |
| 14 |
Commit-Queue: Alexis Cruz-Ayala <[email protected]> |
| 15 |
--- |
| 16 |
src/core/SkTextBlob.cpp | 6 ++++++ |
| 17 |
1 file changed, 6 insertions(+) |
| 18 |
|
| 19 |
diff --git a/src/core/SkTextBlob.cpp b/src/core/SkTextBlob.cpp |
| 20 |
index 6695a39040..c95badb65e 100644 |
| 21 |
--- a/src/core/SkTextBlob.cpp |
| 22 |
+++ b/src/core/SkTextBlob.cpp |
| 23 |
@@ -778,6 +778,12 @@ sk_sp<SkTextBlob> SkTextBlobPriv::MakeFromBuffer(SkReadBuffer& reader) { |
| 24 |
!reader.readByteArray(buf->utf8text, textSize)) { |
| 25 |
return nullptr; |
| 26 |
} |
| 27 |
+ |
| 28 |
+ for (int i = 0; i < glyphCount; ++i) { |
| 29 |
+ if (buf->clusters[i] >= static_cast<uint32_t>(textSize)) { |
| 30 |
+ return nullptr; |
| 31 |
+ } |
| 32 |
+ } |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
-- |
| 37 |
2.43.0 |
| 38 |
|