CSRF In JSF 2.0: Predicting CSRF Tokens For Apache MyFaces
Apache MyFaces generated ViewState and CSRF tokens using a predictable random number generator, allowing an attacker to predict valid tokens and perform CSRF attacks. This affected both server-side and client-side state saving configurations.
Published on certitude.consulting
Written by Wolfgang Ettlinger on 19.02.202118.05.2021
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The application used java.util.Random, a non-cryptographically secure pseudo-random number generator, to create security tokens, making them predictable.
Impact
An attacker could perform CSRF attacks, potentially executing state-changing actions on behalf of a victim user.
What the attacker needed
Victim uses Apache MyFaces; attacker can obtain a ViewState token; victim visits attacker's site
The fix
Apache MyFaces was updated to use cryptographically secure random number generators by default, and users should upgrade to version 2.2.14, 2.3.8, 2.3-next-M5 or 3.0.0, or set specific configuration parameters to 'secureRandom'.
How it was found
- Obtain a valid ViewState string from the application.
- Use the observed random values to predict future ViewState values for other users.
- Send a crafted request with the predicted ViewState to perform a CSRF attack.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
CSRF (Cross-Site Request Forgery) is an attack where a malicious site tricks a logged-in user's browser into sending a request to another site, like changing their password. To stop this, sites use secret tokens that only the real site knows. Here, the tokens were made with a weak random generator that can be predicted, so an attacker could guess them and forge requests.
What is CSRF?
Another site makes a signed-in user's browser perform an action they did not intend.