CVE-2024-56731: Gogs.io/gogs Gogs Allows Deletion Of Internal Vulnerability

CRITICAL
Advisory Identifier: GHSA-wj44-9vcg-wjq7
CVSS 10.0
CWE-552
Published
Advisory Summary

CVE-2024-56731 is a CRITICAL (CVSS 10.0) gogs allows deletion of internal vulnerability (CWE-552: Files or Directories Accessible to External Parties) affecting Gogs.io/gogs libraries in the Go ecosystem. The issue involves gogs allows deletion of internal files which leads to remote command execution. Remediation is available by upgrading affected packages to version 0.13.3.

CVE-2024-56731 at a Glance

CVE Identifier CVE-2024-56731
GHSA Identifier GHSA-wj44-9vcg-wjq7
Severity CRITICAL
CVSS v3.1 Base Score 10.0
CWE Classification CWE-552: Files or Directories Accessible to External Parties
Affected Product Gogs.io/gogs
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 10.0

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Changed (S:C)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2024-56731

To remediate this vulnerability, upgrade all affected Gogs.io/gogs dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

gogs.io/gogs fixed: 0.13.3
Upgrade gogs.io/gogs to 0.13.3
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for gogs.io/gogs

How to Check if You Are Affected

To determine whether your application is affected by CVE-2024-56731, inspect your project dependencies for Gogs.io/gogs:

inspect dependencies for gogs.io/gogs

Analyze the terminal output to locate any version of Gogs.io/gogs in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.13.3), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-552: Files or Directories Accessible to External Parties, where the product makes files or directories accessible to unauthorized actors, even though they should not be. In Gogs.io/gogs, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### 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 ```diff + // 🚨 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.

CVE-2024-56731 Affected Gogs.io/gogs Versions

1 component(s)
Fixed Versions:
0.13.3
Product / Package Ecosystem Affected Versions Fixed Version
gogs.io/gogs
Go
< 0.13.3
0.13.3

References

Frequently Asked Questions

What is CVE-2024-56731?
CVE-2024-56731 is a security vulnerability in Gogs.io/gogs involving Gogs allows deletion of internal files which leads to remote command execution under CWE-552: Files or Directories Accessible to External Parties.
Which Gogs.io/gogs versions are affected?
Affected versions include releases prior to 0.13.3 across affected packages: gogs.io/gogs.
What version fixes CVE-2024-56731?
Upgrading to 0.13.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is gogs.io/gogs affected?
Yes, gogs.io/gogs is affected in releases prior to 0.13.3. Upgrade your dependency to 0.13.3 or later.
What is the CVSS score of CVE-2024-56731?
CVE-2024-56731 has a CVSS v3.1 base score of 10.0 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H.
What CWE is associated with CVE-2024-56731?
CVE-2024-56731 is classified under CWE-552: Files or Directories Accessible to External Parties (The product makes files or directories accessible to unauthorized actors, even though they should not be.).
How can I check Go dependencies for CVE-2024-56731?
Run the dependency tree command: 'inspect dependencies for gogs.io/gogs'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-wj44-9vcg-wjq7",
  "modified" : "2025-06-24T19:00:21Z",
  "published" : "2025-06-24T19:00:20Z",
  "aliases" : [ "CVE-2024-56731" ],
  "summary" : "Gogs allows deletion of internal files which leads to remote command execution",
  "details" : "### Summary\nDue 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.\n\n### Details\nIn the patch for CVE-2024-39931, the following check is added:\nhttps://github.com/gogs/gogs/commit/77a4a945ae9a87f77e392e9066b560edb71b5de9\n\n```diff\n+\t// 🚨 SECURITY: Prevent uploading files into the \".git\" directory\n+\tif isRepositoryGitPath(opts.TreePath) {\n+\t\treturn errors.Errorf(\"bad tree path %q\", opts.TreePath)\n+\t}\n```\n\n\nWhile 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.\n\n### Impact\nUnprivileged 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.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "gogs.io/gogs"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.13.3"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 0.13.2"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/gogs/gogs/security/advisories/GHSA-wj44-9vcg-wjq7"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-56731"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/gogs/gogs/commit/77a4a945ae9a87f77e392e9066b560edb71b5de9"
  }, {
    "type" : "ADVISORY",
    "url" : "https://github.com/advisories/GHSA-ccqv-43vm-4f3w"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/gogs/gogs"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/gogs/gogs/releases/tag/v0.13.3"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-552" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2025-06-24T19:00:20Z",
    "nvd_published_at" : "2025-06-24T04:15:45Z"
  }
}