Difference between revisions of "Same Origin Policy"

From MgmtWiki
Jump to: navigation, search
m (Meme)
(Context)
Line 5: Line 5:
  
 
# Threats Mitigated by the Same-Origin Policy
 
# Threats Mitigated by the Same-Origin Policy
 
+
## Cross-Site Scripting (XSS) Data Theft**
### 1. **Cross-Site Scripting (XSS) Data Theft**
+
### Threat**: Malicious scripts injected into a trusted site could access sensitive data (cookies, localStorage, session info).
- **Threat**: Malicious scripts injected into a trusted site could access sensitive data (cookies, localStorage, session info).
+
### SOP Defense**: Prevents scripts from reading data from other origins, even if embedded.
- **SOP Defense**: Prevents scripts from reading data from other origins, even if embedded.
+
## Cross-Site Request Forgery (CSRF)**
 
+
### Threat**: An attacker tricks a user’s browser into sending authenticated requests to another site.
### 2. **Cross-Site Request Forgery (CSRF)**
+
### SOP Defense**: Restricts cross-origin access to response data, making CSRF harder to exploit without additional vectors.
- **Threat**: An attacker tricks a user’s browser into sending authenticated requests to another site.
+
## Session Hijacking via Embedded Requests**
- **SOP Defense**: Restricts cross-origin access to response data, making CSRF harder to exploit without additional vectors.
+
### Threat**: A malicious site embeds content from another origin and tries to read session-specific responses.
 
+
### SOP Defense**: Blocks JavaScript from accessing embedded content (e.g., iframes, images) from other origins.
### 3. **Session Hijacking via Embedded Requests**
+
## Credential Leakage**
- **Threat**: A malicious site embeds content from another origin and tries to read session-specific responses.
+
### Threat**: Unauthorized access to cookies, tokens, or headers tied to another origin.
- **SOP Defense**: Blocks JavaScript from accessing embedded content (e.g., iframes, images) from other origins.
+
### SOP Defense**: Ensures that only scripts from the same origin can access these credentials.
 
+
## Unauthorized DOM Access**
### 4. **Credential Leakage**
+
### Threat**: Scripts from one origin manipulate or inspect the DOM of another origin (e.g., popup windows, iframes).
- **Threat**: Unauthorized access to cookies, tokens, or headers tied to another origin.
+
### SOP Defense**: Prevents cross-origin DOM access, preserving UI integrity and user privacy.
- **SOP Defense**: Ensures that only scripts from the same origin can access these credentials.
 
 
 
### 5. **Unauthorized DOM Access**
 
- **Threat**: Scripts from one origin manipulate or inspect the DOM of another origin (e.g., popup windows, iframes).
 
- **SOP Defense**: Prevents cross-origin DOM access, preserving UI integrity and user privacy.
 
 
 
---
 
 
 
 
# How SOP Works
 
# How SOP Works
 
- Defines “origin” as the **scheme (protocol), host (domain), and port**.   
 
- Defines “origin” as the **scheme (protocol), host (domain), and port**.   

Revision as of 11:09, 21 November 2025

Meme

The Same Origin Policy (SOP) addresses key web security threats by preventing scripts from one origin from accessing data or resources from another origin. It protects against cross-site attacks like XSS, CSRF, and data theft.

Context

  1. Threats Mitigated by the Same-Origin Policy
    1. Cross-Site Scripting (XSS) Data Theft**
      1. Threat**: Malicious scripts injected into a trusted site could access sensitive data (cookies, localStorage, session info).
      2. SOP Defense**: Prevents scripts from reading data from other origins, even if embedded.
    2. Cross-Site Request Forgery (CSRF)**
      1. Threat**: An attacker tricks a user’s browser into sending authenticated requests to another site.
      2. SOP Defense**: Restricts cross-origin access to response data, making CSRF harder to exploit without additional vectors.
    3. Session Hijacking via Embedded Requests**
      1. Threat**: A malicious site embeds content from another origin and tries to read session-specific responses.
      2. SOP Defense**: Blocks JavaScript from accessing embedded content (e.g., iframes, images) from other origins.
    4. Credential Leakage**
      1. Threat**: Unauthorized access to cookies, tokens, or headers tied to another origin.
      2. SOP Defense**: Ensures that only scripts from the same origin can access these credentials.
    5. Unauthorized DOM Access**
      1. Threat**: Scripts from one origin manipulate or inspect the DOM of another origin (e.g., popup windows, iframes).
      2. SOP Defense**: Prevents cross-origin DOM access, preserving UI integrity and user privacy.
  2. How SOP Works

- Defines “origin” as the **scheme (protocol), host (domain), and port**. - Two pages are same-origin only if all three match. - SOP restricts:

 - JavaScript access to cross-origin content.
 - Reading response data from cross-origin requests.
 - DOM manipulation across origins.

Solution

The Same-Origin Policy is a **foundational browser security mechanism** that blocks malicious cross-origin interactions. It protects users from **data theft, session hijacking, and unauthorized access**, making it essential for safe web browsing.

References