Skip to content

Commit ce21209

Browse files
authored
Merge pull request #2163 from HackTricks-wiki/research_update_src_pentesting-web_cors-bypass_20260423_135850
Research Update Enhanced src/pentesting-web/cors-bypass.md
2 parents ee65139 + 195ef64 commit ce21209

1 file changed

Lines changed: 37 additions & 5 deletions

File tree

src/pentesting-web/cors-bypass.md

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,25 +106,39 @@ Note that usually (depending on the content-type and headers set) in a **GET/POS
106106

107107
### **Local Network Requests Pre-flight request**
108108

109-
1. **`Access-Control-Request-Local-Network`**: This header is included in the client's request to signify that the inquiry is aimed at a local network resource. It serves as a marker to inform the server that the request originates from within the local network.
110-
2. **`Access-Control-Allow-Local-Network`**: In response, servers utilize this header to communicate that the requested resource is permitted to be shared with entities outside of the local network. It acts as a green light for sharing resources across different network boundaries, ensuring controlled access while maintaining security protocols.
109+
Modern browsers and the current **Private Network Access (PNA)** draft use the headers **`Access-Control-Request-Private-Network: true`** in the preflight and **`Access-Control-Allow-Private-Network: true`** in the response. Older articles and PoCs may still refer to `Local-Network` header names, but for current testing you should expect the `Private-Network` variants.
111110

112-
A **valid response allowing the local network request** needs to have also in the response the header `Access-Controls-Allow-Local_network: true` :
111+
A **valid response allowing the local network request** needs to also include `Access-Control-Allow-Private-Network: true`:
113112

114113
```
115114
HTTP/1.1 200 OK
116115
...
117116
Access-Control-Allow-Origin: https://example.com
118117
Access-Control-Allow-Methods: GET
119118
Access-Control-Allow-Credentials: true
120-
Access-Control-Allow-Local-Network: true
119+
Access-Control-Allow-Private-Network: true
121120
Content-Length: 0
122121
...
123122
```
124123

124+
And the preflight request will look similar to:
125+
126+
```http
127+
OPTIONS / HTTP/1.1
128+
Host: router.local
129+
Origin: https://example.com
130+
Access-Control-Request-Method: GET
131+
Access-Control-Request-Private-Network: true
132+
```
133+
134+
> [!NOTE]
135+
> Chrome's PNA rollout changed several times during 2024. As of **October 9, 2024**, Chrome documented that **PNA preflights were on hold** because of compatibility problems, while secure-context restrictions remained in place. Therefore, keep testing both the **spec-compliant preflight flow** and the older **"works in practice because enforcement is incomplete"** behavior.
136+
125137
> [!WARNING]
126138
> Note that the linux **0.0.0.0** IP works to **bypass** these requirements to access localhost as that IP address is not considered "local".
127139
>
140+
> Chrome also documented that **`0.0.0.0/8`** is now treated as part of Private Network Access, so this trick is browser/version-dependent and should be re-tested instead of assumed.
141+
>
128142
> It's also possible to **bypass the Local Network requirements** if you use the **public IP address of a local endpoint** (like the public IP of the router). Because in several occasions, even if the **public IP** is being accessed, if it's **from the local network**, access will be granted.
129143
130144
### Wildcards
@@ -258,6 +272,22 @@ Access-Control-Allow-Origin: https://target.application}.arbitrary.com
258272
Access-Control-Allow-Credentials: true
259273
```
260274

275+
Recent updates to PortSwigger's cheat sheet added more **Safari-oriented domain splitting** payloads that are worth fuzzing when the target validates the `Origin` header using regexes or home-grown URL parsers:
276+
277+
```text
278+
https://example.com.{.attacker.com/
279+
https://example.com.}.attacker.com/
280+
https://example.com.`.attacker.com/
281+
```
282+
283+
These are useful when the backend only checks whether the supplied origin *starts with* or *contains* the trusted hostname, while the browser still treats the attacker-controlled suffix as the effective origin boundary.
284+
285+
Also remember that modern origin fuzzing should not stop at hostname suffixes. The current PortSwigger cheat sheet includes payload families for:
286+
287+
- **Domain allow-list bypasses**: attacker-controlled domains that still satisfy naive prefix/suffix/substring checks.
288+
- **Fake-relative absolute URLs**: browser-valid absolute URLs that application code may parse as relative.
289+
- **Loopback/IP normalizations**: alternative IPv4/IPv6 forms useful when CORS logic tries to block `localhost`, `127.0.0.1`, or cloud metadata endpoints by string comparison.
290+
261291
### **Other funny URL tricks**
262292

263293

@@ -455,6 +485,7 @@ DoH simply tunnels the classic RFC1035 DNS wire format inside HTTPS (usually a P
455485
**Fuzz possible misconfigurations in CORS policies**
456486

457487
- [https://portswigger.net/bappstore/420a28400bad4c9d85052f8d66d3bbd8](https://portswigger.net/bappstore/420a28400bad4c9d85052f8d66d3bbd8)
488+
- [https://portswigger.net/bappstore/c257bcb0b6254a578535edb2dcee87d0](https://portswigger.net/bappstore/c257bcb0b6254a578535edb2dcee87d0)
458489
- [https://github.com/chenjj/CORScanner](https://github.com/chenjj/CORScanner)
459490
- [https://github.com/lc/theftfuzzer](https://github.com/lc/theftfuzzer)
460491
- [https://github.com/s0md3v/Corsy](https://github.com/s0md3v/Corsy)
@@ -473,8 +504,9 @@ DoH simply tunnels the classic RFC1035 DNS wire format inside HTTPS (usually a P
473504
- [https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/CORS%20Misconfiguration](https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/CORS%20Misconfiguration)
474505
- [https://medium.com/entersoftsecurity/every-bug-bounty-hunter-should-know-the-evil-smile-of-the-jsonp-over-the-browsers-same-origin-438af3a0ac3b](https://medium.com/entersoftsecurity/every-bug-bounty-hunter-should-know-the-evil-smile-of-the-jsonp-over-the-browsers-same-origin-438af3a0ac3b)
475506
- [NCC Group - Impact of DNS over HTTPS (DoH) on DNS Rebinding Attacks](https://www.nccgroup.com/research-blog/impact-of-dns-over-https-doh-on-dns-rebinding-attacks/)
507+
- [https://portswigger.net/research/new-crazy-payloads-in-the-url-validation-bypass-cheat-sheet](https://portswigger.net/research/new-crazy-payloads-in-the-url-validation-bypass-cheat-sheet)
508+
- [https://developer.chrome.com/blog/pna-on-hold](https://developer.chrome.com/blog/pna-on-hold)
476509

477510

478511
{{#include ../banners/hacktricks-training.md}}
479512

480-

0 commit comments

Comments
 (0)