Chains on Chains!! Chaining several IDOR’s into Account Takeover(PART ONE)
The utility service allowed enumeration of account IDs and brute-forcing of 4-digit PINs, which returned the victim's email address. An attacker could then enrol the victim's account, change the email address, and use the main site's password reset to take over the account.
Published on medium.com
Welcome to my FIRST writeup! Just to give you some background, My name is Daniel, I started hacking about 4 months ago and can’t stop!
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
The target is a utility company that provides services to a state. The program lets a user sign up for several services using the same credentials. In the write-up the main site is referred to as https://gas.com/ and the secondary service as "utility" at https://gas.com/utility/. The utility service is a property portal where a customer enrols using an AccountID and a 4-digit PIN, then sets a username and password. Once logged in, the user can create an agreement that is prepopulated with sensitive information from the main account (name, phone number, employer, address, first and last name), and can change the email address, username and password in the profile section.
Setup
The researcher had an account on gas.com and enrolled in the utility service using the same account information. Enrolment requires the AccountID and the 4-digit PIN. The researcher used two of their own accounts to compare AccountIDs. No specific tools or versions are named in the report.
Finding it
During content discovery the researcher located the utility service. While enrolling, they noticed that the email address associated with the AccountID was already prepopulated at step 2, and the username was prepopulated at step 3. They also noticed that when an AccountID is entered at step 1, the server calls an endpoint to validate it:
https://gas.com/utility/account/check/{{AccountID}}
This returns True or False. Comparing the AccountIDs of their two accounts, they found the IDs differed only in the first 6 digits. This suggested the AccountID could be enumerated by brute-forcing the first 6 digits followed by four zeros and a single digit from 1 to 9. For example, if the account ID is 12345600007, the 123456 part is brute-forced, the four zeros stay the same, and the final digit changes between 0 and 9. The researcher enumerated several account IDs in about 15 minutes this way, and states they did not take additional action with those accounts.
They could also check whether an account had been enrolled by calling:
https://gas.com/utility/enrolled/check/{{AccountID}}
which returns True or False.
Exploitation
Step 1: Enumerate AccountIDs
Using the account check endpoint, the researcher brute-forced the first 6 digits of the AccountID with the remaining digits fixed as four zeros plus a single digit. A positive result is a True response from https://gas.com/utility/account/check/{{AccountID}}. The enrolled check endpoint confirms whether the account has already been enrolled.
Step 2: Brute-force the PIN and leak the email
Once an AccountID is known, the PIN can be validated with a POST request to:
https://gas.com/utility/pin/check
sending the following parameters:
{"accountNumber":"12345600007","accountPin":"1234"}
A 4-digit PIN is quick to brute-force. When the correct PIN is hit, the response validates that the account exists and returns the email address associated with the victim. This means the endpoint can be used to enumerate PINs and email addresses given only an AccountID.
Step 3: Enrol the victim
With the victim's AccountID, PIN and email address, the researcher went back to step 1 of enrolment and enrolled the victim:
- Enter the victim's AccountID and AccountPin and press next.
- Enter the victim's email address and confirm it (it is already populated) and press next.
- Confirm the username (already populated) and set a password.
At this point the victim is enrolled in the property portal and the attacker is logged in as them.
Step 4: Act as the victim and change the email
Once logged in, the attacker can act on behalf of the victim. Creating an agreement prepopulates it with sensitive information from the main account (name, phone number, employer, address, first and last name). The attacker can also change the email address in the My profile section.
The researcher tested whether changing the password in the utility service would also change the password on the main account. That did not work. However, a notification stated that if the password were changed there, it would propagate to the main page. This implies that changing the email address in utility reflects on the account services as well. The attacker can therefore change the victim's email address in utility, then send a forgot password request on the main page, which allows a full takeover of every account that can be enumerated.
Root cause
The core issue is an insecure direct object reference: the account check, enrolled check and pin check endpoints accept an AccountID (and PIN) and return whether it is valid, which the researcher used to enumerate accounts. The AccountID is predictable because it differs only in the first 6 digits, and the PIN is only 4 digits, so both can be brute-forced. The enrolment flow also prepopulates the email address and username. The profile change of email address propagates to the main account, so changing the email enables a password reset on the main site. The report does not state what defences, if any, were in place (rate limiting, lockout, CAPTCHA); the brute force succeeded in about 15 minutes for AccountIDs and the PIN is described as very easy and quick to brute-force.
Impact
An attacker who can enumerate AccountIDs and brute-force PINs can obtain the email address associated with each account, enrol as the victim, view and act on sensitive information (name, phone number, employer, address), change the victim's email address, and then trigger a password reset on the main site to take over the account. The researcher describes this as a 100% full takeover of every account that can be enumerated. The report does not state how many accounts were affected or whether the program awarded a bounty.
Fix
Based on the described behaviour, the endpoints should require authentication and verify that the requesting user owns the AccountID, the PIN should not be brute-forceable (rate limiting, lockout, CAPTCHA), and the email change in utility should not propagate to the main account without additional verification.
Variants to test
- Enumerate predictable identifiers on other services (sequential or partially fixed IDs) and check whether validation endpoints return True/False without authentication. A positive result is a True response for an ID you do not own.
- Brute-force short PINs or codes on validation endpoints. A positive result is a valid PIN returned along with associated data such as an email address.
- Test whether profile changes (email, username) in a secondary service propagate to the main account. A positive result is the change appearing on the main account, enabling a password reset.
- Check whether enrolment flows prepopulate sensitive fields such as email or username. A positive result is a prepopulated field that confirms the victim's details and can be submitted without further verification.
What happened, in plain words
A security researcher found a way to take over other people's accounts on a utility company's website. The company runs a main site where customers sign up, and a second service (a "property portal") where the same customers can manage things like agreements. The researcher discovered that the second service would tell whether a given account number existed, and the PIN check would hand back the email address tied to it. Because account numbers were easy to guess and the PIN protecting them was only four digits, the researcher could work out both for other customers. With those two pieces of information they could enrol as the victim in the property portal, change the victim's email address there, and then use the main site's "forgot password" feature to reset the victim's password. That is a full account takeover.
This article walks through the same steps in the same order, explaining every concept from scratch. You only need a browser and a computer to follow along.
Background: what the product is
A utility company provides services to a state. Customers create an account on the main site, which the write-up calls https://gas.com/. From that one account they can sign up for several services using the same login details.
One of those services is a property portal, which the write-up calls "utility" and which lives at https://gas.com/utility/. In the portal a customer enrols using two things:
- an AccountID, a long number that identifies their account, and
- a 4-digit PIN, a short numeric code, like the PIN on a bank card.
After enrolling, the customer sets a username and a password and can log in. Once inside, they can create an agreement, and the form comes pre-filled with sensitive details pulled from the main account: name, phone number, employer, address, first and last name. In the profile section they can also change their email address, username and password.
A few terms used throughout:
- Endpoint: a specific address on a server that does one job, like a counter in a shop.
https://gas.com/utility/account/check/is one counter;https://gas.com/utility/pin/checkis another. - API: the set of endpoints a website's pages talk to behind the scenes. When you fill in a form, your browser sends a request to an API endpoint and the page updates with the answer.
- Request: the message your browser sends to a server, for example "does account 12345600007 exist?".
- Response: the server's reply, for example "True" or "False".
- IDOR (Insecure Direct Object Reference): a bug where a server lets you ask about an object (an account, a file, an order) just by naming it, without checking that the object is yours. Think of a hotel where any guest can open any room by saying the room number out loud, because the reception never checks the key.
- Brute force: trying every possible value until one works. Like spinning the dials on a combination lock one combination at a time.
- Enumeration: listing things out one by one. Here, walking through account numbers to find which ones exist.
- Account takeover: getting full control of someone else's account, usually by changing their password or email so the real owner is locked out.
Setting up
The researcher already had an account on gas.com and enrolled in the utility service using the same account information. Enrolment needs the AccountID and the 4-digit PIN. To compare account numbers, the researcher used two of their own accounts. The report does not name any tools or versions.
Finding the weakness
While exploring the site (the write-up calls this "content discovery", meaning looking around for pages and services that are not linked prominently), the researcher found the utility service. During enrolment they noticed two things:
- At step 2, the email address associated with the AccountID was already filled in.
- At step 3, the username was already filled in.
Those pre-filled fields matter later: the email address and username are already populated when you reach those steps.
They also noticed that when you type an AccountID at step 1, the server calls an endpoint to check it:
https://gas.com/utility/account/check/{{AccountID}}
Line by line:
https://gas.com/utility/account/check/is the address of the checking endpoint.{{AccountID}}is a placeholder for the account number you want to check. In a real request you would put the number there, for examplehttps://gas.com/utility/account/check/12345600007.
The endpoint replies with True or False: whether the account exists. The researcher used it to enumerate account numbers.
How the researcher captured a victim's AccountID
The researcher compared the AccountIDs of their two own accounts and found something interesting: the two numbers differed only in the first 6 digits. That pattern suggested the numbers were not random. If the first six digits are the only part that changes, you can guess account numbers by trying every possible first six digits while keeping the rest fixed.
In the write-up's example, an account ID looks like 12345600007. The plan is:
- brute-force the
123456part, - keep the four zeros that follow it,
- and vary the final digit between 0 and 9.
Running that for about 15 minutes, the researcher enumerated several account IDs. The report states clearly that no further action was taken with those accounts.
To know whether a found account had already been enrolled in the portal, the researcher called another endpoint:
https://gas.com/utility/enrolled/check/{{AccountID}}
Line by line:
https://gas.com/utility/enrolled/check/is the address of the enrolment-check endpoint.{{AccountID}}is again the account number to check.
It replies True or False: whether that account has been enrolled.
How the researcher captured the PIN
Knowing an AccountID is not enough to enrol: the portal also asks for the 4-digit PIN. When you submit the PIN, the server validates it with a POST request to:
https://gas.com/utility/pin/check
A POST request is simply a request that carries data in its body, the way a form you fill in and submit carries your answers. The data sent here is:
{"accountNumber":"12345600007","accountPin":"1234"}
Line by line:
- The whole thing is JSON, a common text format for structured data. Curly braces
{}wrap an object, and each entry is a"name":"value"pair separated by commas. "accountNumber":"12345600007"is the account number being checked."accountPin":"1234"is the PIN being tried.
A 4-digit PIN has only 10,000 possible values (0000 to 9999), which is quick to try one after another. When the correct PIN is hit, the response confirms the account exists and also returns the email address associated with it. So with only an AccountID, this endpoint lets you find the PIN and the email address.
Enrolling as the victim
Now the researcher had three things: the victim's AccountID, the victim's PIN, and the victim's email address. That is everything the enrolment flow asks for. The steps were:
- Enter the victim's AccountID and AccountPin and press next.
- Enter the victim's email address and confirm it (it is already populated) and press next.
- Confirm the username (already populated) and set a password.
At this point the victim is enrolled in the property portal, and the attacker is logged in as them.
Acting as the victim and changing the email
Once logged in, the attacker can do anything the victim could do. Creating an agreement pre-fills it with sensitive information from the main account: name, phone number, employer, address, first and last name. The attacker can also change the email address in the My profile section.
The researcher then tested whether changing the password in the utility service would also change the password on the main account. It did not. But a notification stated that if the password were changed there, it would propagate to the main page. In other words, the two accounts are linked: a change made in the portal shows up on the main site.
That is the key. If the email address can be changed in the portal, and the change carries over to the main account, then the attacker can:
- change the victim's email address in the portal to one the attacker controls,
- go to the main site and use the "forgot password" feature,
- receive the reset link at the attacker's email address, and
- set a new password for the victim's main account.
That is a full takeover of every account that can be enumerated.
Why it worked
The core problem is an insecure direct object reference. The account check, enrolled check and pin check endpoints accept an AccountID (and a PIN) and return whether it is valid, which the researcher used to enumerate accounts.
Two more weaknesses make it practical:
- The AccountID is predictable, because it differs only in the first 6 digits.
- The PIN is only 4 digits, so it can be guessed quickly.
The enrolment flow also pre-fills the email address and username. Finally, changing the email address in the portal propagates to the main account, so the change enables a password reset on the main site.
The report does not state what defences, if any, were in place, such as rate limiting (a cap on how many requests you can make in a period), lockout (blocking an account after too many wrong tries) or CAPTCHA (a puzzle to prove you are human). The brute force succeeded in about 15 minutes for AccountIDs, and the PIN is described as very easy and quick to brute-force.
What the impact is
An attacker who can enumerate AccountIDs and brute-force PINs can:
- obtain the email address associated with each account,
- enrol as the victim,
- view and act on sensitive information (name, phone number, employer, address),
- change the victim's email address, and
- trigger a password reset on the main site to take over the account.
The researcher describes this as a 100% full takeover of every account that can be enumerated.
How it should be fixed
Based on the described behaviour, the endpoints should require authentication and verify that the requesting user owns the AccountID, the PIN should not be brute-forceable (rate limiting, lockout, CAPTCHA), and the email change in the portal should not propagate to the main account without additional verification.
Things to try on other programs
- Enumerate predictable identifiers on other services (sequential or partially fixed IDs) and check whether validation endpoints return True/False without authentication. A positive result is a True response for an ID you do not own.
- Brute-force short PINs or codes on validation endpoints. A positive result is a valid PIN returned along with associated data such as an email address.
- Test whether profile changes (email, username) in a secondary service propagate to the main account. A positive result is the change appearing on the main account, enabling a password reset.
- Check whether enrolment flows pre-populate sensitive fields such as email or username. A positive result is a pre-populated field that confirms the victim's details and can be submitted without further verification.
Glossary
- Account takeover: gaining full control of someone else's account, usually by changing their password or email so the real owner is locked out.
- API: the set of endpoints a website's pages talk to behind the scenes to fetch and send data.
- Brute force: trying every possible value until one works, like spinning the dials on a combination lock.
- CAPTCHA: a puzzle designed to prove a human, not a script, is making the request.
- Content discovery: looking around a site for pages and services that are not linked prominently.
- Endpoint: a specific address on a server that performs one job.
- Enumeration: listing things out one by one, here walking through account numbers to find which exist.
- IDOR (Insecure Direct Object Reference): a bug where a server lets you ask about an object just by naming it, without checking that the object is yours.
- JSON: a common text format for structured data, using curly braces and
"name":"value"pairs. - Lockout: blocking an account or address after too many failed attempts.
- PIN: a short numeric code, like the one on a bank card.
- POST request: a request that carries data in its body, like a form you fill in and submit.
- Propagate: carry over from one system to another, so a change in one place appears in the other.
- Rate limiting: a cap on how many requests can be made in a period.
- Request: the message your browser sends to a server.
- Response: the server's reply to a request.
- True/False response: a reply that only says whether something exists or is valid, without further detail.