Skip to content
Info disclosure Write-up Beginner

Decoding a $😱,000.00 htpasswd bounty

A publicly accessible .htpasswd file exposed a DES-hashed password, which the author cracked. The same credentials then granted access to multiple development and staging environments.

Patrik Fehrenbach Follow

Published on wss.sh

dirbuster https://www.owasp.org/index.php/Category:OWASPDirBusterProject

Patrik Fehrenbach (@ITSecurityguard), on wss.sh

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. 6 min read.

Context

This write-up covers a finding in a private bug bounty program. Because the program is private, the researcher does not disclose the identifying details of the target, so the company and its domains are redacted throughout. What is described is a web server that exposed a .htpasswd file publicly, and the chain that followed from it: cracking the stored hash and reusing the recovered credentials against other hosts.

The relevant feature is HTTP Basic Authentication, the mechanism several web servers offer for protecting a directory or site. When a browser requests a protected resource, the server answers with a challenge and the browser resends the request with an Authorization header carrying the username and password. The server checks those credentials against a password file, commonly named .htpasswd, which stores each user's password as a hash. The security of the whole arrangement depends on that file staying private and on the hashes inside it being hard to recover.

Setup

The researcher worked against a private program and was not permitted to name the target, so the domains below appear as they do in the report, with REDACTED in place of the company name. Two tools were used:

  • dirbuster, the OWASP directory and file brute-forcer, to enumerate paths on a host.
  • john (John the Ripper), to crack the recovered password hash, run with a wordlist suggested by Nico (@nijagaw): the CrackStation wordlist.

No accounts were provisioned in advance. The starting point was simply the ability to browse the company's public subdomains.

Finding it

The first step was subdomain discovery with a Google dork:

Text
site:*.REDACTED.com -www

This lists indexed subdomains of the target while excluding the www host. Among the results, one host stood out: admin.REDACTED.com. On review the site itself looked unremarkable, so the researcher turned to dirbuster to look for files and directories that were not linked from the pages.

Just as the search was about to be abandoned, dirbuster reported a .htpasswd file returning HTTP status 200. A 200 on a password file is the signal that matters: the server is serving the file as ordinary content rather than denying access to it. Visiting the URL confirmed it, and the file rendered in the browser.

The rendered file showed the username us3r and a password value that was not plaintext. That the username was visible was already useful; the password was still protected by a hash.

Exploitation

Step 1: Identify the hash format

The researcher had seen Basic Authentication password files before where the value was simply Base64 encoded, which offers no protection at all. This value did not look like Base64. After searching, the format was identified as DES (Data Encryption Standard), the traditional crypt(3) scheme used by .htpasswd files.

DES is considered insecure today and is susceptible to theoretical attacks, but there is no trivial method for cracking it. The practical route is a dictionary or brute-force attack against the hash, which is what John the Ripper does.

Step 2: Crack the hash with John

The hash was saved to a file named pw and John was run against it with the CrackStation wordlist:

Bash
john --wordlist=/Users/Patrik/Downloads/crackstation.txt pw

The run loaded a single hash and identified it as descrypt, the traditional crypt(3) DES scheme:

Text
Loaded 1 password hash (descrypt, traditional crypt(3) [DES 128/128 SSE2-16])

Press 'q' or Ctrl-C to abort, almost any other key for status

0g [redacted] 5% 0g/s 3316Kp/s 3316Kc/s 3316KC/s 09554858..09554972

0g [redacted] 52% 0g/s 2953Kp/s 2953Kc/s 2953KC/s 42333281..42333395

0g [redacted] 54% 0g/s 2971Kp/s 2971Kc/s 2971KC/s 45154098..45154206

