Skip to content
Info disclosure Write-up Beginner

#BugBounty — How I was able to download the Source Code of India’s Largest Telecom Service Provider including dozens of more popular websites!

A publicly exposed .git directory on a subdomain allowed the attacker to download the complete Git repository, including the source code of the website. The attacker automated subdomain enumeration and .git directory checking across many companies, finding dozens of exposed repositories including that of India's largest telecom service provider.

Avinash Jain Follow

Published on medium.com

#### Avinash Jain (@logicbomb1)

Avinash Jain (@logicbomb_1), 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 is about a widespread misconfiguration rather than a single application bug: a web server that serves its .git directory to anyone who asks. Git is a version control system for tracking changes in files and coordinating work on them among multiple people. It is used mainly for source code management, but it can track changes in any set of files, and it manages versions through forks and branches.

When a web server is misconfigured so that its .git directory is publicly exposed, the repository metadata stays reachable over HTTP. The researcher set out to find such exposures across companies with public or private bug bounty programmes and responsible disclosure policies. The result, as described, was the complete .git folder of dozens of companies, including that of India's largest telecom service provider, from which he escalated to the complete source code of their website. Some of the affected organisations had the leak on their main domain, others on a subdomain.

Setup

The work needed no accounts or special roles on the targets. The only precondition was that a target served its .git directory publicly. The tooling was:

  • Sublist3r, an open source subdomain enumeration tool that collects subdomains of a parent domain from various sources and outputs a list.
  • Git-dumper, a tool that checks whether a .git directory is being indexed and then downloads it.
  • wget, used to recursively mirror the directory.
  • A custom script, git-domain.py, built by merging the code of the two tools above with small changes.

The researcher also points readers to two references on the technique: the Internetwache analysis of Git exposure across Alexa's top 1M sites, and the Netspi article on dumping Git data from misconfigured web servers.

Finding it

The starting point was a news story about a Snapchat source code leak, where a hacker downloaded the complete source code of the website and published it on GitHub. The researcher frames the underlying problem as a misconfiguration that has been exploited heavily: inexperienced developers inadvertently leave key components of their Git repositories publicly accessible, potentially giving anyone access to sensitive source code, access keys, passwords and more.

A misconfigured, publicly exposed Git directory looks like this:

Image for post
Git directory exposed From the original on medium.com

Git directory exposed

The reasoning that shaped the search was that subdomains matter as much as the main domain, and that Git misconfiguration is not limited to the main domain. So the plan combined subdomain enumeration with .git folder download: enumerate every subdomain of a parent domain, then test each one for an exposed repository.

Exploitation

Step 1: Download the exposed repository

Once a .git directory is confirmed to be exposed, the whole repository can be mirrored recursively. The command given in the report is:

Bash
wget –r https://www.example.com/.git

The -r flag makes wget recurse through the directory, pulling every file under .git. With the complete folder on disk, a little Git command line knowledge is enough to fetch the Git objects and reconstruct the working tree.

Step 2: Automate enumeration and download

The researcher merged Sublist3r and Git-dumper into git-domain.py, which does three things:

  1. It expects an input file containing a list of main domains, one per line.
  2. It traverses each domain line by line, finds its subdomains, and checks each subdomain for a publicly exposed .git directory.
  3. If one is found, it recursively downloads the complete Git folder of that subdomain and saves it in a folder.

Step 3: Run it against a prepared target list

A list was prepared of large, medium and small scaled popular companies that have public or private bug bounty programmes or responsible disclosure policies, and fed to the script:

Image for post
Git directory check on each subdomain of the main domain From the original on medium.com

Git directory check on each subdomain of the main domain

The output was the complete Git folder of dozens of companies with a misconfigured Git directory, including India's largest telecom service provider.

Step 4: Recover the source code

From the downloaded folders the researcher escalated to the complete source code of the affected websites. The report shows the downloaded Git directory files and the resulting source code access:

Git directory files

Source code access

Root cause

The mistake is deployment and server configuration, not application logic: the .git directory is left inside the web root and the web server is allowed to serve it, including directory indexing. Because the repository metadata contains the objects needed to rebuild the project, anyone who can fetch the folder can reconstruct the source. The report does not describe any defence that was in place and failed.

Impact

Anyone on the internet, with no authentication, could download the repository of any affected host and recover its source code. The researcher notes that such repositories can also expose access keys and passwords. The affected parties were dozens of companies, some on their main domain and some on a subdomain, and the report names only the largest: India's largest telecom service provider, whose complete website source code was obtained. The report does not give a bounty amount or a severity rating.

