> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/cheat-sheets/authentication-sessions/oauth-oidc.md). Agents can also search and read this documentation through its [MCP server](https://hacking-notes.jord4n.pro/~gitbook/mcp).

# OAuth and OIDC Cheat Sheet: Redirects, Tokens and PKCE Testing

OAuth and OpenID Connect tests for state validation, redirect URIs, code interception, token scopes, PKCE and identity claim enforcement.

## OAuth / OIDC — Cheat Sheet

{% hint style="info" %}
**What is OAuth / OIDC?**

OAuth delegates access through tokens, while OpenID Connect adds authenticated identity claims. Security depends on binding each authorization response to the correct browser flow, client, redirect URI, issuer, and token purpose.
{% endhint %}

<details open>

<summary>Missing State Parameter (CSRF)</summary>

{% code title="No state parameter" overflow="wrap" %}

```
GET /oauth/authorize?client_id=app&redirect_uri=https://app.com/callback&response_type=code
```

{% endcode %}

{% code title="Test: can attacker set state to a fixed value?" overflow="wrap" %}

```
GET /oauth/authorize?client_id=app&redirect_uri=https://app.com/callback&response_type=code&state=ATTACKER_CONTROLLED_VALUE
```

{% endcode %}

</details>

<details open>

<summary>Open Redirect in redirect_uri</summary>

{% code title="Direct redirect bypass" overflow="wrap" %}

```
GET /oauth/authorize?client_id=app&redirect_uri=https://evil.com&response_type=code
```

{% endcode %}

{% code title="Subdomain confusion" overflow="wrap" %}

```
GET /oauth/authorize?client_id=app&redirect_uri=https://app.com.evil.com&response_type=code
```

{% endcode %}

{% code title="Path traversal in redirect\_uri" overflow="wrap" %}

```
GET /oauth/authorize?client_id=app&redirect_uri=https://app.com/callback/../../../redirect?url=https://evil.com&response_type=code
```

{% endcode %}

{% code title="CRLF injection in redirect\_uri" overflow="wrap" %}

```
GET /oauth/authorize?client_id=app&redirect_uri=https://app.com/callback%0a%0dhttps://evil.com&response_type=code
```

{% endcode %}

</details>

<details open>

<summary>Authorization Code Interception</summary>

{% code title="Auth code leaks via Referer header" overflow="wrap" %}

```
Check Referer header on callback page — code may leak in Referer to third-party scripts
```

{% endcode %}

{% code title="Auth code in server logs or analytics" overflow="wrap" %}

```
Look for auth code in server-side logs, analytics, or CDN access logs
```

{% endcode %}

{% code title="Implicit flow: token in URL fragment — visible to browser history and JS" overflow="wrap" %}

```
GET /oauth/authorize?client_id=app&redirect_uri=https://app.com/callback&response_type=token
```

{% endcode %}

</details>

<details open>

<summary>Token Scope Escalation</summary>

{% code title="Add extra scopes to token request" overflow="wrap" %}

```
POST /oauth/token
scope=admin openid profile
```

{% endcode %}

{% code title="Modify scope in authorization request URL" overflow="wrap" %}

```
GET /oauth/authorize?client_id=app&scope=admin+openid+profile&response_type=code
```

{% endcode %}

</details>

<details open>

<summary>PKCE Bypass</summary>

{% code title="PKCE bypass: server may not validate code\_verifier" overflow="wrap" %}

```
Remove code_verifier from token exchange POST body and test if server still returns token
```

{% endcode %}

{% code title="Test if plain PKCE challenge method is accepted (weaker than S256)" overflow="wrap" %}

```
POST /oauth/token with code_challenge_method=plain instead of S256
```

{% endcode %}

</details>

<details open>

<summary>JWT as Access Token Attacks</summary>

{% code title="Algorithm confusion: remove signature — server may accept unsigned token" overflow="wrap" %}

```json
{"alg":"none"}
```

{% endcode %}

{% code title="Weak HS256 secret: crack JWT offline" overflow="wrap" %}

```bash
hashcat -m 16500 jwt_token.txt rockyou.txt
```

{% endcode %}

{% code title="alg confusion attack" overflow="wrap" %}

```json
{"alg":"HS256"}
```

{% endcode %}

</details>

<details open>

<summary>Common OIDC Attacks</summary>

{% code title="ID token audience bypass: aud claim may not be validated" overflow="wrap" %}

```
Decode ID token and check if "aud" claim is validated — swap aud to another client_id
```

{% endcode %}

{% code title="Nonce replay: nonce may not be validated" overflow="wrap" %}

```
Replay ID token with old nonce value — check if server rejects replays
```

{% endcode %}

{% code title="sub claim IDOR: access another user account" overflow="wrap" %}

```
Decode ID token, swap "sub" claim to another user ID, re-sign and submit
```

{% endcode %}

</details>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/cheat-sheets/authentication-sessions/oauth-oidc.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
