Same origin policy: what is it?

Print anything with Printful



The Same Origin Policy (SOP) is a security measure that validates scripts running on websites to prevent hackers from establishing a connection to a computer with fraudulent parameters. SOP checks the domain name, application layer protocol, and specific port numbers to allow scripts to run. However, SOP is not foolproof and should only be considered a line of defense against online threats.

Same Origin Policy (SOP) is a safeguard for some types of browser applications on the Internet. When using a computer on a large-scale network such as the Internet, the possibility of being attacked by hackers and other malicious entities increases dramatically compared to working on smaller, more isolated networks. The origin policy itself works to validate scripts running on websites, preventing hackers from establishing a connection to a computer with fraudulent parameters. Scripts are simply programs or applications that the website requires to function.

When you connect to a website, you connect through “ports” on your computer. The name is quite descriptive; ports are open or closed depending on the circumstances, only open ports are vulnerable to attack. When a website requests a connection to a specific port on your computer, it exposes your computer to some degree of risk. As long as the port remains open, other individuals and online programs can try to “crack in” to your computer through the vulnerability. Other individuals and programs may also try to impersonate the website, asking the computer to open other ports as well.

This is where the origin policy itself comes into play. Think of the origin policy itself as a kind of constant virtual query between the website requesting the open port and a computer. The website has to constantly “prove” who it is and what it claims to be by preventing others from jumping in and taking advantage of the open connection on your computer. The origin policy itself only allows scripts to run as long as they come from the intended website, satisfying the “demands” posed by SOP.

To verify this, the origin policy itself checks three things: the domain name, the application layer protocol, and the specific port numbers of the document or website running the script. The domain name is the specific name of the website. It is usually preceded by the prefix “www”. The application layer protocol is the connection method; for example, HyperText Transfer Protocol (HTTP) or File Transfer Protocol (FTP). Finally, the port number is the specific number of the port through which the connection is made. If these three things are checked, the script runs; otherwise, SOP prevents it from functioning.

Like anything involving computers, SOP is not foolproof. Certain types of hacking attacks such as domain name server remapping and proxies will allow a fraudulent site to impersonate a legitimate site. That’s why SOP should only be considered a line of defense against online threats.




Protect your devices with Threat Protection by NordVPN


Skip to content