CVE-2024-56731 Gogs deletion of internal files allows remote command execution

Critical 10.0 Published Updated

Unprivileged users can delete internal Git files to achieve remote command execution on the server, compromising all hosted code.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Over the internet
Victim action needed
Not needed
Fix
Available

What is CVE-2024-56731?

CVE-2024-56731 is a critical command injection vulnerability in gogs, published on 24 Jun 2025. An attacker can exploit it over the internet without logging in, with no action from the victim.

Official 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.

Weakness: CWE-552

Which versions are affected by CVE-2024-56731?

3 open source packages ship an affected version, including gogs.io/gogs. It affects 1 product.

PackageAffectedFixed in
gogs.io/gogs GoAll versions0.13.3
gogs.io/gogs GoAll versions0.13.3
gogs.io/gogs GoAll versions0.13.3

Products include Gogs Gogs.

How do I fix CVE-2024-56731?

Upgrade gogs.io/gogs to 0.13.3 or later.

Upgrade, and pass arguments to programs as a list instead of through a shell. More about Command injection.

Is CVE-2024-56731 being exploited?

There is no known exploitation of CVE-2024-56731 in the wild and no public exploit code.

Sources

Also known as GHSA-wj44-9vcg-wjq7, GO-2025-3776.

Is CVE-2024-56731 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free