Fix

The report's mitigation is for web server administrators and developers: make sure the .git directory is not indexed and that the directory, its subdirectories and all files are inaccessible through server permission rules. The .gitignore file should be used so that sensitive files are properly ignored and not mistakenly added. The simplest mitigation is to deny access to .git folders outright:

Text
<DirectoryMatch “^/.*/\.git/”>

Require all denied

</DirectoryMatch>

Variants to test

  • Other version control metadata. Request /.svn/, /.hg/ and /.bzr/ on the same hosts. A positive result is a directory listing or a fetchable metadata file such as entries or wc.db.
  • Backup and archive files next to the web root. Try common names such as backup.zip, www.zip or site.tar.gz. A positive result is a downloadable archive whose contents match the deployed application.
  • Subdomains of the same organisation. Run the enumeration and check on every subdomain, not just the apex, since the report found the misconfiguration on both. A positive result is a /.git/HEAD that returns a ref rather than a 404.
  • Non-indexed but readable .git. Even when directory listing is off, request known paths such as /.git/config and /.git/HEAD. A positive result is a 200 with repository content, which still allows reconstruction with a dumper.
  • Deployment artefacts. Look for .env, .DS_Store and CI configuration files in the web root. A positive result is a readable file containing credentials or build details.

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

What happened, in plain words

A security researcher found that dozens of companies had left a hidden folder called .git sitting on their public websites, where anyone with a browser could reach it. That folder is part of how developers keep track of their code, and it contains enough information to rebuild the entire source code of the website. Among the affected organisations was India's largest telecom service provider, whose complete website source code the researcher was able to download. Some companies had the problem on their main website address, others on a subdomain.

The report does not give a bounty amount or a severity rating. It is a story about a widespread configuration mistake, not a single clever bug in one application.

Background: what Git is and why its folder matters

Git is a version control system. In everyday terms, think of it as a very detailed undo history for a folder of files. Every time a developer saves a change, Git records what changed, when, and by whom. It also lets several people work on the same project at once and merge their work together. The report describes it like this: Git tracks changes in computer files and coordinates work on those files among multiple people. It is used mainly for source code management, but it can track changes in any set of files, and it manages versions through forks and branches.

When a web server is misconfigured, the .git folder inside the published folder can be served to visitors. The .git folder is normally hidden from view, but hidden is not the same as protected. If the web server is not told to refuse requests for it, anyone who knows the address can ask for it and get it.

That is the whole vulnerability class here: a publicly reachable .git directory. There is no trick in the application's login, no broken password check, no clever injection. The server simply hands out a folder it should never have served.

How the researcher got the idea

The starting point was a news story about a Snapchat source code leak, in which a hacker downloaded the complete source code of the website and published it on GitHub. The researcher frames the underlying problem as a misconfiguration that has been exploited heavily: inexperienced developers inadvertently leave key components of their Git repositories publicly accessible, potentially giving anyone access to sensitive source code, access keys, passwords and more.

So the plan was to go looking for the same mistake at scale, across companies that run bug bounty programmes or responsible disclosure policies. A bug bounty programme is a scheme where a company invites outside people to report security problems in exchange for recognition or a reward. A responsible disclosure policy is a lighter version of the same idea: a published route for reporting a problem.

What an exposed Git directory looks like

If an application has a misconfigured Git directory that is exposed publicly, the directory will look something like this:

Image for post
Git directory exposed From the original on medium.com

Git directory exposed

What you are seeing in that screenshot is a web page listing the contents of the folder, the way a shop might leave its stockroom door open with the shelves visible from the street. When a web server is configured to show a directory listing, a visitor who requests a folder gets an index of the files inside it instead of an error. That listing is the first sign that the folder is reachable. Even without a listing, the files can often still be fetched one by one if you know their names.

The tools used

The work needed no accounts or special roles on the targets. The only precondition was that a target served its .git directory publicly. The tooling was:

  • Sublist3r, an open source subdomain enumeration tool that collects subdomains of a parent domain from various sources and outputs a list.
  • Git-dumper, a tool that checks whether a .git directory is being indexed and then downloads it.
  • wget, used to recursively mirror the directory.
  • A custom script, git-domain.py, built by merging the code of the two tools above with small changes.

A few of those words need unpacking for a newcomer.

A domain is the main address of a site, for example example.com. A subdomain is a prefix on that address, for example shop.example.com or mail.example.com. Companies often run many subdomains, one per service, and each one is a separate web server that can have its own configuration mistakes. That is why the researcher did not only look at the main domain.

