CVE-2024-56731
JSON

10.0critical

Gogs deletion of internal files allows remote command execution

Severity
10.0critical CVSS:3.1 by GitHub_M
Exploit likelihood
1.27% (higher than 70% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-wj44-9vcg-wjq7GO-2025-3776

Description

Gogs is an open source self-hosted Git service. Prior to version 0.13.3, it's still possible to delete files under the .git directory and achieve remote command execution due to an insufficient patch for CVE-2024-39931. Unprivileged user accounts can execute arbitrary commands on the Gogs instance with the privileges of the account specified by RUN_USER in the configuration. Allowing attackers to access and alter any users' code hosted on the same instance. This issue has been patched in version 0.13.3.

Affected

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

All scores

GitHub_M10.0critical CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H
GitHub10.0critical CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H
NVD9.8critical CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

Classification

CWE-552

SSVC (CISA-ADP): exploitation none, automatable yes, technical impact total.

What each source says

CVE List

Gogs is an open source self-hosted Git service. Prior to version 0.13.3, it's still possible to delete files under the .git directory and achieve remote command execution due to an insufficient patch for CVE-2024-39931. Unprivileged user accounts can execute arbitrary commands on the Gogs instance with the privileges of the account specified by RUN_USER in the configuration. Allowing attackers to access and alter any users' code hosted on the same instance. This issue has been patched in version 0.13.3.

GitHub Advisory Database
Summary

Due to the insufficient patch for the CVE-2024-39931, it's still possible to delete files under the .git directory and achieve remote command execution.

Details

In the patch for CVE-2024-39931, the following check is added: https://github.com/gogs/gogs/commit/77a4a945ae9a87f77e392e9066b560edb71b5de9

+	// 馃毃 SECURITY: Prevent uploading files into the ".git" directory
+	if isRepositoryGitPath(opts.TreePath) {
+		return errors.Errorf("bad tree path %q", opts.TreePath)
+	}

While the above code snippet checks if the specified path is a .git directory, there are no checks for symbolic links in the later steps. So, by creating a symbolic link that points to the .git directory, an attacker can still delete arbitrary files in the .git directory and achieve remote command execution.

Impact

Unprivileged user accounts can execute arbitrary commands on the Gogs instance with the privileges of the account specified by RUN_USER in the configuration. It allows attackers to access and alter any users' code hosted on the same instance.

Go Vulnerability Database

Gogs allows deletion of internal files which leads to remote command execution in gogs.io/gogs

NVD (es)

Gogs es un servicio Git autoalojado de c贸digo abierto. Antes de la versi贸n 0.13.3, a煤n era posible eliminar archivos del directorio .git y ejecutar comandos de forma remota debido a un parche insuficiente para CVE-2024-39931. Las cuentas de usuario sin privilegios pueden ejecutar comandos arbitrarios en la instancia de Gogs con los privilegios de la cuenta especificada por RUN_USER en la configuraci贸n. Esto permite a los atacantes acceder y modificar el c贸digo de cualquier usuario alojado en la misma instancia. Este problema se ha corregido en la versi贸n 0.13.3.

References

Sources

SourceRecordLicence
CVE ListCVE-2024-56731 changed 2025-06-25CVE Terms of Use
GitHub Advisory DatabaseGHSA-wj44-9vcg-wjq7 changed 2025-07-28CC-BY-4.0
Go Vulnerability DatabaseGO-2025-3776 changed 2026-03-03CC-BY-4.0
NVDCVE-2024-56731 changed 2026-06-17Public domain