Skip to content

Commit 30942bc

Browse files
committed
fix(material/stepper): validate animation durations
The `animationDuration` input is a potential CSS injection attack vector, because we pass the value directly along to the `animation-duration` binding. These changes mitigate the risk by validating the incoming value. (cherry picked from commit 0939437)
1 parent e8f3419 commit 30942bc

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/material/stepper/stepper.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,13 @@ export class MatStepper extends CdkStepper implements AfterViewInit, AfterConten
203203
return this._animationDuration;
204204
}
205205
set animationDuration(value: string) {
206-
this._animationDuration = /^\d+$/.test(value) ? value + 'ms' : value;
206+
if (/^[0-9]+(?:\.[0-9]+)?$/.test(value)) {
207+
this._animationDuration = value + 'ms';
208+
} else if (/^[0-9]+(?:\.[0-9]+)?(?:ms|s)$/.test(value)) {
209+
this._animationDuration = value;
210+
} else {
211+
this._animationDuration = '';
212+
}
207213
}
208214
private _animationDuration = '';
209215

0 commit comments

Comments
 (0)