Subdomain enumeration means finding out which subdomains exist for a given domain. You cannot guess them all by hand, so a tool collects them from public sources such as certificate records and search engines.

wget is a command line program that downloads files from the web. It is the command line equivalent of right clicking a link and choosing save, except it can follow links automatically and download a whole folder tree in one go.

Git-dumper is a small program written for exactly this situation: it checks whether a .git folder is reachable and, if so, downloads it.

The researcher also points readers to two references on the technique: the Internetwache analysis of Git exposure across Alexa's top 1M sites, and the Netspi article on dumping Git data from misconfigured web servers. Those are background reading for anyone who wants to understand Git commands before trying this.

Step 1: Download the exposed repository

Once a .git directory is confirmed to be exposed, the whole repository can be mirrored recursively. The command given in the report is:

Bash
wget –r https://www.example.com/.git

Line by line, in plain words:

  • wget is the program being run. It fetches things from the web.
  • –r tells wget to recurse, meaning to follow every link it finds inside the folder and download those files too, and then the files inside those, and so on. Without it, wget would download only the single page at that address.
  • https://www.example.com/.git is the address being downloaded. example.com is a placeholder name used in documentation; the real target would be the company's own address. The /.git at the end is the path of the hidden folder on the server.

The reason for this step is simple: the .git folder is not one file, it is a tree of many files. Downloading it by hand, one click at a time, would be slow and error prone. Recursion turns that into a single command.

With the complete folder on disk, a little Git command line knowledge is enough to fetch the Git objects and reconstruct the working tree. In plain terms: the .git folder stores the project's history in a compressed internal format. Git itself knows how to read that format. So once you have the folder, you run ordinary Git commands against it and Git rebuilds the actual source files for you, as if you had cloned the project from the developer's machine.

Step 2: Automate enumeration and download

Doing this by hand for one site is easy. Doing it for many companies, each with many subdomains, is not. So the researcher merged Sublist3r and Git-dumper into a single script, git-domain.py, which does three things:

  1. It expects an input file containing a list of main domains, one per line.
  2. It traverses each domain line by line, finds its subdomains, and checks each subdomain for a publicly exposed .git directory.
  3. If one is found, it recursively downloads the complete Git folder of that subdomain and saves it in a folder.

Why each step matters:

  1. The input file is the shopping list. You write down the companies you are allowed to test, one domain per line, and the script works through them without you typing anything again.
  2. The traversal is the part that catches the mistakes people miss. A company might secure its main website and forget a forgotten test server on a subdomain. Checking every subdomain is how you find those.
  3. The download is the payoff. Each hit is saved into its own folder so the results do not mix together and can be examined later.

Step 3: Run it against a prepared target list

A list was prepared of large, medium and small scaled popular companies that have public or private bug bounty programmes or responsible disclosure policies, and fed to the script:

Image for post
Git directory check on each subdomain of the main domain From the original on medium.com

Git directory check on each subdomain of the main domain

The second screenshot shows the check being performed on each subdomain of the main domain.

The output was the complete Git folder of dozens of companies with a misconfigured Git directory, including India's largest telecom service provider.

Step 4: Recover the source code

From the downloaded folders the researcher escalated to the complete source code of the affected websites. The report shows the downloaded Git directory files and the resulting source code access:

Git directory files

Source code access

The first screenshot shows the files that make up the downloaded Git directory. The second shows the source code that came out of them. This is the moment the misconfiguration turns into a real leak: the folder that looked like harmless plumbing turns out to contain the actual code the website runs on.

Why this happens

The mistake is deployment and server configuration, not application logic. The .git directory is left inside the web root, meaning the folder that the web server publishes to the internet, and the web server is allowed to serve it, including directory indexing. Because the repository metadata contains the objects needed to rebuild the project, anyone who can fetch the folder can reconstruct the source.

The report does not describe any defence that was in place and failed. In everyday terms, it is like leaving the key to the stockroom on the shop counter: nothing was broken, the door was just never locked.

What the impact was

Anyone on the internet, with no authentication, could download the repository of any affected host and recover its source code. No login, no special tool, no insider knowledge was required beyond knowing the address.

The researcher notes that such repositories can also expose access keys and passwords. That matters because source code often contains configuration values that were never meant to be public, such as the credentials a website uses to talk to its database or to other services.

The affected parties were dozens of companies, some on their main domain and some on a subdomain, and the report names only the largest: India's largest telecom service provider, whose complete website source code was obtained.

How to fix it

