Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
A direct command skips the review prompt. Inspect the source before running it.
The OAuth Authorization Server is responsible for authenticating users, obtaining consent, and issuing access tokens. Vulnerabilities in the authorization server can compromise the entire OAuth ecosystem, leading to unauthorized access to protected resources across all client applications. This test focuses on identifying weaknesses specific to the authorization server implementation.
#!/bin/bash# Test authorization endpoint weaknesses
AUTH_URL="https://auth.target.com/oauth/authorize"
CLIENT_ID="test_client"# Test response_type variations
response_types=("code""token""id_token""code token""code id_token""token id_token""code token id_token")
for rt in"${response_types[@]}"; do
response=$(curl -s -I "$AUTH_URL?client_id=$CLIENT_ID&response_type=$rt&redirect_uri=https://client.com/callback&scope=openid" 2>/dev/null | head -20)
echo"response_type=$rt"echo"$response" | grep -iE "location|error"echo"---"done# Test scope handling
scopes=("openid""profile""email""admin""write""delete""all""*")
for scope in"${scopes[@]}"; do
response=$(curl -s "$AUTH_URL?client_id=$CLIENT_ID&response_type=code&redirect_uri=https://client.com/callback&scope=$scope" 2>/dev/null)
ifecho"$response" | grep -qi "invalid_scope"; thenecho"Scope '$scope': Rejected"elseecho"Scope '$scope': Potentially accepted"fidone
Step 3: Test Token Endpoint Security
#!/bin/bash# Test token endpoint weaknesses
TOKEN_URL="https://auth.target.com/oauth/token"# Test without client authentication
curl -s -X POST "$TOKEN_URL" \
-d "grant_type=authorization_code&code=AUTH_CODE&redirect_uri=https://client.com/callback"# Test with various client auth methods# client_secret_post
curl -s -X POST "$TOKEN_URL" \
-d "grant_type=authorization_code&code=AUTH_CODE&redirect_uri=https://client.com/callback&client_id=CLIENT&client_secret=SECRET"# client_secret_basic
curl -s -X POST "$TOKEN_URL" \
-u "CLIENT:SECRET" \
-d "grant_type=authorization_code&code=AUTH_CODE&redirect_uri=https://client.com/callback"# Test grant types
grant_types=("authorization_code""client_credentials""password""refresh_token""urn:ietf:params:oauth:grant-type:jwt-bearer")
for gt in"${grant_types[@]}"; do
response=$(curl -s -X POST "$TOKEN_URL" \
-d "grant_type=$gt&client_id=CLIENT&client_secret=SECRET")
echo"Grant type: $gt"echo"$response" | head -c 200
echo -e "\n---"done
Step 4: Test Token Generation Strength
#!/usr/bin/env python3import requests
import time
import hashlib
from collections import Counter
classTokenAnalyzer:
def__init__(self, token_url, client_id, client_secret):
self.token_url = token_url
self.client_id = client_id
self.client_secret = client_secret
self.tokens = []
defcollect_tokens(self, count=10):
"""Collect multiple tokens for analysis"""print(f"[*] Collecting {count} tokens...")
for i inrange(count):
try:
response = requests.post(
self.token_url,
data={
"grant_type": "client_credentials",
"client_id": self.client_id,
"client_secret": self.client_secret,
"scope": "openid"
}
)
if response.status_code == 200:
token = response.json().get("access_token")
if token:
self.tokens.append({
"token": token,
"timestamp": time.time(),
"length": len(token)
})
time.sleep(0.5) # Avoid rate limitingexcept Exception as e:
print(f"[ERROR] {e}")
print(f"[*] Collected {len(self.tokens)} tokens")
returnself.tokens
defanalyze_entropy(self):
"""Analyze token entropy"""print("\n[*] Analyzing token entropy...")
for token_data inself.tokens:
token = token_data["token"]
# Character frequency
freq = Counter(token)
unique_chars = len(freq)
total_chars = len(token)
# Simple entropy approximation
entropy = sum((count/total_chars) * (-1 * (count/total_chars))
for count in freq.values()) * -1print(f"Token length: {total_chars}, Unique chars: {unique_chars}")
defcheck_predictability(self):
"""Check for predictable patterns"""print("\n[*] Checking for predictable patterns...")
iflen(self.tokens) < 2:
print("[!] Need more tokens for pattern analysis")
return# Check if tokens are sequential
token_hashes = [hashlib.md5(t["token"].encode()).hexdigest()
for t inself.tokens]
# Check for common prefixes
common_prefix = ""
tokens_list = [t["token"] for t inself.tokens]
for i, char inenumerate(tokens_list[0]):
ifall(t[i] == char for t in tokens_list iflen(t) > i):
common_prefix += char
else:
breakiflen(common_prefix) > 10:
print(f"[WARN] Common prefix found: {common_prefix}")
# Check for timestamp-based patternsfor token_data inself.tokens:
token = token_data["token"]
ts = str(int(token_data["timestamp"]))
if ts[:6] in token:
print(f"[VULN] Timestamp may be embedded in token")
defanalyze_jwt_tokens(self):
"""Analyze if tokens are JWTs"""print("\n[*] Analyzing JWT tokens...")
import base64
import json
for token_data inself.tokens:
token = token_data["token"]
parts = token.split(".")
iflen(parts) == 3:
try:
header = json.loads(
base64.urlsafe_b64decode(parts[0] + "==")
)
payload = json.loads(
base64.urlsafe_b64decode(parts[1] + "==")
)
print(f"\nJWT detected:")
print(f" Algorithm: {header.get('alg')}")
print(f" Type: {header.get('typ')}")
# Check for weak algorithmsif header.get('alg') in ['none', 'HS256']:
print(f" [WARN] Potentially weak algorithm: {header.get('alg')}")
# Check for sensitive data
sensitive_keys = ['password', 'secret', 'ssn', 'credit_card']
for key in payload:
ifany(s in key.lower() for s in sensitive_keys):
print(f" [VULN] Sensitive data in payload: {key}")
except:
pass# Usage
analyzer = TokenAnalyzer(
"https://auth.target.com/oauth/token",
"client_id",
"client_secret"
)
analyzer.collect_tokens(10)
analyzer.analyze_entropy()
analyzer.check_predictability()
analyzer.analyze_jwt_tokens()
Step 5: Test Client Authentication Weaknesses
#!/bin/bash# Test client authentication security
TOKEN_URL="https://auth.target.com/oauth/token"
CLIENT_ID="known_client"# Test common/default client secrets
secrets=("secret""password""123456""client_secret""$CLIENT_ID""")
for secret in"${secrets[@]}"; do
response=$(curl -s -X POST "$TOKEN_URL" \
-d "grant_type=client_credentials&client_id=$CLIENT_ID&client_secret=$secret")
ifecho"$response" | grep -q "access_token"; thenecho"[VULN] Weak client secret found: '$secret'"fidone# Test client_id enumerationfor i in {1..100}; do
client="client_$i"
response=$(curl -s -X POST "$TOKEN_URL" \
-d "grant_type=client_credentials&client_id=$client&client_secret=test")
error=$(echo"$response" | jq -r '.error_description // .error')
if [ "$error" != "invalid_client" ]; thenecho"Client '$client': $error"fidone
Step 6: Test Token Introspection/Revocation
# Token introspection endpoint
INTROSPECT_URL="https://auth.target.com/oauth/introspect"# Test introspection without auth
curl -s -X POST "$INTROSPECT_URL" \
-d "token=SOME_TOKEN"# Test with client credentials
curl -s -X POST "$INTROSPECT_URL" \
-u "CLIENT:SECRET" \
-d "token=SOME_TOKEN"# Test token revocation
REVOKE_URL="https://auth.target.com/oauth/revoke"
curl -s -X POST "$REVOKE_URL" \
-u "CLIENT:SECRET" \
-d "token=SOME_TOKEN&token_type_hint=access_token"# Verify token is actually revoked
curl -s -X POST "$INTROSPECT_URL" \
-u "CLIENT:SECRET" \
-d "token=SOME_TOKEN"
Step 7: Test Consent Bypass
#!/bin/bash# Test if consent can be bypassed
AUTH_URL="https://auth.target.com/oauth/authorize"
CLIENT_ID="test_client"# Test with prompt=none (should fail if no prior consent)
curl -s "$AUTH_URL?client_id=$CLIENT_ID&response_type=code&redirect_uri=https://client.com/callback&scope=openid&prompt=none"# Test with approval_prompt=auto
curl -s "$AUTH_URL?client_id=$CLIENT_ID&response_type=code&redirect_uri=https://client.com/callback&scope=openid&approval_prompt=auto"# Test with auto-approved client# Some clients may be pre-approved (first-party apps)# Check for scope creep# If initially granted "read", can we silently add "write"?
curl -s "$AUTH_URL?client_id=$CLIENT_ID&response_type=code&redirect_uri=https://client.com/callback&scope=openid+profile+email+admin&prompt=none"
Step 8: Test Resource Owner Password Grant
#!/bin/bash# Test ROPC (Resource Owner Password Credentials) grant
TOKEN_URL="https://auth.target.com/oauth/token"# Test if ROPC is enabled (should be disabled for most apps)
curl -s -X POST "$TOKEN_URL" \
-d "grant_type=password&username=test&password=test&client_id=CLIENT&client_secret=SECRET"# If enabled, test for brute force protectionfor i in {1..20}; do
response=$(curl -s -X POST "$TOKEN_URL" \
-d "grant_type=password&username=admin&password=password$i&client_id=CLIENT&client_secret=SECRET")
status=$(echo"$response" | jq -r '.error // "success"')
echo"Attempt $i: $status"if [ "$status" == "too_many_requests" ]; thenecho"Rate limited after $i attempts"breakfidone