-
Notifications
You must be signed in to change notification settings - Fork 2k
fix: prevent proto-access bypass via Symbol.toStringTag and escape bypass via toHTML #2148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,18 +35,13 @@ export function isFunction(value) { | |
| return typeof value === 'function'; | ||
| } | ||
|
|
||
| function testTag(name) { | ||
| const tag = '[object ' + name + ']'; | ||
| return function (value) { | ||
| return value && typeof value === 'object' | ||
| ? toString.call(value) === tag | ||
| : false; | ||
| }; | ||
| } | ||
|
|
||
| export const isArray = Array.isArray; | ||
| export const isMap = testTag('Map'); | ||
| export const isSet = testTag('Set'); | ||
| export function isMap(value) { | ||
| return value instanceof Map; | ||
| } | ||
| export function isSet(value) { | ||
| return value instanceof Set; | ||
| } | ||
|
|
||
| // Older IE versions do not directly support indexOf so we must implement our own, sadly. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this needs a regression test, something like it('does not treat Symbol.toStringTag-spoofed objects as Map', function () {
expectTemplate('{{value.constructor}}')
.withInput({ value: { [Symbol.toStringTag]: 'Map', get: () => 'pwned' } })
.toCompileTo(''); // or whatever the proto-controlled path produces
});
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add one each for isMap / isSet at the unit level (spec/utils.js already has the happy-path tests) plus an end-to-end runtime.js lookup test. |
||
| export function indexOf(array, value) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given
isMapnow gates proto-access control behavior inruntime.lookupProperty, it would be good to add a security regression test that a plain object spoofing[Symbol.toStringTag] = 'Map'is not treated as a Map and cannot be used to read blocked proto properties (e.g.constructor). No existing spec appears to cover the spoofing case.