Skip to content
Info disclosure Write-up Beginner

From Error_Log File(P4) To Company Account Takeover(P1) and Unauthorized Actions On API

An error log file exposed on a subdomain contained an API authentication token and API endpoint URLs. The hunter used the token to authenticate to the API and read encoding jobs, devices, groups, and products belonging to the account.

Muhanad Israiwi Follow

Published on medium.com

Hi Everyone,My name is Muhanad Israiwi. I’m Bug Bounty Hunter, I'm Student At Amman Arab University.

Muhanad Israiwi, on medium.com

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.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 5 min read.

Context

This write-up describes a hunt against a program the author calls Aex-Target, whose scope covered subdomains of *.aex-target.com. The author, Muhanad Israiwi, frames the work as a chain that started from a publicly reachable log file rated P4 and ended in what he describes as company account takeover and unauthorised actions on an API, rated P1.

The feature at the centre of the report is an API on a separate host, xxxUpload.com, with endpoints for encoding jobs, groups, devices, network types and products. The API expects a token in an Authorization header and returns JSON. When called without credentials it refuses the request, which is the behaviour that made the leaked token interesting.

Setup

The only precondition described is a subdomain enumeration and content discovery workflow run against the in-scope domain. No accounts, roles or versions are mentioned. The tooling named in the report is:

  • Subdomain enumeration: Findomain, Sublist3r, Amass, Subfinder.
  • Deduplication and sorting of results, or the anew tool by tomnomnom.
  • Live host filtering: Httpx.
  • Directory and endpoint fuzzing: FFuf, Dirsearch, wfuzz, with a wordlist such as the one linked in the report or any list the reader has.
  • An API wordlist, linked as API-World_List, used later for endpoint discovery.

Finding it

The author's routine is to enumerate subdomains, collect and sort the output into one file, filter for live hosts, and then fuzz those live hosts for paths. The sorting step is a single shell command:

Bash
cat file.txt | sort -u > new_file.txt

Live subdomains are saved to Result.txt with Httpx, and that file becomes the input for directory fuzzing. After fuzzing, one of the subdomains returned an error_log file. The report gives the vulnerable file as:

Text
https://aex-target.com/log.txt

The file contained many errors and dummy information, but among it were request headers of this shape:

Text
{ Authorization: Token 66d3337fefbf4d91xxxxxxxxxxxxx Accept: application/json singularityheader: appId=64xx Content-Type: application/json; charset=utf-8 Content-Length: 23}

The important part is the Authorization: Token ... header: a credential written into an error log that was publicly reachable. The author then searched the same file for API paths by pressing CTRL+F and looking for /api/, or by extracting URLs from the file with a command. That search surfaced an endpoint of the form:

Text
https://xxxUpload.com/api/encodingjobs/1xx9788/

Navigating to the endpoint returned:

JSON
{“detail”:”Authentication credentials were not provided.”}

The endpoint returned an authentication error when called without credentials.

Exploitation

Step 1: replay the leaked token against the encoding jobs endpoint

The first request was sent with curl, reusing the token from the log file:

Bash
curl “https://xxxUpload.com/api/encodingjobs/" -H “Authorization: Token 66d3337fefbf4d91xxxxxxxxxxxxx”

The Authorization header carries the token recovered from log.txt. According to the report, this request returned all encoding jobs belonging to the token's owner. On its own the author judged this insufficient for high impact, so he moved on to discovering more endpoints.

Step 2: fuzz for additional API endpoints

With Dirsearch and the API wordlist, run against the same host, the author discovered four more endpoints:

Text
https://xxxUpload.com/api/groups/
https://xxxUpload.com/api/devices/
https://xxxUpload.com/api/networktypes/
https://xxxUpload.com/api/products/

Step 3: reuse the same token on each endpoint

The same curl request was repeated with each newly found path substituted for the original one. The report states that this exposed, inside the account tied to the token:

  1. All devices, via /api/devices/.
  2. All groups, via /api/groups/.
  3. All products, via /api/products/.

The /api/networktypes/ endpoint is listed among the discoveries but the report does not describe a result for it.

Root cause

