/

CVE-2026-24135

Severity:

HIGH RISK

(8.1)

Path Traversal in Gogs Wiki updateWikiPage Enables

CVE-2026-24135

Analyzed

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22

Impact:

Arbitrary File Deletion

Severity:

HIGH RISK

(8.1)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A path traversal vulnerability in the updateWikiPage functionality of Gogs allows an authenticated user with wiki write access to influence filesystem paths via the old_title parameter.

By crafting this parameter, an attacker can cause the server to delete arbitrary files accessible to the Gogs process, turning normal wiki edits into a high-impact file deletion primitive.

Affected context

This vulnerability arises in Gogs instances that:

  • Expose repository wikis to authenticated users, and
  • Allow those users to edit existing wiki pages via the web interface or API.

The issue is specifically tied to the updateWikiPage function, where user-controlled input (old_title) is used to compute file paths for wiki content. When path components are not properly validated or normalized, edits to wiki titles can escape the intended wiki directory and target other files on the server filesystem that the Gogs process can delete.

Exploit preconditions

  • Attack surface: HTTP(S) endpoints handling wiki page updates (web UI or corresponding API).
  • Required access: Authenticated account with write permissions to a repository's wiki.
  • Trigger point: Submission of a wiki edit form or request where the old_title field is attacker-controlled.
  • Why exploitation is possible: The server-side logic that maps old_title to a file path does not sufficiently sanitize or constrain path segments (such as ../), allowing traversal outside the expected wiki directory and enabling deletion of non-wiki files.

Why this happens

The root cause is improper restriction of user-controlled path input when performing filesystem operations, a classic CWE-22: Path Traversal issue.

In updateWikiPage, the application appears to:

  • Treat old_title as a trusted reference to the existing wiki page file,
  • Use it directly or with insufficient normalization to build a filesystem path, and
  • Perform deletion or rename operations using that path.

Without strict enforcement that the resolved path remains within the repository's wiki directory, an attacker can craft values that traverse directories (using relative components or similar patterns). This breaks the intended isolation between wiki content and the rest of the server filesystem and turns a simple content update into an arbitrary file deletion operation.

Potential impact

  • Deletion of configuration files that the Gogs process can access, which may disrupt the application or other services.
  • Removal of application data or repository content, leading to data loss or corruption.
  • Deletion of log files, hindering incident response and auditability.
  • Potential removal of security controls or scripts (where permissions allow), facilitating follow-on attacks or persistence.
  • Service interruption or denial of service if critical files required for normal operation are removed.

General mitigation guidance

Effective mitigation focuses on constraining filesystem access and treating path components as untrusted data:

  • Normalize and validate all user-supplied path components before use, ensuring the final resolved path:
  • Cannot contain directory traversal sequences, and
  • Is strictly confined to a known base directory (e.g., the repository's wiki root).
  • Use high-level path utility functions that:
  • Join user input with a fixed root, and
  • Reject operations where the canonical resolved path escapes that root.
  • Represent wiki pages by internal identifiers or safe slugs instead of raw user-controlled titles, and map these IDs to file paths via trusted server-side logic.
  • Apply least-privilege to the Gogs process:
  • Run under a dedicated account with minimal filesystem permissions,
  • Separate writable wiki storage from sensitive system paths.
  • Introduce defensive checks in file deletion and rename helpers that fail closed if there is any path ambiguity or traversal risk.

How teams detect issues like this

Organizations can detect and monitor for similar path traversal risks using a combination of static and operational techniques:

  • Static analysis:
  • Flag direct use of request parameters or form fields in filesystem APIs (e.g., delete, rename, open).
  • Enforce rules that any user-controlled path must pass through a canonicalization and validation routine.
  • Identify string concatenation of directory paths and user input without normalization.
  • Code review:
  • Review all code paths that manipulate wiki titles or filenames, ensuring a clear separation between display names and filesystem names.
  • Look for helper functions performing delete/move operations and verify they validate paths against a fixed base directory.
  • Policy and tooling:
  • Integrate secure coding guidelines for path handling into contribution checklists.
  • Use automated code review or SAST tools configured with rules for CWE-22 patterns.
  • Runtime monitoring:
  • Log deletion operations including resolved paths and request context.
  • Alert on unexpected deletions outside allowed content directories by the application user.

Sources

SourceLink
github.comgithub.com/gogs/gogs/security/advisories/GHSA-jp7c-wj6q-3qf2

Frequently asked

questions

Yes. Any user who can reach the Gogs web interface or API and authenticate with an account that has wiki write permissions to a repository can attempt to exploit this issue by crafting the old_title parameter.

The attacker must have a valid Gogs account and write access to the target repository's wiki. Anonymous users without such permissions cannot directly leverage this specific flaw.

The safest pattern is to treat all path components derived from user input as untrusted: canonicalize and validate them against a fixed base directory, and never use raw titles or arbitrary strings directly in filesystem operations. Using internal IDs or sanitized slugs mapped on the server side greatly reduces risk.

Establish secure file-handling conventions: centralize path construction in well-reviewed helpers, enforce strict base-directory checks, integrate static analysis rules for CWE-22, and include path validation as a mandatory checkpoint in code review for any feature interacting with the filesystem.

Find out what's already
exploitable in your codebase.