CSRF (protection bypassed) to force a below 18 user into viewing an nsfw subreddit !
A state-changing POST request to the over-18 preference endpoint lacked a proper modhash validator, so it was vulnerable to cross-site request forgery. An attacker could trick a logged-in user into toggling the adult-content preference and viewing NSFW subreddits.
Originally disclosed on HackerOne
- Triaged in under an hour
- Fixed in 4 months
- Paid in 5 hours
- Disclosed after 4 months
Summary by the program
Summary of the Issue
A state-changing POST request to https://old.reddit.com/over18? lacked proper modhash validator leaving the sensitive action vulnerable to CSRF attacks. An attacker can trick users into executing the action, enabling/disabling "I am over eighteen years old" and willing to view adult content preference in the victim account.
#Steps to reproduce
- Create a reddit account and go to https://old.reddit.com/prefs/
- Scroll down and you'll see an option saying I am over eighteen years old and willing to view adult content. Turn that off.
- Visit nsfw subreddit https://www.reddit.com/r/<nsfw_subreddit_here> and you'll see a window asking if you want to see nsfw content.
- Open html file of html content shown below
- Settings will get updated and you'll be able to view nsfw content. In other words you'll be able to view https://www.reddit.com/r/<nsfw_subreddit_here>
<html>
<body>
<form action="https://old.reddit.com/over18?dest=https%3A%2F%2Fold.reddit.com%2Fr%2F<nsfw_subreddit_here>%2F" method="POST">
<input type="hidden" name="over18" value="yes" />
<input type="submit" value="Submit request" />
</form>
<script>
document.forms[0].submit();
</script>
</body>
</html>
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the over-18 preference endpoint accepted POST requests without validating the modhash (Reddit's per-session CSRF token), so any origin could submit the state change.
Impact
An attacker could force a logged-in victim's account to toggle the adult-content preference, enabling viewing of NSFW content; no further compromise is claimed.
What the attacker needed
Victim has a Reddit account; victim is logged in; victim opens attacker's page or link
How it was found
- Create a Reddit account and open the preferences page.
- Turn off the over-18 adult content option.
- Visit an NSFW subreddit to confirm the age prompt appears.
- Open a local HTML file containing an auto-submitting form to the over-18 endpoint.
- Observe that the preference is updated and the NSFW subreddit becomes viewable.
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 report has not been written yet. The Original tab links to the source.
When you are logged in to a site, your browser automatically sends your session cookie with every request to that site. If a site accepts a change (like a preference toggle) without also checking a secret token that only its own pages know, another website can make your browser send that change for you. This is called cross-site request forgery, or CSRF.
What is CSRF?
Another site makes a signed-in user's browser perform an action they did not intend.