Skip to content

Commit 4e9b94e

Browse files
Kevin Ellismibrunin
authored andcommitted
[Backport] CVE-2021-21188: Use after free in Blink.
Manual backport of patch originally reviewed on https://chromium-review.googlesource.com/c/chromium/src/+/2636213: Test for persistent execution context during Animatable::animate. Prior to the patch, the validity of the execution context was only checked on entry to the method; however, the execution context can be invalidated during the course of parsing keyframes or options. The parsing of options is upstream of Animatable::animate and caught by the existing check, but invalidation during keyframe parsing could fall through triggering a crash. Bug: 1161739 Change-Id: Ic0fc927d1d6ce902592bf92261fd4c506e96afac Commit-Queue: Kevin Ellis <[email protected]> Reviewed-by: Robert Flack <[email protected]> Cr-Commit-Position: refs/heads/master@{#844622} Reviewed-by: Jüri Valdmann <[email protected]>
1 parent 70fbd69 commit 4e9b94e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,21 @@ Animation* ElementAnimation::animate(
3636
if (exception_state.HadException())
3737
return nullptr;
3838

39+
// Creation of the keyframe effect parses JavaScript, which could result
40+
// in destruction of the execution context. Recheck that it is still valid.
41+
if (!element.GetExecutionContext())
42+
return nullptr;
43+
3944
Timing timing =
4045
TimingInput::Convert(options, &element.GetDocument(), exception_state);
4146
if (exception_state.HadException())
4247
return nullptr;
4348

4449
Animation* animation = animateInternal(element, effect, timing);
50+
51+
if (!animation)
52+
return nullptr;
53+
4554
if (options.IsKeyframeAnimationOptions())
4655
animation->setId(options.GetAsKeyframeAnimationOptions().id());
4756
return animation;
@@ -56,6 +65,10 @@ Animation* ElementAnimation::animate(ScriptState* script_state,
5665
script_state, exception_state);
5766
if (exception_state.HadException())
5867
return nullptr;
68+
69+
if (!element.GetExecutionContext())
70+
return nullptr;
71+
5972
return animateInternal(element, effect, Timing());
6073
}
6174

0 commit comments

Comments
 (0)