0g [redacted] 35% 0g/s 3055Kp/s 3055Kc/s 3055KC/s CFCbu..CF(CC

sasi21033******        (?)

Use the "--show" option to display all of the cracked passwords reliably

Session completed

The progress lines show the wordlist being worked through at roughly three million candidates per second. The cracked entry then appears as sasi21033******, with the remainder of the password masked in the published output. The (?) after it is John's placeholder for the source file. The password was recovered from the wordlist.

Step 3: Find where the credentials apply

The site that hosted the .htpasswd file did not itself use .htaccess protection, so the recovered credentials had no obvious use there. With help from @mongobug, the researcher established that the following hosts were each protected by Basic Authentication:

  • thestageingstuff.*.domain.com
  • developmentworkshere.*.domain.com
  • quark.*.domain.com
  • devsfavourite.*.domain.com

The same username and password recovered from the .htpasswd file worked on every one of them. In other words, the credentials gave access to the company's development and beta environments.

Root cause

The immediate mistake is that the .htpasswd file was reachable over HTTP and returned status 200, so anyone who found the path could download it. A password file is only a defence if the server refuses to serve it; here nothing did.

The second mistake is in what the file contained. The password was stored as a DES crypt(3) hash, a fast scheme that a wordlist attack can exhaust at millions of candidates per second. A slow, modern password hash would have made the same wordlist run impractical.

The third mistake is credential reuse. The same username and password protected several separate development and staging hosts, so a single recovered secret opened all of them. The report does not describe how those hosts were configured, so whether they shared one password file or simply one password is not stated.

Impact

An attacker who found the file, as this researcher did through directory enumeration, could download the password hashes and crack them offline. With the recovered credentials, the researcher gained access to the company's development and beta environments across four hosts. The report does not describe what those environments contained or what further access they granted, so the impact beyond authenticated access to those hosts is not established here. The program owner responded quickly and resolved the issue even more quickly.

Fix

The measures that address the root cause are: stop serving .htpasswd (and similar) files over HTTP, for example by placing them outside the document root or denying access to them at the server; store passwords with a slow, modern hashing scheme instead of DES crypt(3); and avoid reusing one credential across multiple environments, so that a single cracked password does not open several hosts.

Variants to test

  1. Password files in the web root. Run directory enumeration against each host and watch for .htpasswd, .htaccess, backup copies and similar files returning 200. A positive result is the file rendering in the browser with usernames and hashes visible.
  2. Weak hash schemes in Basic Authentication files. When a hash is recovered, identify the scheme before assuming it is safe. A descrypt or otherwise fast hash is a candidate for a wordlist attack with John; a positive result is the password appearing in the john output.
  3. Credential reuse across environments. Take any credential recovered from one host and try it against staging, development and beta hosts found through subdomain enumeration. A positive result is a successful Basic Authentication challenge on a host you were not given credentials for.
  4. Subdomain discovery as the entry point. Start from a dork such as site:*.REDACTED.com -www to build a host list, then enumerate each host for exposed files. A positive result is an administrative or non-production host that exposes something it should not.

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. 13 min read.

What happened, in plain words

A security researcher was taking part in a private bug bounty program. A bug bounty program is an arrangement where a company invites independent researchers to look for security problems in its systems and pays them for reporting what they find. This particular program was private, which means only invited researchers could take part and the company's identity had to stay secret. That is why the company name appears as REDACTED everywhere in the story.

The researcher found a file on one of the company's web servers that was supposed to be secret but could be downloaded by anyone. The file held a username and a scrambled password. The researcher unscrambled the password, then discovered that the same username and password opened several other internal servers belonging to the company, including development and testing environments. The company fixed the problem quickly.

This article walks through the same steps at a beginner's pace. You only need to be comfortable using a browser and a computer to follow it.

Background: what the pieces are

Before the steps make sense, a few ideas need explaining.

Subdomains

A domain is a company's main address on the internet, something like example.com. A subdomain is a prefix added in front of it, such as admin.example.com or shop.example.com. Companies use subdomains to run separate services: one for the public website, one for the admin panel, one for development, and so on. Each subdomain can be a different machine with different content, even though they all belong to the same company.

Basic Authentication

Basic Authentication is a simple way for a web server to protect a page or a folder. Think of it like a door with a keypad: when you try to open the page, the server asks for a username and password before it shows anything. Several web servers offer this mechanism, and it is often used to protect internal or unfinished areas of a site.

When your browser requests a protected page, the server replies with a challenge. The browser then shows you a small login box, you type your username and password, and the browser resends the request with an Authorization header that carries those credentials. A header is a small piece of extra information sent along with a web request, like a label on a parcel. The server checks the credentials against a password file and lets you in if they match.

The .htpasswd file

That password file is commonly named .htpasswd. It lists usernames and, next to each one, the user's password stored as a hash. A hash is the result of running a password through a mathematical scrambling process. The point of hashing is that you cannot simply read the password back out of the hash, the way you could read a plain text file. The server hashes whatever you type and compares the result with the stored hash.

The security of the whole arrangement depends on two things: the .htpasswd file staying private, and the hashes inside it being hard to reverse.

Directory enumeration

Websites often contain files and folders that are not linked from any page. You cannot find them by clicking around. Directory enumeration is the practice of guessing common file and folder names and asking the server whether each one exists. It is like trying every door in a corridor rather than only the ones with signs on them.

Password cracking and wordlists

Cracking a hash means trying candidate passwords, hashing each one the same way the server did, and checking whether the result matches the stored hash. A wordlist is a long list of likely passwords, often built from real passwords leaked in past breaches. Trying a wordlist against a hash is called a dictionary attack. If the password is an ordinary word or a common pattern, it will usually be on such a list.

The tools used

Two tools appear in this story:

  • dirbuster, the OWASP directory and file brute-forcer, used to enumerate paths on a host. It takes a list of common names and requests each one, reporting which ones exist.
  • john (John the Ripper), a password cracking tool, used here to crack the recovered password hash. It was run with a wordlist suggested by Nico (@nijagaw): the CrackStation wordlist.

No accounts were set up in advance. The starting point was simply the ability to browse the company's public subdomains, which anyone with a browser can do.

Finding it

Step 1: Look for subdomains

The first step was to find out which subdomains the company had. The researcher used a Google dork, which is a search query written in a special way to surface things a normal search would not show. The query was:

Text
site:*.REDACTED.com -www

Line by line, this means:

  • site: tells Google to restrict results to one website.
  • *.REDACTED.com means any subdomain of the company's domain. The asterisk is a wildcard standing for any prefix.
  • -www excludes the main www host, because that is the ordinary public website and not interesting here.

The result is a list of indexed subdomains of the target. Search engines index pages they have crawled, so this is a quick way to get a picture of what a company exposes without touching its servers at all.

Step 2: Pick an interesting host

Among the results, one host stood out: admin.REDACTED.com. The word admin suggests an administrative area, which is exactly the kind of place that tends to hold sensitive things.

On review, the site itself looked unremarkable. There was nothing obviously wrong on the pages a visitor would see. So the researcher turned to dirbuster to look for files and directories that were not linked from the pages, the hidden parts of the site.

Step 3: Find the exposed password file

Just as the search was about to be abandoned, dirbuster reported a .htpasswd file returning HTTP status 200.

HTTP status codes are the server's short answers to a request. 200 means "here is the content you asked for, everything is fine". Other codes mean other things: 404 means "not found", 403 means "forbidden". A 200 on a password file is the signal that matters: the server is serving the file as ordinary content rather than denying access to it. If the server had been configured properly, the answer would have been 403 or 404.

Visiting the URL confirmed it, and the file rendered in the browser.

The rendered file showed the username us3r and a password value that was not plaintext. The username being visible was already useful. The password was still protected by a hash, so it could not simply be read.

Exploitation

Step 1: Identify the hash format

The researcher had seen Basic Authentication password files before where the value was simply Base64 encoded. Base64 is a way of turning data into text using a fixed set of characters. It is not encryption at all: anyone can decode it instantly, so a Base64 password offers no protection whatsoever.

This value did not look like Base64. After searching, the format was identified as DES (Data Encryption Standard), the traditional crypt(3) scheme used by .htpasswd files. DES is an old scrambling method. It is considered insecure today and is susceptible to theoretical attacks, but there is no trivial method for cracking it. The practical route is a dictionary or brute-force attack against the hash, which is what John the Ripper does.

Knowing the format matters because it tells you which tool and which settings to use. Feeding a hash to the wrong cracking mode wastes time and produces nothing.

Step 2: Crack the hash with John

The hash was saved to a file named pw and John was run against it with the CrackStation wordlist:

Bash
john --wordlist=/Users/Patrik/Downloads/crackstation.txt pw

Line by line:

  • john starts the John the Ripper program.
  • --wordlist=/Users/Patrik/Downloads/crackstation.txt tells it to take candidate passwords from that file, one after another. The path is simply where the wordlist happened to be saved on the researcher's own computer.
  • pw is the file containing the hash to crack.

The run loaded a single hash and identified it as descrypt, the traditional crypt(3) DES scheme:

Text
Loaded 1 password hash (descrypt, traditional crypt(3) [DES 128/128 SSE2-16])

Press 'q' or Ctrl-C to abort, almost any other key for status

0g [redacted] 5% 0g/s 3316Kp/s 3316Kc/s 3316KC/s 09554858..09554972

0g [redacted] 52% 0g/s 2953Kp/s 2953Kc/s 2953KC/s 42333281..42333395

0g [redacted] 54% 0g/s 2971Kp/s 2971Kc/s 2971KC/s 45154098..45154206

0g [redacted] 35% 0g/s 3055Kp/s 3055Kc/s 3055KC/s CFCbu..CF(CC

sasi21033******        (?)

Use the "--show" option to display all of the cracked passwords reliably

Session completed

What each part means:

  • The first line says one hash was loaded and that John recognised it as descrypt, the DES scheme. Recognising the format automatically is why the earlier identification step was useful.
  • The Press 'q' line is just an instruction for stopping the run early.
  • The progress lines are printed while John works. 0g means zero passwords have been cracked so far. The time shows how long the run has been going. The percentage shows how far through the wordlist John has got. The Kp/s figures are the speed, roughly three million candidates per second. The strings at the end are examples of the candidates currently being tried.
  • The line sasi21033****** (?) is the result: the cracked password. The remainder of the password is masked in the published output. The (?) after it is John's placeholder for the source file.
  • The --show line is a hint that John can list previously cracked results later.
  • Session completed means the run finished.

The progress lines show the wordlist being worked through at roughly three million candidates per second. The password had been recovered from the wordlist. That is the weakness of a fast hash: a modern password hash is deliberately slow, so the same wordlist run would take an impractical amount of time.

Step 3: Find where the credentials apply

The site that hosted the .htpasswd file did not itself use .htaccess protection, so the recovered credentials had no obvious use there. .htaccess is a configuration file that tells the server how to behave in a folder, including whether to require Basic Authentication. Without that protection on the admin site, the username and password did not open anything on it.

With help from @mongobug, the researcher established that the following hosts were each protected by Basic Authentication:

  • thestageingstuff.*.domain.com
  • developmentworkshere.*.domain.com
  • quark.*.domain.com
  • devsfavourite.*.domain.com

The names suggest staging and development environments. A staging environment is a copy of a site used for testing before changes go live, and a development environment is where programmers build and try things. Both tend to be less locked down than production, the live site real customers use.

The same username and password recovered from the .htpasswd file worked on every one of them. In other words, the credentials gave access to the company's development and beta environments. This is credential reuse: one secret protecting several separate places, so a single recovered password opens all of them.

Root cause

The immediate mistake is that the .htpasswd file was reachable over HTTP and returned status 200, so anyone who found the path could download it. A password file is only a defence if the server refuses to serve it. Here nothing did.

The second mistake is in what the file contained. The password was stored as a DES crypt(3) hash, a fast scheme that a wordlist attack can exhaust at millions of candidates per second. A slow, modern password hash would have made the same wordlist run impractical.

The third mistake is credential reuse. The same username and password protected several separate development and staging hosts, so a single recovered secret opened all of them. The report does not describe how those hosts were configured, so whether they shared one password file or simply one password is not stated.

Impact

An attacker who found the file, as this researcher did through directory enumeration, could download the password hashes and crack them offline.

With the recovered credentials, the researcher gained access to the company's development and beta environments across four hosts. The report does not describe what those environments contained or what further access they granted, so the impact beyond authenticated access to those hosts is not established here.

The program owner responded quickly and resolved the issue even more quickly.

Fix

The measures that address the root cause are:

  1. Stop serving .htpasswd and similar files over HTTP, for example by placing them outside the document root (the folder the web server publishes) or denying access to them at the server.
  2. Store passwords with a slow, modern hashing scheme instead of DES crypt(3), so that a wordlist attack becomes too slow to be practical.
  3. Avoid reusing one credential across multiple environments, so that a single cracked password does not open several hosts.

Variants to test

If you want to look for the same kind of problem yourself, these are the patterns worth trying. Only do this on systems you own or on programs that explicitly invite testing.

  1. Password files in the web root. Run directory enumeration against each host and watch for .htpasswd, .htaccess, backup copies and similar files returning 200. A positive result is the file rendering in the browser with usernames and hashes visible.
  2. Weak hash schemes in Basic Authentication files. When a hash is recovered, identify the scheme before assuming it is safe. A descrypt or otherwise fast hash is a candidate for a wordlist attack with John. A positive result is the password appearing in the john output.
  3. Credential reuse across environments. Take any credential recovered from one host and try it against staging, development and beta hosts found through subdomain enumeration. A positive result is a successful Basic Authentication challenge on a host you were not given credentials for.
  4. Subdomain discovery as the entry point. Start from a dork such as site:*.REDACTED.com -www to build a host list, then enumerate each host for exposed files. A positive result is an administrative or non-production host that exposes something it should not.

Glossary

  • Bug bounty program: an arrangement where a company invites independent researchers to look for security problems and pays them for reporting what they find.
  • Private program: a bug bounty program open only to invited researchers, where the company's identity is kept secret.
  • Domain: a company's main address on the internet, such as example.com.
  • Subdomain: a prefix added in front of a domain, such as admin.example.com, used to run a separate service.
  • HTTP: the protocol browsers and web servers use to exchange requests and responses.
  • HTTP status code: a short number in a server's response saying what happened, such as 200 for success, 403 for forbidden and 404 for not found.
  • Header: a small piece of extra information sent along with a web request or response.
  • Basic Authentication: a simple mechanism where a web server asks for a username and password before showing a protected page or folder.
  • Authorization header: the header a browser sends to carry the username and password during Basic Authentication.
  • .htpasswd: a password file used by Basic Authentication, listing usernames and hashed passwords.
  • .htaccess: a configuration file that tells the web server how to behave in a folder, including whether to require Basic Authentication.
  • Hash: the result of running a password through a mathematical scrambling process, designed so the original password cannot simply be read back.
  • DES (Data Encryption Standard): an old scrambling method, used in the traditional crypt(3) scheme for .htpasswd files, considered insecure today.
  • crypt(3): the traditional password hashing scheme used by .htpasswd files, identified by John as descrypt.
  • Base64: a way of turning data into text using a fixed set of characters; it is not encryption and anyone can decode it.
  • Directory enumeration: guessing common file and folder names and asking the server whether each one exists.
  • Wordlist: a long list of likely passwords, often built from real passwords leaked in past breaches.
  • Dictionary attack: trying a wordlist against a hash to recover the password.
  • Password cracking: trying candidate passwords, hashing each one, and checking whether the result matches a stored hash.
  • john (John the Ripper): a password cracking tool, used here with the CrackStation wordlist.
  • Google dork: a search query written in a special way to surface things a normal search would not show.
  • Wildcard: a symbol, here the asterisk, standing for any prefix in a search query.
  • Credential reuse: using the same username and password to protect several separate systems, so one recovered secret opens all of them.
  • Staging environment: a copy of a site used for testing before changes go live.
  • Development environment: a place where programmers build and try things, separate from the live site.
  • Production: the live site real customers use.
  • Document root: the folder a web server publishes to the internet.
  • Offline attack: cracking hashes on the attacker's own machine, with no rate limits and no alarms on the company's side.

More by Patrik Fehrenbach

View all

12 more disclosed reports, best first.

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.