You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+10-4Lines changed: 10 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -118,13 +118,19 @@ Change directory to dvws-node
118
118
cd dvws-node
119
119
```
120
120
Start Docker
121
+
```bash
122
+
docker-compose up --build
121
123
```
122
-
`docker-compose up`
123
-
```
124
-
This will start the dvws service with the backend MySQL database and the NoSQL database.
124
+
This will start the dvws service with the backend MySQL database and the NoSQL database. It will also start:
125
+
***OAuth Provider (Port 5000):** A mock Identity Provider for testing OAuth flows.
126
+
***Attacker Service (Port 6666):** A service to capture callbacks and tokens.
125
127
126
128
If the DVWS web service doesn't start because of delayed MongoDB or MySQL setup, then increase the value of environment variable : `WAIT_HOSTS_TIMEOUT`
127
129
130
+
## OAuth Vulnerabilities
131
+
We have added support for testing OAuth vulnerabilities (Account Takeover, CSRF, Token Leakage).
132
+
See [answers.md](answers.md) for a detailed guide on how to exploit these flaws using the provided services.
133
+
128
134
129
135
130
136
## Solutions
@@ -141,7 +147,7 @@ If the DVWS web service doesn't start because of delayed MongoDB or MySQL setup,
This document describes the OAuth vulnerabilities introduced into the `dvws-node` application and how to exploit them using the provided `oauth-provider` and `attacker-service`.
4
+
5
+
## 1. Privilege Escalation (Scope Upgrade)
6
+
7
+
**Vulnerability:**
8
+
The `dvws-node` application determines user privileges based on the OAuth **scopes** granted by the provider. Specifically, if the Access Token contains the `dvws:admin` scope, the user is granted local Administrator rights. The Vulnerability is that the Mock Provider grants *any* scope requested by the client without restriction, and the Client Application trusts the presence of this scope blindly.
9
+
10
+
**Exploitation:**
11
+
1. Click **"Login with MockOAuth"**.
12
+
2. Observe the URL in the address bar when you reach the Login Page. It looks like:
3.**The Attack:** Modify the URL to append the admin scope. Change `scope=openid` to `scope=openid dvws:admin`.
15
+
* You might need to URL encode the space (`%20`), so: `scope=openid%20dvws:admin`.
16
+
* Or modify the `return_to` parameter if you are already at the login page, but it's easier to modify the `/authorize` link before you get redirected (intercept the request or copy-paste).
17
+
* Easier method:
18
+
1. Go to `http://localhost:5000/authorize?client_id=dvws-client&redirect_uri=http://localhost:80/api/v2/auth/callback&response_type=code&scope=openid%20dvws:admin` directly.
19
+
4. Log in as **ANY** user (e.g., `attacker`). You do *not* need to be `admin`.
20
+
5. The Provider will grant the requested `dvws:admin` scope.
21
+
6. You will be redirected back to the app.
22
+
7.`dvws-node` sees the scope and logs you in as `attacker` but with **Admin Privileges**.
23
+
8. Verify by checking if you can access Admin features.
24
+
25
+
## 2. Cross-Site Request Forgery (CSRF)
26
+
27
+
**Vulnerability:**
28
+
The OAuth flow initiated by `dvws-node` (`/api/v2/login/oauth`) does not generate or validate a `state` parameter. This means an attacker can start a login flow, obtain an authorization code, and then trick a victim into consuming that code, logging the victim into the attacker's account.
29
+
30
+
**Exploitation:**
31
+
1.**Attacker Steps:**
32
+
* The attacker starts the login flow but stops before the callback is consumed (or manually gets a code from the provider).
33
+
* Since the provider is auto-approving, the attacker can just construct the callback URL manually if they know a valid code, OR they can send the victim to the Provider's authorize page with a fixed parameters.
34
+
* A more common CSRF in OAuth is "Login CSRF": Attacker logs in to *their* account, captures the authorization code, and stops. Then constructs a link: `http://localhost/api/v2/auth/callback?code=ATTACKER_CODE` (or `http://localhost:80/...`).
35
+
2.**Victim Steps:**
36
+
* Victim clicks the link.
37
+
*`dvws-node` consumes `ATTACKER_CODE`.
38
+
*`dvws-node` logs the victim in as the user associated with that code (the Attacker).
39
+
* The victim is now using the app as the Attacker. If they enter credit card info or private notes, the Attacker can see them.
40
+
41
+
## 3. Authorization Code Leakage (via Open Redirect on Provider)
42
+
43
+
**Vulnerability:**
44
+
The Mock OAuth Provider (`oauth-provider`) implements a weak validation of the `redirect_uri` parameter. It checks if the URI contains "localhost", but does not strictly check the port or path.
(Note: `localhost:6666` contains "localhost" so it passes the weak check).
52
+
2. Victim clicks the link (thinking it's a legitimate login to the provider).
53
+
3. If the victim is logged in to the provider, they are redirected. If not, they log in, and *then* are redirected.
54
+
4. The Provider redirects the victim to:
55
+
```
56
+
http://localhost:6666/callback?code=SECRET_CODE
57
+
```
58
+
4. The `attacker-service` logs the `SECRET_CODE`.
59
+
5. The attacker can now exchange this code for an access token (if they can communicate with the provider's `/token` endpoint) or impersonate the user if the client accepts the code (via the CSRF vulnerability above).
60
+
61
+
## 4. Authentication Bypass via Implicit Flow
62
+
63
+
**Vulnerability:**
64
+
The application supports a custom login flow where an access token is submitted via a POST request to `/api/v2/login/implicit`. The server verifies that the access token is valid (by checking with the provider), but fails to ensure that the token belongs to the user claimed in the request body. It trusts the `username` parameter submitted by the client as long as the token is valid.
65
+
66
+
**Exploitation:**
67
+
1. Log in to the `oauth-provider` as `attacker` (or any user).
68
+
2. Obtain a valid Access Token by manually initiating an Implicit Flow request:
0 commit comments