The report's mitigation is for web server administrators and developers: make sure the .git directory is not indexed and that the directory, its subdirectories and all files are inaccessible through server permission rules. The .gitignore file should be used so that sensitive files are properly ignored and not mistakenly added. The simplest mitigation is to deny access to .git folders outright:

Text
<DirectoryMatch “^/.*/\.git/”>

Require all denied

</DirectoryMatch>

Line by line, in plain words:

  • <DirectoryMatch “^/.*/\.git/”> is a rule that matches any folder whose path ends in .git. The pattern is a regular expression, which is a way of describing a set of names rather than listing them one by one. The ^ means start of the path, .* means any characters, and \.git/ means the literal text .git/.
  • Require all denied is the instruction: refuse every request that matches the rule, from anyone, for any reason.
  • </DirectoryMatch> closes the rule.

The folder can stay on disk; it just cannot be reached from the internet. The .gitignore advice is a second layer: it stops developers from accidentally adding sensitive files to the repository in the first place, so that even if the folder leaks, there is less inside it worth having.

Other things worth checking

Once you know the pattern, the same idea applies to other leftovers that developers commonly leave in the web root:

  • Other version control metadata. Request /.svn/, /.hg/ and /.bzr/ on the same hosts. These are the equivalent folders for other version control systems. A positive result is a directory listing or a fetchable metadata file such as entries or wc.db.
  • Backup and archive files next to the web root. Try common names such as backup.zip, www.zip or site.tar.gz. A positive result is a downloadable archive whose contents match the deployed application.
  • Subdomains of the same organisation. Run the enumeration and check on every subdomain, not just the apex, since the report found the misconfiguration on both. A positive result is a /.git/HEAD that returns a ref rather than a 404. HEAD is a small file inside .git that points at the current branch; a 404 is the standard web response for not found.
  • Non-indexed but readable .git. Even when directory listing is off, request known paths such as /.git/config and /.git/HEAD. A positive result is a 200 with repository content, which still allows reconstruction with a dumper. A 200 is the standard web response for success.
  • Deployment artefacts. Look for .env, .DS_Store and CI configuration files in the web root. A positive result is a readable file containing credentials or build details. .env files commonly hold configuration values such as database passwords.

Glossary

  • Bug bounty programme: a scheme where a company invites outside researchers to report security problems, usually in exchange for recognition or a reward.
  • Responsible disclosure policy: a published route for reporting a security problem to a company, without a reward scheme attached.
  • Git: a version control system that records changes to files over time and lets several people work on the same project.
  • Version control system (VCS): software that tracks the history of changes to a set of files.
  • Repository: the collection of files plus the full history of changes, stored by Git.
  • .git directory: the hidden folder inside a project where Git keeps its history and metadata.
  • Fork: a copy of a project that can be developed separately.
  • Branch: a parallel line of development inside a repository.
  • Web root: the folder on a server that the web server publishes to the internet.
  • Directory indexing / directory listing: a web server feature that shows the contents of a folder as a web page when no specific file is requested.
  • Domain: the main address of a website, such as example.com.
  • Subdomain: a prefix on a domain, such as shop.example.com, usually a separate service on a separate server.
  • Subdomain enumeration: the process of discovering which subdomains exist for a domain.
  • Sublist3r: an open source tool that collects subdomains of a parent domain from various sources and outputs a list.
  • wget: a command line program that downloads files from the web, optionally following links recursively.
  • Recursive download: downloading a folder and everything inside it, following links automatically.
  • Git object: the internal stored form of a file or change inside a .git folder.
  • Working tree: the actual files of a project as they appear on disk, as opposed to the history stored in .git.
  • Authentication: proving who you are, usually with a login.
  • Access key / credential: a secret value, such as a password or API key, used to gain access to a system.
  • API key: a secret string that identifies a program to a service, similar to a password for software.
  • HTTP status code: a number a web server returns with each response, such as 200 for success or 404 for not found.
  • HEAD: a small file inside .git that points at the current branch.
  • Regular expression: a pattern that describes a set of text strings, used in rules and searches.
  • .gitignore: a file that tells Git which files should not be added to the repository.
  • .env file: a configuration file commonly used to store settings and secrets such as database passwords.
  • .DS_Store: a file created by macOS in folders to store view settings; it can reveal file names.
  • CI configuration file: a file that describes how a project is automatically built and tested.
  • Apex domain: the main domain itself, without any subdomain prefix.
  • Severity rating: a score or label describing how serious a vulnerability is.
  • CVSS: a standard scoring system for the severity of security vulnerabilities.

More by Avinash Jain

View all

29 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.