Open Build Service, one year later: command execution through Mercurial argument injection
The obs_scm service passed a user-controlled revision value to Mercurial's update command without a separator, so a revision beginning with a dash was parsed as an option. An attacker could use Mercurial's --config option to set a pre-update hook and run arbitrary shell commands on the OBS source service server.
fenrisk.com
Published on fenrisk.com
In March 2025 we published an analysis of a remote code execution vulnerability in Open Build Service (OBS), tracked as CVE-2024-22033. A little over a year later we went back to the same attack surface and found a second, distinct flaw of the same family.
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
Root cause
User-controlled revision data was appended to a command line without a `--` separator, so Mercurial interpreted a dash-leading value as an option.
Impact
A plain commit with a valid _service file could yield command execution on the OBS source service server, and an attacker who compromised that server could push malicious packages or modify legitimate packages, potentially compromising openSUSE users.
What the attacker needed
Mercurial installed on the service server; scm set to hg in the _service file; url uses an http(s) scheme; url points to a real clonable Mercurial repository
The fix
The fix was to insert a `--` separator between the update subcommand and the revision, and to reject revision values beginning with a dash as defence in depth.
How it was found
- Create a package with a _service file that uses the obs_scm service and sets scm to hg.
- Set the url parameter to a real, clonable Mercurial repository over http(s).
- Set the revision parameter to a value beginning with a dash that contains a space, so it passes argparse and is read by Mercurial as the --config option.
- Commit the package so the service runs server-side and the injected option reaches hg update.
- The pre-update hook runs the attacker's shell command on the service server.
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.
Open Build Service (OBS) is a system that builds software packages from source code. A small configuration file in each package tells OBS which helper programs to run, and one helper clones source code from repositories such as Mercurial. The helper passed a value from that file to Mercurial without marking it as plain data, so a value starting with a dash was treated as an extra command-line option. Mercurial has an option that can run a shell command, so the attacker's value caused their command to run on the build server.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.