Skip to content

Commit

Permalink
[vulnerability][acl] Fix #341 Apply ACL to all sources of Object.assi…
Browse files Browse the repository at this point in the history
…gn()
  • Loading branch information
t2ym committed Mar 3, 2020
1 parent 9558349 commit eb25f8e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
26 changes: 16 additions & 10 deletions demo/hook-callback.js
Original file line number Diff line number Diff line change
Expand Up @@ -5713,10 +5713,13 @@ else {
property = _p;
break;
case S_TARGETED:
if (_args[1][1] instanceof Object || (_args[1][1] && typeof _args[1][1] === 'object')) {
rawProperty = [];
for (let i = 1; i < _args[1].length; i++) {
let _obj = _args[1][i];
rawProperty = [];
for (let i = 1; i < _args[1].length; i++) {
let _obj = _args[1][i];
if (!_obj) {
continue;
}
if (_obj instanceof Object || typeof _obj === 'object') {
let _name = _globalObjects.get(_obj);
let _isStatic = true;
let _isObject = false;
Expand All @@ -5730,8 +5733,8 @@ else {
// TODO: Are inherited properties targeted?
rawProperty = rawProperty.concat(Object.keys(_args[1][i]));
}
property = rawProperty.map(p => _escapePlatformProperties.get(p) || p);
}
property = rawProperty.map(p => _escapePlatformProperties.get(p) || p);
break;
case S_ALL:
property = _p;
Expand Down Expand Up @@ -7223,10 +7226,13 @@ else {
property = _p;
break;
case S_TARGETED:
if (_args[1][1] instanceof Object || (_args[1][1] && typeof _args[1][1] === 'object')) {
rawProperty = [];
for (let i = 1; i < _args[1].length; i++) {
let _obj = _args[1][i];
rawProperty = [];
for (let i = 1; i < _args[1].length; i++) {
let _obj = _args[1][i];
if (!_obj) {
continue;
}
if (_obj instanceof Object || typeof _obj === 'object') {
let _name = _globalObjects.get(_obj);
let _isStatic = true;
let _isObject = false;
Expand All @@ -7240,8 +7246,8 @@ else {
// TODO: Are inherited properties targeted?
rawProperty = rawProperty.concat(Object.keys(_args[1][i]));
}
property = rawProperty.map(p => _escapePlatformProperties.get(p) || p);
}
property = rawProperty.map(p => _escapePlatformProperties.get(p) || p);
break;
case S_ALL:
property = _p;
Expand Down
4 changes: 4 additions & 0 deletions demo/normalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -3022,6 +3022,10 @@
accessor: { get: function () { return this.property2; }, set: function (value) { this.property2 = value; }, configurable: true, enumerable: true },
}).accessor = 2; // write this own accessor

chai.assert.throws(() => {
Object.assign({}, undefined, window);
}, /^Permission Denied: Cannot access window/);

/*
let NoAclGlobalObject = {
property: 1,
Expand Down

0 comments on commit eb25f8e

Please sign in to comment.