Skip to content

Commit b185b3c

Browse files
committed
fix: Make ARIA polyfill more robust
All the attributes listed in the polyfill already begin with "aria". However, to add extra protection against the possibility of XSS attacks through one of the polyfill's internal methods, this enforces "aria-" at the beginning of the snake-case attribute name, even if somehow "aria" were missing from the input JavaScript attribute name. This change is based on the outcome of an internal security review. Change-Id: Iec8a9cbd5f88fdf4b87da3e5cd058c4ffb69c3ff
1 parent 3270248 commit b185b3c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/polyfill/aria.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,13 @@ shaka.polyfill.Aria = class {
4848
* @private
4949
*/
5050
static addARIAMixinAttribute_(name) {
51-
const snakeCaseName = name.toLowerCase().replace('aria', 'aria-');
51+
const baseName = name.toLowerCase().replace(/^aria/, '');
52+
// NOTE: All the attributes listed in the method above begin with "aria".
53+
// However, to add extra protection against the possibility of XSS attacks
54+
// through this method, this enforces "aria-" at the beginning of the
55+
// snake-case name, even if somehow "aria" were missing from the input.
56+
const snakeCaseName = `aria-${baseName}`;
57+
5258
/* eslint-disable no-restricted-syntax */
5359
Object.defineProperty(Element.prototype, name, {
5460
get() {

0 commit comments

Comments
 (0)