Question about lies #149
-
Hi,
Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
These are great questions. For example,
How is still a mystery to me, but both novice and advanced object tampering techniques leak subtle differences from the object's native behavior. // This returns undefined in native engines
Object.getOwnPropertyDescriptor(navigator, 'hardwareConcurrency')
// => undefined
// Let's tamper with the value using a basic method
Object.defineProperty(navigator, 'hardwareConcurrency', { value: 2 })
// Now this returns the descriptor object
Object.getOwnPropertyDescriptor(navigator, 'hardwareConcurrency')
// => {value: 2, writable: false, enumerable: false, configurable: false}
Workers have their own scope separate from the window scope, so tampering with an object in one scope does not affect the other scope. Above, we changed Not all objects in the window are available to workers, and support varies per engine: https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope |
Beta Was this translation helpful? Give feedback.
-
Very interesting. Thanks for the reply. |
Beta Was this translation helpful? Give feedback.
-
Hi,
But instead of the 'failed undefined properties' I now get 'failed descriptor.value undefined'. What's the difference between these two lies? Thanks |
Beta Was this translation helpful? Give feedback.
-
// Native return undefined
Object.getOwnPropertyDescriptor(Navigator.prototype, 'hardwareConcurrency').value
// tamper
Object.defineProperty(Object.getPrototypeOf(navigator), 'hardwareConcurrency', { value: 2 })
// Now we get 2
Object.getOwnPropertyDescriptor(Navigator.prototype, 'hardwareConcurrency').value This will bypass both tests. Idea from: Object.defineProperty(
Object.getPrototypeOf(navigator),
'hardwareConcurrency', {
get: (function hardwareConcurrency() { return 2 }).bind(null)
}
) But, then that creates a new set of leaks. For example: // this should return an error and not "Number"
Navigator.prototype.hardwareConcurrency.constructor.name There's a few interesting articles highlighting some of these leaks and potential solutions, but I'm pretty sure the only way to 100% bypass leaks is to change functions at engine level. |
Beta Was this translation helpful? Give feedback.
These are great questions.
For example,
navigator.hardwareConcurrency
:How is still a mystery to me, but both novice and advanced object tampering techniques leak subtle differences from the object's native behavior.