You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Kevin Reid edited this page Apr 16, 2015
·
1 revision
(legacy summary: watch and unwatch intercept gets and sets to object properties)
(legacy labels: Attack-Vector)
Object.watch allows stealing and poisoning of otherwise restricted data
Effect
If static or runtime checks prevent access to certain properties, then on Firefox, malicious code can still access those properties by using Object.watch.
// Untrusted code need never access private directly to observe and
// modify private fields of a mutable object
function untrusted(o) {
o.watch(
'private_',
function (obj, oldval, newval) {
alert('untrusted got oldval ' + oldval + ' and newval ' + newval);
return 'poisoned'; // substitute a bogus value
});
}
// Trusted code
var o = { private_: 'old' };
untrusted(o);
o.private_ = 'new';
alert('private is now ' + o.private_);