Skip to content
Info disclosure Write-up Beginner

eBay Source Code leak

The production web server for eBay Japan exposed its .git version control directory, allowing anyone to download the repository. The author retrieved roughly 700 MB of compressed data containing the site's source code, WordPress configuration files with hashed backend credentials, and production database passwords.

David Follow

Published on slashcrypto.org

Today I wanna write about a finding I discovered during a research project where the aim was to find critical vulnerabilities in Alexa Top 1 Million websites. The main focus was to discover common configuration issues which do not require sophisticated exploits, which are easy to find and which can have a high impact…

David (@slashcrypto), on slashcrypto.org

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

Context

During a research project aimed at finding critical vulnerabilities in the Alexa Top 1 Million websites, I looked for common configuration issues that do not require sophisticated exploits, are easy to find and can have a high impact on a business. Some of the results were presented at ITSECX 2018, an Austrian IT-Security conference.

One of the findings was on www.ebay.co.jp, eBay Japan. The site ran a version control repository on its production web server, and the .git folder in the webroot directory was reachable. That gave access to the entire source code of the site, including database passwords and much more. The approach builds on research first performed in 2015 by internetwache.org, whose post on downloading websites' source code through exposed .git folders is worth reading.

Setup

The work needed no account on the target and no special role: the only precondition was that the .git directory of the site be served by the web server. The tooling was the GitTools published by internetwache.org, run against millions of Alexa Top 1 Million subdomains. www.ebay.co.jp was in scope of eBay's bug bounty program.

Finding it

After running the GitTools script across the Alexa Top 1 Million subdomains, I checked the results and eBay Japan popped up. To verify the bug initially, I accessed the HEAD file of the repository directly:

The response to that request was a strong indicator that the website was actually vulnerable.

eBay leaks git repo
eBay leaks git repo From the original on slashcrypto.org

The screenshot shows the response from www.ebay.co.jp/.git/HEAD, a strong indicator that the repository metadata was publicly served.

Exploitation

Step 1: Confirm the exposed repository

Requesting www.ebay.co.jp/.git/HEAD returned a response that was a strong indicator the site was vulnerable. A web server that serves the contents of a .git directory lets anyone read the files Git uses to track the repository, which is enough to start reconstructing it.

Step 2: Dump the source code

Because eBay runs a bug bounty program and www.ebay.co.jp is in scope, I dumped the source code using the GitTools scripts. While waiting for the download to finish I reported the issue to eBay.

The download produced about 700 MB of compressed data. After extracting, there was 1.2 GB of data to go through. The data set contained:

  • WordPress configuration files (yes, they use WordPress), including hashed user credentials for the backend login
  • Database passwords for production databases
  • Log files
  • A lot of PHP source code
  • much more

Step 3: Report and fix

eBay was very responsive and fixed the issue about 10 to 12 hours after I reported it. There were no cash rewards for valid bugs, but I was added to eBay's Hall of Fame.

Root cause

The web server served the .git directory that sat in the webroot of the production site. Git keeps the full history and object store under that directory, so exposing it lets a client fetch the repository's objects and rebuild the working tree, including files that are not linked from any page. The report does not describe the server configuration that allowed this; .

Impact

Anyone who could reach www.ebay.co.jp could download the site's source code. In this case the data set included WordPress configuration files with hashed credentials for the backend login, database passwords for production databases, log files and a large amount of PHP source. The report does not state whether any of these credentials were used or whether the data was accessed by anyone else.

Fix

eBay fixed the issue about 10 to 12 hours after the report.

Variants to test

  • Request /.git/HEAD on other hosts and subdomains. A positive result is a response containing a Git ref such as a branch name, instead of a 404 or a generic error page.
  • Run the GitTools scripts against a list of in-scope hosts to detect and then dump exposed repositories. A positive result is a reconstructed working tree containing configuration files, credentials or source code.
  • Check other version control metadata directories in the webroot, such as .svn or .hg, in the same way. A positive result is any file from those directories being served.
  • Look for backup and archive files left next to the application. A positive result is a downloadable archive or configuration file that the site does not intend to publish.

Update 29.11.2018

eBay employees donated $500 to charity.

From the original on slashcrypto.org

The image relates to the charity donation update.

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

What happened, in plain words

A security researcher was running a project that scanned a very large list of popular websites (the Alexa Top 1 Million) looking for simple, common mistakes in how those sites were set up. One of the sites that turned up was eBay Japan, at www.ebay.co.jp. That site was letting anyone on the internet download a hidden folder called .git, which is where a piece of software called Git keeps a copy of a website's source code and its history. Because that folder was reachable, the researcher could download the whole source code of the site, including database passwords and other sensitive material. He reported it to eBay, and eBay fixed it within about 10 to 12 hours. There was no cash reward, but he was added to eBay's Hall of Fame, and eBay employees later donated $500 to charity.

This article walks through the same story step by step, explaining each idea from scratch, so you can follow it even if you have never done any security work before.

Background: what the researcher was looking for

