Attacking Renovate Bots: A Practical Guide
This guide explains how to use Pipeleak to discover and exploit common misconfigurations in Renovate bot setups. For more background and technical details, see the full blog post.
There are two key points to understand:
-
Code Execution by Renovated Repositories
Every project renovated by the same bot must be considered equally trusted and exposed to the same attack level. If one project is compromised, all others processed by that bot can be affected. Code execution by the renovated repository in the bot context is assumed in Renovate's threat model.
-
GitLab Invite Auto-Acceptance
GitLab project invites are auto-accepted. You can invite any bot directly to your repository. If it is then renovated by the invited bot, you can compromise the bot user.
1. Enumerate Renovate Bot Usage
Use the enum
command to scan your GitLab instance for Renovate bot jobs and configuration files. This is useful for:
- Identify Renovate configurations
- Finding projects with vulnerable Renovate bot configurations
- Collecting config files for further analysis
For example, we enumerated Renovate configs found on GitLab.com. One project was found that enables Renovate's autodiscovery of projects and does not set any autodiscovery filters.
This makes the bot susceptible to autodiscovery exploits, since it will renovate any repository it can access.
Even when autodiscovery filters are enabled, weak or poorly written filter regexes can still allow attackers to bypass them and exploit the bot.
2. Exploit Autodiscovery with a Malicious Project
The Renovate bot from the example above is configured to autodiscover new projects and does not apply any, or only weak, bypassable filters. You can create a repository with a malicious script that gets executed by the bot.
The following command creates a repository that includes an exploit script called exploit.sh
. Whenever a Renovate bot picks up this repo, the script will be executed.
First, set up the exploit.sh
script according to your needs. The goal is to read the Renovate process environment variables and exfiltrate them to your attacker server.
On your attacker server, start a GoShs server to accept the environment files from the Renovate process.
Next, identify the bot user and invite it to your repository. By looking at the Renovate bot configuration, you can identify the renovated repos and check the username of the bot user in the merge requests created by that bot.
Such a merge request can look like this. Below the title, you see the bot's username renovate_runner
.
Invite that user to your repository with developer
access. Now, wait until the bot is triggered next. After it has run, you can find the environment file on your GoShs server.
In that file, extract all sensitive environment variables and use them for lateral movement. Most interesting is probably the RENOVATE_TOKEN
, as it might contain a GitLab PAT. You can then enumerate the access of that PAT using Pipeleak's features.
After receiving a merge request from the Renovate bot, you must fully delete both the branch and the merge request. This ensures the bot will recreate them, allowing your script to run again. Otherwise, the script will not be executed a second time. Ensure to revert the commits as well if they were merged.
3. Privilege Escalation via Renovate Bot Branches
In this scenario, assume you already have access to a repository, but only with developer permissions. You want to gain access to the CI/CD variables configured for deployments. However, you cannot directly access these, as they are only provided to pipeline runs on protected branches like the main branch.
Fortunately, the project is using Renovate and the bot is configured to auto-merge after tests pass in the merge request created by the bot. Thus, the bot has maintainer access to the repository.
Your goal is to abuse the Renovate bot's access level to merge a malicious gitlab-ci.yml
file into the main branch, effectively bypassing a review by other project maintainers. On the main branch, you can then steal the exposed environment variables used for deployments.
Using Pipeleak, you can monitor your repository for new Renovate branches. When a new one is detected, Pipeleak tries to add a new job into the gitlab-ci.yml
. As this needs to exploit a race condition (adding new changes to the Renovate branch before the bot activates auto-merge), this might take a few attempts.
Manually check if the merge request has been set to auto-merge, and see if your changes land in the main branch. If they do, you have successfully injected a CI/CD job into the protected branch. From there, leak all the credentials and continue your attack path.