VYPR
Critical severityNVD Advisory· Published Jun 24, 2025· Updated Jun 25, 2025

Gogs deletion of internal files allows remote command execution

CVE-2024-56731

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 packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
gogs.io/gogsGo
< 0.13.30.13.3

Affected products

1

Patches

1
77a4a945ae9a

repo: prevent preview and delete files in `.git` directories (#7870)

https://github.com/gogs/gogsJoe ChenDec 22, 2024via ghsa
1 file changed · +10 0
  • internal/database/repo_editor.go+10 0 modified
    @@ -220,6 +220,11 @@ func (repo *Repository) UpdateRepoFile(doer *User, opts UpdateRepoFileOptions) (
     
     // GetDiffPreview produces and returns diff result of a file which is not yet committed.
     func (repo *Repository) GetDiffPreview(branch, treePath, content string) (diff *gitutil.Diff, err error) {
    +	// 🚨 SECURITY: Prevent uploading files into the ".git" directory
    +	if isRepositoryGitPath(treePath) {
    +		return nil, errors.Errorf("bad tree path %q", treePath)
    +	}
    +
     	repoWorkingPool.CheckIn(com.ToStr(repo.ID))
     	defer repoWorkingPool.CheckOut(com.ToStr(repo.ID))
     
    @@ -283,6 +288,11 @@ type DeleteRepoFileOptions struct {
     }
     
     func (repo *Repository) DeleteRepoFile(doer *User, opts DeleteRepoFileOptions) (err error) {
    +	// 🚨 SECURITY: Prevent uploading files into the ".git" directory
    +	if isRepositoryGitPath(opts.TreePath) {
    +		return errors.Errorf("bad tree path %q", opts.TreePath)
    +	}
    +
     	repoWorkingPool.CheckIn(com.ToStr(repo.ID))
     	defer repoWorkingPool.CheckOut(com.ToStr(repo.ID))
     
    

Vulnerability mechanics

Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

6

News mentions

0

No linked articles in our index yet.