This question is about the property disguiseToken
itself, not about the error directly.
disguiseToken
does not show up in the codebase and a google search does not bring up anything.
- What is
disguiseToken
? - What is it a property of?
- What is trying to access this property?
The error happens when calling getOwnPropertyDescriptor
.
Example stack trace :
TypeError: Cannot read property 'disguiseToken' of undefined
at getOwnPropertyDescriptor (eval at (:1:38695), :560:24)
at Function.Object.getOwnPropertyDescriptor (https://www.mywebsite.com/polyfills.d8680adf69e7ebd1de57.js:1:39700)
at a (https://www.mywebsite.com/main.25a9fda6ea42f4308b79.js:1:1075141)
at https://www.mywebsite.com/5.6c58d8732681a35a1f8b.js:1:1533
at Object.26NW (https://www.mywebsite.com/5.6c58d8732681a35a1f8b.js:1:1805)
at i (https://www.mywebsite.com/runtime.8928e149b3f1200cf1ca.js:1:507)
at Module.L6id (https://www.mywebsite.com/5.6c58d8732681a35a1f8b.js:1:62181)
at i (https://www.mywebsite.com/runtime.8928e149b3f1200cf1ca.js:1:507)
at https://www.mywebsite.com/main.25a9fda6ea42f4308b79.js:1:914848
at t.invoke (https://www.mywebsite.com/polyfills.d8680adf69e7ebd1de57.js:1:8160)
at M (https://www.mywebsite.com/polyfills.d8680adf69e7ebd1de57.js:1:14076)
at M (https://www.mywebsite.com/polyfills.d8680adf69e7ebd1de57.js:1:13634)
at https://www.mywebsite.com/polyfills.d8680adf69e7ebd1de57.js:1:14864
at t.invokeTask (https://www.mywebsite.com/polyfills.d8680adf69e7ebd1de57.js:1:8844)
at Object.onInvokeTask (https://www.mywebsite.com/main.25a9fda6ea42f4308b79.js:1:467756)
at t.invokeTask (https://www.mywebsite.com/polyfills.d8680adf69e7ebd1de57.js:1:8765)
at e.runTask (https://www.mywebsite.com/polyfills.d8680adf69e7ebd1de57.js:1:4026)
at g (https://www.mywebsite.com/polyfills.d8680adf69e7ebd1de57.js:1:11111)
This error happens in multiple browsers with different engines. Over the past 3 months (today is 2020-06-13) we have seen it in :
- Chrome
- Mobile Safari
- Chrome Mobile
- Firefox
- Samsung Internet
Update (1) :
I totally understand what the error means. My question is what is a 'disguise Token'? I've never heard of that, and it's not something in my code. I searched my entire code base for the word 'disguise', and no hits, so it must be something inside of Angular. What the heck is it? I am getting this error a few dozen times a day, but I have no idea what it is. I am running Angular 7.
Looking through the source code of angular and angular.js does not give any results for disguiseToken
Update (2) :
This code results in the exact error message as seen in the error reports. This snippet was not taken from actual source code. It is included here so others can reproduce the error.
<script type="application/javascript">
try {
class Dummy extends HTMLElement {
get dummyFuncA() {
return 'dummy';
}
}
var old = Object.getOwnPropertyDescriptor;
Object.getOwnPropertyDescriptor = function(obj, property) {
var descriptor = old.call(this, obj, property);
var _disguiseToken = descriptor.disguiseToken;
return descriptor;
};
var descriptorA = Object.getOwnPropertyDescriptor(Dummy.prototype, 'dummyFuncA');
var descriptorB = Object.getOwnPropertyDescriptor(Dummy.prototype, 'dummyFuncB');
} catch (err) {
console.warn(err);
}
</script>
This snippet on it's own can be used to test if Object.getOwnPropertyDescriptor
has been overridden :
<script type="application/javascript">
try {
class Dummy extends HTMLElement {
get dummyFuncA() {
return 'dummy';
}
}
var descriptorA = Object.getOwnPropertyDescriptor(Dummy.prototype, 'dummyFuncA');
var descriptorB = Object.getOwnPropertyDescriptor(Dummy.prototype, 'dummyFuncB');
} catch (err) {
if (
err &&
err.toString &&
err.toString().indexOf('Cannot read property \'disguiseToken\' of undefined') > -1
) {
console.log('Something did override \'Object.getOwnPropertyDescriptor\'');
console.warn(err);
console.log(Object.getOwnPropertyDescriptor);
}
}
</script>
Update (3) :
We added the above but didn't learn much :/
Log for console.log(Object.getOwnPropertyDescriptor);
:
function getOwnPropertyDescriptor() { [native code] }
So that seems to be fine.
We also added logs to send all script
tag source url's or innerHTML to our bug reporting service when this error happens. This did not yield any unexpected results.
Update (4) :
We added code and logs to trap use of Proxy
. This is not something we use in our code bases and this can theoretically also be part of this issue.
A few hours later we had some hits and it does seem that something is injecting code that creates Proxy
's. This is the first direct evidence of code that isn't ours running on these pages.
Stacktrace captured when something tried to construct a Proxy
:
[redacted-url]:72:24
[redacted-url]:356:25 ObjectWithDefaultValues
[redacted-url]:404:59 parseMetaTags
[redacted-url]:453:18
[redacted-url]:465:3 global code
The first row with line 72
is where we called new Error()
. Lines 356-456
are not our code but something that was injected.
The code we used to detect Proxy
use :
<script type="text/javascript">
var proxyUses = [];
function reportProxyUse() {
if (true) { // [redacted] check if error reporting is ready
for (var i = 0; i < proxyUses.length; i++) {
console.log('target', proxyUses[i].target);
console.log('handler', proxyUses[i].handler);
// [redacted]
// error reported here
}
proxyUses = [];
} else {
setTimeout(function() {
reportProxyUse();
}, 2000);
}
}
window.Proxy = function( target, handler ) {
proxyUses.push({
'target': target,
'handler': handler,
'error': new Error() // this captures a stack trace
});
reportProxyUse();
return target;
};
</script>
We will add a MutationObserver
next to try and trap all scripts. Even those that delete themselves.
Update (5) :
Haven't analysed this bit fully yet but it seems that "Add to Reader list" in Safari does an initial render of a page and injects the Javascript that includes the Proxy
stuff.
As this is obviously only Safari the use of Proxy
and the stacktrace above does not explain disguiseToken
.