Two mistakes combine here. First, an application wrote full request headers, including an Authorization token, into an error log, and that log was left reachable at a predictable path on a public subdomain. Second, the same token worked against several resource collections, not just the encoding jobs endpoint.

The API rejected the unauthenticated request, so the leaked token was what made access possible. Whether the token was long-lived, shared between users, or tied to a privileged account is not stated.

Impact

An attacker who can read the log file obtains a working API token and can then read the account's encoding jobs, devices, groups and products without any further authentication. The author characterises the outcome as company account takeover and unauthorised actions on the API, and rates the chain P1 against a P4 starting point. The report does not enumerate write operations, so the demonstrated impact is disclosure of account data through the listed endpoints; any state-changing actions are asserted in the title rather than shown in the requests.

Fix

The report does not say what the program changed. Sensible measures would be to stop serving logs publicly, stop logging credentials, rotate the leaked token and scope API tokens narrowly.

Variants to test

  1. Fuzz for log and backup files on every live subdomain (log.txt, error_log, and similar names from a standard wordlist). A positive result is a reachable log containing request headers or credentials.
  2. Grep any discovered log for /api/ and for Authorization, Bearer, Token and cookie names. A positive result is a path plus a credential that can be replayed.
  3. Replay a recovered token against the endpoint it was logged with, then fuzz sibling paths from an API wordlist and replay the same token on each. A positive result is a 200 with JSON collections where an unauthenticated request returns an authentication error.
  4. Compare the unauthenticated and authenticated responses on each endpoint to confirm the difference is authorisation and not caching. A positive result is an authentication error without the header and data with it.
  5. Check whether the token grants write access by repeating the request with a state-changing method on the same paths. A positive result is a success response rather than a 403 or 405.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 10 min read.

What happened, in plain words

A security researcher was testing a company's website, which he calls Aex-Target in his write-up. While looking around, he found a file on one of the company's web servers that was never meant to be public: a log file. A log file is a diary that a web server or application keeps, writing down what happened, including errors. This one was sitting at a web address anyone could open in a browser.

Inside that log were request headers, and among them was a token. A token is a short string of characters that works like a temporary key or a wristband at an event: if you show it, the system believes you are the person it was issued to, without asking for a password again. The token in the log was used against a separate service, xxxUpload.com, which has an API.

An API (Application Programming Interface) is the part of a website that programs talk to, rather than people clicking buttons. Think of a restaurant: the dining room with menus is the website you see, and the kitchen door where waiters hand in orders is the API. You can send an order (a request) to the kitchen door and get food (data) back, but only if you are allowed to be there. This API hands out information in JSON, a text format for structured data that looks a bit like a shopping list with labels.

The API refused to answer when asked without a key. But the researcher now had a key, copied from the public log. He used it, and the API answered with the account's encoding jobs; further endpoints later returned devices, groups and products. He then guessed more addresses on the same API and found more collections he could read with the same key.

The researcher describes the whole chain as starting from a low-severity problem (a public log file, rated P4) and ending in what he calls company account takeover and unauthorised actions on the API (rated P1). Severity ratings like P1 and P4 are labels programs use to say how serious a finding is; P1 is the most serious, P4 the least.

The setup: how the researcher found things

Before any of this, the researcher did what he says he does on every hunt: subdomain enumeration. A domain is the main name of a site, like aex-target.com. A subdomain is a name in front of it, like shop.aex-target.com or mail.aex-target.com. Companies often have many, and some are forgotten, old or less protected. Enumerating means finding as many of these names as possible.

The tools he names for this are Findomain, Sublist3r, Amass and Subfinder. You do not need to know how each works to follow the story; they all do the same basic job of producing lists of subdomain names.

Once you have several lists, you have duplicates. He merges and sorts them with one command:

Bash
cat file.txt | sort -u > new_file.txt

Line by line:

  • cat file.txt prints the contents of file.txt to the screen (here, into the next step instead).
  • | is a pipe: it takes the output of the command on the left and feeds it as input to the command on the right, like passing a plate along a counter.
  • sort -u sorts the lines alphabetically and the -u means unique, so duplicate lines are removed.
  • > new_file.txt writes the result into a new file called new_file.txt, replacing anything already there.

