DEV Community

facilishz
facilishz

Posted on

Gogs on Windows needs canonical repository paths, not string prefixes

Gogs on Windows needs canonical repository paths, not string prefixes

Repository servers protect .git paths because they can contain hooks, configuration, and objects that influence how Git behaves. A textual prefix check can fail when the operating system treats two different strings as the same file path.

CVE-2026-134808 affects Gogs before 0.14.4 on Windows. The public record describes a path-equivalence flaw in isRepositoryGitPath. An authenticated user with write access could use NTFS aliases to bypass the .git directory protection.

The Windows path problem

Windows can resolve names through aliases that are not obvious in a simple string comparison. The application needs to determine the effective file object, not just whether a string contains a protected component. A check that works on a conventional path can miss another spelling that reaches the same directory.

The public description does not claim unauthenticated access. The attacker needs a Gogs account and write access to a repository. Those conditions fit a malicious collaborator, a compromised developer account, or a tenant with broader write rights than intended.

The impact is repository integrity. If an attacker can modify protected Git metadata, the server may later execute hooks or expose data through a repository operation. The CVE record should be used for the precise scope; administrators should not assume remote code execution without deployment-specific evidence.

Fix the path decision

Upgrade Gogs to 0.14.4 or later on Windows. Search for older installations used for builds, mirrors, or internal archives. Linux deployments are outside the specific Windows path condition but should still track the release.

Resolve paths with Windows filesystem APIs and compare canonical file identities. Reject reparse points and symbolic links in protected repository paths. Do not decide access by lowercasing or trimming a string and hoping that the filesystem agrees.

Administrators should review repository write permissions and recent changes to .git configuration, hooks, and object metadata. Restore from a known-good repository copy if unauthorized changes are found. Rotate credentials that could push to the affected repository.

Keep hooks disabled unless the repository owner has an approved use. Run Git operations under a service account limited to repository storage. Separate the web application from build workers so a repository compromise does not automatically reach deployment credentials.

After patching, test with a disposable repository and Windows alias variants that resolve to a protected directory. Confirm that the write is denied before a file is created. Then test a normal repository operation to ensure that the guard did not break legitimate collaboration.

References

Top comments (0)