Get the latest tech news

Checking if a JavaScript native function is monkey patched (2022)


Delving deep into how to determine whether a JavaScript native function has been monkey patched, and why it's not possible to determine it reliably.

For example, monitoring tools such as Bugsnag override the Fetch and XMLHttpRequest APIs to gain visibility into network connections triggered by JavaScript code. It requires storing the original function reference before running any other code in your app (to ensure it's still untouched), which sometimes you won't be able to do (e.g., if you're building a library). If you're in control of the entire web page, you can set up your code in advance by storing references of the functions you want to check when they're still "clean" and compare them later.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of javascript

javascript

Photo of monkey

monkey

Photo of native function

native function

Related news:

News photo

Show HN: Ion, a Rust/Tokio powered JavaScript runtime for embedders

News photo

I still love PHP and JavaScript (2022)

News photo

Aspects of modern HTML/CSS you may not be familiar with