SOP(Same Origin Policy): Security Protocol

SOP or Same Origin Policy is restrictive policy that prevent loading of document and malicious script from one origin to obtain access to sensitive data on another web page through that page's Data Object Model.

(Data Object Model is Application Programming Interface for valid HTML and XML documents and defines the logical structure of documents)

Lets take an example to get better understanding of SOP , You open your FACEBOOK account in a tab and then you open another web page in different tab which has some JavaScript code that attempts to access information from your FACEBOOK page, that the point where Same Origin Policy kicks in, as soon attempt is made to get access from some other domain then this policy prevent interaction.

Origin of a webpage is based on hostname, protocol and port number . The path of the page doesn't matter as long as these three things are satisfied. Data stored in localstorage is also governed by SOP.

Let take an example exhibiting different SOP result based on above mentioned things when compared with origin :

http://xyz/abc/cc.html

 URL
 RESULT
 EXPLANATION
 http://xyz/pqr/cc.html
 PASS
 Path not matter
 http://www.xyz/abc/cc.html
 FAIL
 Different Domain
 http://xyz:8081/pqr/cc.htm
 FAIL
 Different Port
 ftp://xyz/pqr/cc.html
 FAIL
 Different Protocol


Comments

Popular posts from this blog

SQL injection