He mentions the tool anew by tomnomnom as an alternative for the same job of keeping only new lines.

Next he filtered which subdomains were actually alive (responding) using a tool called Httpx, saving the live ones in Result.txt. Then he did fuzzing on those live hosts. Fuzzing means trying a long list of common names against a server very quickly, to see which ones exist. It is like trying every key on a big keyring in a door to see which one turns. The tools he lists are FFuf, Dirsearch and wfuzz, used with a wordlist (a file full of candidate names) such as the one he links, or any list you have.

Finding the log file

After fuzzing, one of the subdomains returned an error_log file. The report gives the address of the file it found as:

Text
https://aex-target.com/log.txt

This is a plain web address, and the file's contents could be read from it. That is the first mistake: log files are for the operators of a site, not for visitors.

Inside the file there were lots of errors and dummy information, but the researcher noticed request headers that looked like this:

Text
{ Authorization: Token 66d3337fefbf4d91xxxxxxxxxxxxx Accept: application/json singularityheader: appId=64xx Content-Type: application/json; charset=utf-8 Content-Length: 23}

What this is: a record of the headers of a request that the application had logged. Headers are the small labelled lines that travel with every web request and response, carrying information about it, like the address label and handling instructions on a parcel. Reading the labels:

  • Authorization: Token 66d3337fefbf4d91xxxxxxxxxxxxx is the credential. The word Token says what kind of credential it is, and the long string after it is the secret itself. This is the key that should never have been written into a file anyone can read.
  • Accept: application/json tells the server the client would like JSON back.
  • singularityheader: appId=64xx is a custom header, apparently used by this application to identify an app.
  • Content-Type: application/json; charset=utf-8 says the body of the request is JSON text encoded in UTF-8 (a common way of representing characters).
  • Content-Length: 23 says the body is 23 bytes long.

The important line is the first one. Everything else is context.

From the log to an API address

