RCE via GitHub import
GitLab's GitHub import feature used the Sawyer library to convert attacker-controlled JSON responses into Ruby objects, allowing injection of Redis commands. An attacker could execute arbitrary Redis commands and potentially escalate to remote code execution on the GitLab server.
gitlab.com
Published on gitlab.com
Report | Attachments | How To Reproduce
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.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Impact
An attacker with the ability to call the import endpoint could achieve remote code execution on the GitLab server, though on gitlab.com the attacker only confirmed Redis replication control and did not achieve full RCE.
What the attacker needed
Ability to call api/v4/import/github; A GitLab personal access token with api scope; A server to host malicious GitHub API responses
How it was found
- Set up a dummy server that mimics GitHub's API and returns malicious responses.
- Create a GitLab personal access token with API scope.
- Send a POST request to GitLab's GitHub import endpoint, specifying the dummy server as the GitHub hostname.
- The import process triggers Redis command injection, leading to command execution.
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 write-up has not been written yet. The Original tab links to the source.
GitLab can import projects from GitHub. When it does, it asks GitHub for information and trusts the reply. The attacker made a fake GitHub server that sent a specially crafted reply, which tricked GitLab into running extra commands on its own database (Redis). That could let the attacker run commands on the server.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.