Browser Sandbox
To defend against attacks, a developer needs to mitigate vulnerabilities and add security features to an application. Luckily, on the web, the browser provides many security features. Some are available for developers to opt-in, and some are turned on by default to protect users. The idea of a "sandbox" # Figure: Browser as a sandbox Modern web browsers are built on the idea of a "sandbox". A sandbox is a security mechanism used to run an application in a restricted environment. Just like the physical sandbox at a playground where kids can create anything they want within the boundary without making a mess elsewhere, application code has the freedom to execute within a restricted environment. For example, JavaScript can add and modify elements on the page but might be restricted from accessing an external JSON file. This is because of a sandbox feature called same-origin