A token is only useful if you know where to use it. So the researcher searched the same log file for API addresses. His method was simple: press CTRL+F (the browser's find function) and search for /api/, or use a command to pull URLs out of the file. The /api/ part is a common piece of a web address that marks the program-facing part of a site, as opposed to the pages people click.

That search turned up an address like this:

Text
https://xxxUpload.com/api/encodingjobs/1xx9788/

Note that this is a different host from the one with the log file.

When he opened that address in a browser, the API replied:

JSON
{“detail”:”Authentication credentials were not provided.”}

This is a JSON message saying, in effect: this endpoint exists, but you did not show me a key. That is actually useful information. It confirms the address is real and that it is protected. It also tells him exactly what to try next: send the same request again, but this time with the key from the log.

Exploitation

Step 1: use the leaked token on the encoding jobs endpoint

He sent the request with curl, a command-line tool for making web requests. It is the same kind of request a browser makes, but typed out so you can control every part of it.

Bash
curl “https://xxxUpload.com/api/encodingjobs/" -H “Authorization: Token 66d3337fefbf4d91xxxxxxxxxxxxx”

Line by line:

  • curl is the program being run.
  • “https://xxxUpload.com/api/encodingjobs/" is the address being requested. The quotes are there to keep the address together as one piece.
  • -H tells curl to add a header to the request.
  • “Authorization: Token 66d3337fefbf4d91xxxxxxxxxxxxx” is that header: the same credential copied from the log file.

According to the report, this returned all the encoding jobs belonging to the owner of the token. Encoding jobs are tasks the service was processing; the exact meaning does not matter for the lesson. What matters is that a key found in a public file opened a private account's data.

He judged this alone not serious enough to be high impact. Reading one list is bad, but it is a narrow slice. So he went looking for more.

Step 2: fuzz for more API endpoints

He ran Dirsearch against the same host with an API wordlist (he links one called API-World_List). This is the same fuzzing idea as before, but with a list of common API path names instead of common page names. It found four more addresses:

Text
https://xxxUpload.com/api/groups/
https://xxxUpload.com/api/devices/
https://xxxUpload.com/api/networktypes/
https://xxxUpload.com/api/products/

Each of these is a different collection of things the service keeps: groups, devices, network types and products. Think of them as different drawers in the same filing cabinet.

Step 3: reuse the same token on each endpoint

He then repeated the same curl request, swapping in each new address. The report states that this exposed, inside the account tied to the token:

  1. All devices, via /api/devices/.
  2. All groups, via /api/groups/.
  3. All products, via /api/products/.

The /api/networktypes/ address is listed among the discoveries, but the report does not describe what came back from it.

This is the heart of the finding: one key, found in one public file, opened several drawers of one account. The researcher describes the result as company account takeover and unauthorised actions on the API.

Why it worked

Two separate mistakes lined up.

First, the application wrote full request headers, including the Authorization token, into an error log, and that log was reachable at a predictable address on a public subdomain. Predictable matters: fuzzers try common names like log.txt and error_log precisely because people leave them there.

Second, the same token worked against several collections, not just one. The API rejected the request with no key at all, so the leaked key was what made access possible.

The report does not say whether the token was long-lived, shared between users, or tied to a particularly privileged account.

What the impact is

Anyone who can open the log file gets a working API token. With it they can read the account's encoding jobs, devices, groups and products without any further login. Any state-changing actions are asserted in the title rather than shown in the requests.

How to fix it

Sensible measures would be:

  • Remove the log file from the web root and stop serving logs publicly.
  • Stop writing Authorization headers and other credentials into logs.
  • Rotate (replace) any token that has appeared in a log.
  • Scope API tokens to the minimum set of resources and actions they need.

Variants to test

If you want to look for the same pattern yourself, these are the checks the findings suggest:

  1. Fuzz for log and backup files on every live subdomain (log.txt, error_log, and similar names from a standard wordlist). A positive result is a reachable log containing request headers or credentials.
  2. Search any discovered log for /api/ and for Authorization, Bearer, Token and cookie names. A positive result is a path plus a credential that can be replayed.
  3. Replay a recovered token against the endpoint it was logged with, then fuzz sibling paths from an API wordlist and replay the same token on each. A positive result is a 200 with JSON collections where an unauthenticated request returns an authentication error.
  4. Compare the unauthenticated and authenticated responses on each endpoint to confirm the difference is authorisation and not caching. A positive result is an authentication error without the header and data with it.
  5. Check whether the token grants write access by repeating the request with a state-changing method on the same paths. A positive result is a success response rather than a 403 or 405.

Glossary

  • API: the part of a service that programs talk to, rather than people clicking pages; the kitchen door where orders are handed in.
  • API wordlist: a file of common API path names used when fuzzing for endpoints.
  • Authorization header: a header that carries a credential, proving who is making a request.
  • Cookie: a small piece of data a site stores in your browser to remember you; like a claim ticket.
  • Credential: anything that proves identity, such as a password or token.
  • curl: a command-line tool for sending web requests.
  • Dirsearch: a tool that tries many path names against a server to find hidden files and directories.
  • Domain: the main name of a website, such as aex-target.com.
  • Endpoint: a specific address on an API that does one job, such as listing devices.
  • Enumeration: systematically listing things, such as all subdomains of a domain.
  • error_log: a file where an application writes errors and other events; not meant to be public.
  • FFuf: a fast fuzzing tool for trying many names against a server.
  • Fuzzing: trying a long list of candidate names against a server to see which exist.
  • Header: a labelled line sent with a web request or response, carrying information about it.
  • Httpx: a tool that checks which hosts are alive and responding.
  • JSON: a text format for structured data, like a labelled shopping list.
  • P1 / P4: severity labels used by bug bounty programs; P1 is the most serious, P4 the least.
  • Request: a message a client sends to a server asking for something.
  • Response: the message a server sends back.
  • Subdomain: a name in front of a domain, such as shop.aex-target.com.
  • Token: a string of characters that acts as a key, proving identity without a password.
  • Wordlist: a file full of candidate names used when fuzzing.
  • wfuzz: a fuzzing tool for trying many inputs against a web server.
  • 403 / 405: HTTP status codes meaning forbidden and method not allowed respectively.
  • 200: the HTTP status code meaning the request succeeded.

Similar reports

View all

Same bug class and techniques, clearest first.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.