CVE-2021-21251

7.7 HIGH

📋 TL;DR

CVE-2021-21251 is a path traversal vulnerability in OneDev's TarUtils library that allows authenticated attackers to write arbitrary files anywhere on the filesystem. This affects OneDev versions before 4.0.3 and potentially other projects using the vulnerable TarUtils library. Attackers need a valid JobToken to exploit this vulnerability.

💻 Affected Systems

Products:
  • OneDev
Versions: All versions before 4.0.3
Operating Systems: All platforms running OneDev
Default Config Vulnerable: ⚠️ Yes
Notes: Also affects any other projects using the vulnerable io.onedev.commons.utils.TarUtils library from affected OneDev versions.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete system compromise through arbitrary file overwrite leading to remote code execution, data destruction, or privilege escalation.

🟠

Likely Case

Unauthorized file modification, data corruption, or limited code execution within application context.

🟢

If Mitigated

No impact if proper path validation is implemented or access controls prevent exploitation.

🌐 Internet-Facing: MEDIUM - Requires authentication but could be exploited if other vulnerabilities provide JobToken access.
🏢 Internal Only: MEDIUM - Internal attackers with valid credentials could exploit this vulnerability.

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: UNKNOWN
Unauthenticated Exploit: ✅ No
Complexity: MEDIUM

Exploitation requires a valid JobToken, which may require chaining with other vulnerabilities. The vulnerability itself is straightforward path traversal.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 4.0.3

Vendor Advisory: https://github.com/theonedev/onedev/security/advisories/GHSA-2w6j-wc8c-9mq2

Restart Required: Yes

Instructions:

1. Backup your OneDev installation and data. 2. Stop the OneDev service. 3. Upgrade to version 4.0.3 or later. 4. Restart the OneDev service. 5. Verify the upgrade was successful.

🔧 Temporary Workarounds

Restrict KubernetesResource endpoint access

all

Limit network access to the KubernetesResource REST endpoint to trusted sources only.

JobToken rotation and restriction

all

Rotate all JobTokens and implement strict access controls on token usage.

🧯 If You Can't Patch

  • Implement strict network segmentation to isolate OneDev instances
  • Monitor file system changes and implement file integrity monitoring

🔍 How to Verify

Check if Vulnerable:

Check OneDev version via admin interface or by examining the installation directory for version files.

Check Version:

Check OneDev web interface admin panel or examine version.txt in installation directory.

Verify Fix Applied:

Verify version is 4.0.3 or later and test that tar extraction is restricted to intended directories.

📡 Detection & Monitoring

Log Indicators:

  • Unusual file write operations outside expected directories
  • Multiple failed authentication attempts to KubernetesResource endpoint
  • Unexpected tar extraction processes

Network Indicators:

  • Unusual traffic patterns to /api/kubernetes endpoint
  • Large tar file uploads to KubernetesResource endpoint

SIEM Query:

source="onedev" AND (event="file_write" AND path NOT CONTAINS "/expected/directory/") OR (endpoint="/api/kubernetes" AND method="POST" AND size>1000000)

🔗 References

📤 Share & Export