The researcher's project had a clear goal: find critical vulnerabilities in the Alexa Top 1 Million websites. "Alexa Top 1 Million" is a public list of the most visited websites in the world, ranked by traffic. "Critical vulnerabilities" means security holes serious enough to cause real harm to a business.

The important part is what kind of holes he was hunting for. He was not looking for clever, complicated attacks. He was looking for common configuration issues: simple setup mistakes that are easy to find and can still have a high impact on a business. Think of it like checking whether people left their front door unlocked, rather than picking the lock. Some of the results of this research were presented at ITSECX 2018, an Austrian IT-Security conference.

One of the findings was on www.ebay.co.jp, the eBay website for Japan. The site was running a version control repository on its production web server, and the .git folder in the webroot directory was reachable from the internet. That gave access to the entire source code of the site, including database passwords and much more.

A few of those terms need unpacking before the story makes sense:

  • Source code is the text that programmers write to build a website. It is the recipe, not the meal. Normally visitors only ever see the finished pages, never the recipe.
  • Version control is a system for keeping track of every change made to a set of files over time, so you can see what changed, when, and by whom, and go back to an older version if needed. Git is the most widely used version control system.
  • A repository (often shortened to "repo") is the collection of files plus all that history that Git manages. When you use Git, it stores its bookkeeping in a hidden folder named .git inside the project folder.
  • The webroot is the folder on a web server whose contents are published to the internet. If a file sits in the webroot, anyone who knows its address can usually fetch it.
  • Production means the live system that real customers use, as opposed to a test or development copy.

The approach builds on research first performed in 2015 by internetwache.org. Their blog post about downloading websites' source code through exposed .git folders is worth reading, and the researcher recommends it.

Setup: what was needed to start

The work needed no account on the target and no special role. The only precondition was that the .git directory of the site be served by the web server. In other words, the researcher did not need to log in, register, or be an employee. He just needed the server to hand out files from that folder to anyone who asked.

The tooling was the GitTools published by internetwache.org, run against millions of Alexa Top 1 Million subdomains. A subdomain is a smaller name under a main domain: www.ebay.co.jp is a subdomain of ebay.co.jp. Scanning millions of subdomains means asking each one a simple question and noting which ones answer in an interesting way.

www.ebay.co.jp was in scope of eBay's bug bounty program. A bug bounty program is a scheme where a company invites outside researchers to report security problems, usually with rules about which systems are fair game (the "scope") and sometimes with rewards.

Finding it

After running the GitTools script across the Alexa Top 1 Million subdomains, the researcher checked the results and eBay Japan popped up. To verify the bug initially, he accessed the HEAD file of the repository directly:

This is a raw HTTP request, the same kind of message your browser sends whenever it loads a page. Reading it line by line:

  • GET /.git/HEAD HTTP/1.1 is the request line. GET means "please give me this file". /.git/HEAD is the path being asked for: the file named HEAD inside the hidden .git folder. HTTP/1.1 is the version of the web protocol being used.
  • Host: www.ebay.co.jp tells the server which website the request is for. One server can host many sites, so this line says which one is meant.

Why ask for HEAD specifically? In a Git repository, HEAD is a small file that records which branch or commit you are currently on. It is a reliable, tiny test: if the server returns that file, the .git folder is being published. If the folder were properly protected, the server would answer with a 404 ("not found") or an error page instead.

The response to that request was a strong indicator that the website was actually vulnerable.

eBay leaks git repo
eBay leaks git repo From the original on slashcrypto.org

The screenshot shows the response from www.ebay.co.jp/.git/HEAD, a strong indicator that the repository metadata was publicly served.

Exploitation

Step 1: Confirm the exposed repository

Requesting www.ebay.co.jp/.git/HEAD returned a response that was a strong indicator the site was vulnerable. A web server that serves the contents of a .git directory lets anyone read the files Git uses to track the repository, which is enough to start reconstructing it.

Why is that enough? Git does not store your project as one neat archive. It stores many small files, called objects, plus index files that describe how they fit together. If an attacker can read those files one by one, they can reassemble the project. It is a bit like finding that a warehouse's inventory lists and individual boxes are all left on the pavement: nobody handed you the finished product, but you can rebuild it yourself.

Step 2: Dump the source code

Because eBay runs a bug bounty program and www.ebay.co.jp is in scope, the researcher dumped the source code using the GitTools scripts. "Dumping" here simply means downloading a copy of everything. While waiting for the download to finish, he reported the issue to eBay. Reporting early is a courtesy: the sooner the owner knows, the sooner they can close the hole.

The download produced about 700 MB of compressed data. After extracting, there was 1.2 GB of data to go through. "Compressed" means packed into a smaller file, like vacuum-sealing clothes for a suitcase; "extracting" means unpacking it back to full size, which is why 700 MB became 1.2 GB.

The data set contained:

  • WordPress configuration files (yes, they use WordPress), including hashed user credentials for the backend login
  • Database passwords for production databases
  • Log files
  • A lot of PHP source code
  • much more

