Your browser is literally downloading code from many different computers and executing it. It’s honestly amazing to me that we don’t get hacked more often.
Discussion
Firefox only recently improved their browser sandboxing. Before there was barely anything protecting you.
Btw Rust solves a lot of stuff like this.
https://www.securityweek.com/chrome-sandbox-escape-vulnerability-earns-researchers-20000/