Courseiva
Web Application Attacks →mediumMultiple Choice

PEN-200 Web Application Attacks Practice Question

During an external penetration test, you discover a web application that uses a JSON Web Token (JWT) for authentication. The token header is {"alg":"HS256","typ":"JWT"}, and you have captured a valid token. You want to escalate privileges by modifying the "role" claim from "user" to "admin". Which action would most likely allow you to forge a valid token?

⚠ Common exam trap

The trap here is assuming that changing the algorithm to "none" always works, when in fact most modern JWT libraries reject unsigned tokens by default.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

Brute-force the HMAC secret used to sign the token, then re-sign the modified token.

The JWT is signed with HS256, meaning a symmetric secret is used. If that secret is weak, an attacker can crack it offline and then sign arbitrary tokens. Changing the algorithm to "none" might work only if the server is misconfigured, but brute-forcing the secret is a direct and reliable method when the secret is guessable. The other options either rely on server misconfigurations or incorrect cryptographic assumptions.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    Change the "alg" value to "none" and remove the signature, then send the token.

    Why it's wrong here

    Setting the algorithm to "none" and stripping the signature is a known JWT attack, but it only works if the server explicitly accepts unsigned tokens. Modern libraries and properly configured servers reject "none" by default. In this scenario, the token uses HS256, so the server likely expects a signed token and would not accept an unsigned one, making this approach unreliable.

  • ✓

    Brute-force the HMAC secret used to sign the token, then re-sign the modified token.

    Why this is correct

    With HS256, the token is signed using a symmetric secret. If the secret is weak or guessable, an attacker can brute-force it offline using tools like hashcat or john. Once the secret is recovered, the attacker can modify the "role" claim and generate a valid signature, forging an admin token. This is a common and effective attack when the secret is not strong.

  • ✗

    Modify the "role" claim and recompute the signature using the original token's signature as the key.

    Why it's wrong here

    The signature is computed over the header and payload using a secret key, not the previous signature. Using the original signature as a key would not produce a valid signature because the server verifies with the actual secret. This approach misunderstands how HMAC signing works and would result in an invalid token that the server rejects.

  • ✗

    Change the "alg" value to "RS256" and sign the token with the public key.

    Why it's wrong here

    Switching to RS256 and signing with the public key is a variant of the algorithm confusion attack, but it requires the server to accept RS256 and use the public key as an HMAC secret. This is not guaranteed; many servers strictly enforce the algorithm specified in the header or use separate keys. Without knowing the server's configuration, this is less reliable than brute-forcing the secret.

About these practice questions

Courseiva writes every PEN-200 question from scratch — 285 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official OffSec exam blueprint

This PEN-200 practice question is part of Courseiva's free OffSec certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PEN-200 exam.