Some of these deserve a plain explanation:

  • WordPress is a very popular software package for building websites. Its configuration files hold the settings the site needs to run.
  • Hashed user credentials: a hash is the result of scrambling a password with a one-way mathematical function. You cannot simply unscramble it, but weak passwords can still be guessed by trying candidates and comparing the results. So hashed passwords are safer than plain ones, but still sensitive.
  • Backend login is the private administration area of a site, where staff manage content and settings. It is not the public-facing pages.
  • Database passwords are the keys that let the website talk to its database, the store where content and user records live. With those keys, someone could potentially read or change data directly.
  • Log files are records of what happened on the server, which can reveal internal details.
  • PHP is a programming language commonly used to build websites.

Step 3: Report and fix

eBay was very responsive and fixed the issue about 10 to 12 hours after the report. There were no cash rewards for valid bugs, but the researcher was added to eBay's Hall of Fame, a public page that thanks security researchers for their reports.

Root cause

The web server served the .git directory that sat in the webroot of the production site. Git keeps the full history and object store under that directory, so exposing it lets a client fetch the repository's objects and rebuild the working tree, including files that are not linked from any page.

"Working tree" means the normal, editable set of project files as you would see them in a folder. The point is that the leak was not limited to pages the site linked to; it covered the project's files as a whole. The report does not describe the server configuration that allowed this; . A dot-directory is simply a folder whose name starts with a dot, like .git; such folders are often hidden from casual view but are still perfectly readable if a server hands them out.

Impact

Anyone who could reach www.ebay.co.jp could download the site's source code. In this case the data set included WordPress configuration files with hashed credentials for the backend login, database passwords for production databases, log files and a large amount of PHP source. The report does not state whether any of these credentials were used or whether the data was accessed by anyone else.

Fix

eBay fixed the issue about 10 to 12 hours after the report.

Variants to test

If you want to look for the same class of mistake on systems you are allowed to test, these are checks for the same class of mistake:

  • Request /.git/HEAD on other hosts and subdomains. A positive result is a response containing a Git ref such as a branch name, instead of a 404 or a generic error page. A branch is a named line of development in Git, for example the main version of the project.
  • Run the GitTools scripts against a list of in-scope hosts to detect and then dump exposed repositories. A positive result is a reconstructed working tree containing configuration files, credentials or source code.
  • Check other version control metadata directories in the webroot, such as .svn or .hg, in the same way. A positive result is any file from those directories being served. .svn belongs to Subversion and .hg to Mercurial, two other version control systems that keep their own hidden folders.
  • Look for backup and archive files left next to the application. A positive result is a downloadable archive or configuration file that the site does not intend to publish. A backup is a spare copy made for safety; if it is left where the public can reach it, it can leak the same secrets as the live files.

Update 29.11.2018

eBay employees donated $500 to charity.

From the original on slashcrypto.org

The image relates to the charity donation update.

Glossary

  • Alexa Top 1 Million: a public ranking of the most visited websites, often used as a sample list for research.
  • Backend login: the private administration area of a website, used by staff rather than visitors.
  • Branch: a named line of development in Git, such as the main version of a project.
  • Bug bounty program: a scheme where a company invites outside researchers to report security problems, with rules about which systems are in scope and sometimes rewards.
  • Compressed data: files packed into a smaller size for transfer or storage, which must be extracted to be used.
  • Configuration file: a file holding the settings a piece of software needs to run, often including secrets such as passwords.
  • Database: the store where a website keeps its content and records.
  • Database password: the credential a website uses to connect to its database.
  • Dot-directory: a folder whose name starts with a dot, such as .git, often hidden from casual view but readable if served.
  • Extracting: unpacking compressed data back to its full size.
  • Git: the most widely used version control system, which keeps project files and their history in a hidden .git folder.
  • GitTools: scripts published by internetwache.org for detecting and downloading exposed Git repositories.
  • Hash: the result of scrambling a value such as a password with a one-way function; it cannot simply be reversed, but weak inputs can be guessed.
  • HEAD: a small file in a Git repository recording which branch or commit is currently checked out; useful as a quick test for an exposed repository.
  • HTTP request: the message a browser or tool sends to a web server to ask for a file or page.
  • Log file: a record of events on a server, which can reveal internal details.
  • PHP: a programming language commonly used to build websites.
  • Production: the live system that real customers use, as opposed to a test copy.
  • Repository: the collection of project files plus their full history managed by a version control system.
  • Scope: the set of systems a bug bounty program declares fair game for testing.
  • Source code: the text programmers write to build a website, normally not visible to visitors.
  • Subdomain: a smaller name under a main domain, such as www.ebay.co.jp under ebay.co.jp.
  • Version control: a system for tracking every change to a set of files over time.
  • Webroot: the folder on a web server whose contents are published to the internet.
  • WordPress: a very popular software package for building websites.
  • Working tree: the normal set of project files as they appear in a folder, which can be rebuilt from a repository's stored objects.

More from Ebay

View all

The newest disclosed reports for this program.

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.