Skip to content

Commit 1fec1be

Browse files
lillesmibrunin
authored andcommitted
[Backport] CVE-2021-21203: Use after free in Blink
Cherry-pick of commit originally reviewed on https://chromium-review.googlesource.com/c/chromium/src/+/2792423: Don't erase InterpolationTypes used by other documents A registered custom property in one document caused the entry for the same custom property (unregistered) used in another document to be deleted, which caused a use-after-free. Only store the CSSDefaultInterpolationType for unregistered custom properties and never store registered properties in the map. They may have different types in different documents when registered. Bug: 1192054 Change-Id: I1af03d0a298795db99acc9c62f0d0fff8a5e801d Commit-Queue: Rune Lillesveen <[email protected]> Reviewed-by: Robert Flack <[email protected]> Cr-Commit-Position: refs/heads/master@{#867692} Reviewed-by: Allan Sandfeld Jensen <[email protected]>
1 parent a87ec5b commit 1fec1be

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

chromium/third_party/blink/renderer/core/animation/css_interpolation_types_map.cc

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -76,28 +76,22 @@ const InterpolationTypes& CSSInterpolationTypesMap::Get(
7676
DEFINE_STATIC_LOCAL(ApplicableTypesMap, all_applicable_types_map, ());
7777
DEFINE_STATIC_LOCAL(ApplicableTypesMap, composited_applicable_types_map, ());
7878

79-
ApplicableTypesMap& applicable_types_map =
80-
allow_all_animations_ ? all_applicable_types_map
81-
: composited_applicable_types_map;
82-
83-
auto entry = applicable_types_map.find(property);
84-
bool found_entry = entry != applicable_types_map.end();
85-
8679
// Custom property interpolation types may change over time so don't trust the
87-
// applicableTypesMap without checking the registry.
80+
// applicable_types_map without checking the registry. Also since the static
81+
// map is shared between documents, the registered type may be different in
82+
// the different documents.
8883
if (registry_ && property.IsCSSCustomProperty()) {
89-
const auto* registration = GetRegistration(registry_.Get(), property);
90-
if (registration) {
91-
if (found_entry) {
92-
applicable_types_map.erase(entry);
93-
}
84+
if (const auto* registration = GetRegistration(registry_, property))
9485
return registration->GetInterpolationTypes();
95-
}
9686
}
9787

98-
if (found_entry) {
88+
ApplicableTypesMap& applicable_types_map =
89+
allow_all_animations_ ? all_applicable_types_map
90+
: composited_applicable_types_map;
91+
92+
auto entry = applicable_types_map.find(property);
93+
if (entry != applicable_types_map.end())
9994
return *entry->value;
100-
}
10195

10296
std::unique_ptr<InterpolationTypes> applicable_types =
10397
std::make_unique<InterpolationTypes>();

0 commit comments

Comments
 (0)