CVEReports
CVEReports

Automated vulnerability intelligence platform. Comprehensive reports for high-severity CVEs generated by AI.

Product

  • Home
  • Sitemap
  • RSS Feed

Company

  • About
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 CVEReports. All rights reserved.

Made with love by Amit Schendel & Alon Barad



CVE-2026-26196
6.9

CVE-2026-26196: Sensitive API Token Exposure via URL Query Parameters in Gogs

Amit Schendel
Amit Schendel
Senior Security Researcher

Mar 5, 2026·5 min read·4 visits

No Known Exploit

Executive Summary (TL;DR)

Gogs versions < 0.14.2 allow API authentication via URL query strings. This exposes secret tokens to server logs and intermediaries. The fix in 0.14.2 removes query parameter support, enforcing the use of the `Authorization` header. Users must upgrade and rotate all existing tokens.

Gogs, a self-hosted Git service, contained a vulnerability in its API authentication mechanism prior to version 0.14.2. The application permitted the transmission of sensitive authentication tokens via URL query parameters (`token` and `access_token`). This architectural flaw resulted in the potential leakage of credentials to server access logs, proxy logs, browser history, and HTTP Referer headers, exposing users to account takeover risks.

Vulnerability Overview

Gogs is a widely deployed, self-hosted Git service written in Go. In versions prior to 0.14.2, the application's API authentication logic failed to adhere to secure transport standards for sensitive credentials. Specifically, the API accepted authentication tokens passed directly in the URL query string using parameters named token or access_token.

This implementation violates standard security practices defined in CWE-598 (Information Exposure Through Query Strings in GET Request). While convenient for quick scripting, passing secrets in the URL places them in components of the HTTP request that are not intended to be confidential. Unlike the HTTP Body or Headers, the Request Line (URI) is routinely logged in cleartext by web servers, proxies, and security appliances.

The vulnerability is classified as a passive information leak. It does not allow an attacker to break into the system directly via a crafted packet, but rather ensures that valid credentials are persistently recorded in locations accessible to a wider audience than intended, such as system administrators, log analysis tools, or attackers with local file inclusion (LFI) capabilities.

Root Cause Analysis

The root cause of this vulnerability lies in the authenticatedUserID function within internal/context/auth.go. This function is responsible for determining the identity of the user making an API request. The logic explicitly checked the URL query string for authentication material before checking standard HTTP headers.

The vulnerable code prioritized ease of use over security. When an API request was received, the application checked c.Query("token"). If that was empty, it checked c.Query("access_token"). Only if both were missing did the application proceed to inspect the Authorization header. This precedence encouraged users and client libraries to use the insecure query string method.

Because the token retrieval occurred early in the request lifecycle, the full URL—including the sensitive token—would be processed by the Go net/http stack and any reverse proxies (like Nginx or Apache) sitting in front of the Gogs instance. Standard logging configurations for these servers default to the Combined Log Format, which includes the requested resource path and query string.

Code Analysis & Patch

The remediation for CVE-2026-26196 involved removing the logic that parsed tokens from the query string entirely. The patch enforces the use of the Authorization header, which is the standard mechanism for bearer token authentication and is rarely logged by default.

Below is the analysis of the changes in internal/context/auth.go from commit 295bfba72993c372e7b338438947d8e1a6bed8fd:

Vulnerable Implementation (Pre-0.14.2):

// internal/context/auth.go
 
func authenticatedUserID(store AuthStore, c *macaron.Context, sess session.Store) int64 {
    // ...
    if isAPIPath(c.Req.URL.Path) {
        // VULNERABILITY: Tokens extracted from URL query
        tokenSHA := c.Query("token")
        if len(tokenSHA) <= 0 {
            tokenSHA = c.Query("access_token")
        }
        if tokenSHA == "" {
            // Only checks header if query params are empty
            auHead := c.Req.Header.Get("Authorization")
            // ...
        }
    }
}

Patched Implementation (v0.14.2):

// internal/context/auth.go
 
func authenticatedUserID(store AuthStore, c *macaron.Context, sess session.Store) int64 {
    // ...
    if isAPIPath(c.Req.URL.Path) {
        var tokenSHA string
        // FIX: Query string checks removed entirely.
        // Authentication now strictly requires the Authorization header.
        auHead := c.Req.Header.Get("Authorization")
        if auHead != "" {
            auths := strings.Fields(auHead)
            if len(auths) == 2 && auths[0] == "token" {
                tokenSHA = auths[1]
            }
        }
        // ...
    }
}

By removing the calls to c.Query, the maintainers eliminated the attack surface. Any client attempting to use the old query parameter method will now receive a 401 Unauthorized response, forcing the adoption of the secure header method.

Attack Vectors & Impact

The exploitation of this vulnerability relies on an attacker gaining access to historical request data. Several vectors exist for this leakage:

  1. Server Logs: Access logs (e.g., /var/log/nginx/access.log) retain the full request URI. An attacker who gains read access to these logs—perhaps via a separate Directory Traversal vulnerability or misconfigured permissions—can harvest valid tokens.
  2. Proxy & SIEM Logs: In enterprise environments, traffic often passes through transparent proxies or is forwarded to SIEM solutions (Splunk, ELK). If these systems are not configured to redact sensitive query parameters, the tokens become indexed and searchable by security analysts or attackers who compromise the logging infrastructure.
  3. Referer Headers: If a user visits a URL like https://gogs.local/api/v1/repos?token=XYZ and the API response contains a link to an external site, clicking that link may send the full URL (containing the token) in the Referer header to the external server.

Impact Assessment: The compromise of a Gogs API token is equivalent to compromising the user's password for API operations. Depending on the scope of the token and the user's privileges, an attacker could:

  • Clone private repositories (Intellectual Property theft).
  • Push malicious code to repositories (Supply Chain Attack).
  • Modify issue trackers or wiki pages.
  • If the user is an administrator, the attacker could potentially gain full control over the Gogs instance.

Remediation & Mitigation

The primary remediation is to upgrade the Gogs instance to version 0.14.2 or later immediately. This version drops support for query-based authentication, neutralizing the vulnerability.

Critical Post-Upgrade Step: Token Rotation Upgrading the software stops future leaks, but it does not invalidate tokens that have already been logged. Security teams must assume that all tokens used prior to the upgrade are compromised. Users should be forced or instructed to revoke existing Personal Access Tokens and generate new ones.

Log Sanitization Administrators should scan existing web server and proxy logs for patterns matching token= or access_token=. These logs should be scrubbed or deleted to prevent historical data mining by attackers. Future logging configurations should be reviewed to ensure query strings are either excluded or sanitized of sensitive keys.

Official Patches

GogsGogs v0.14.2 Release Notes
GogsFix Commit on GitHub

Fix Analysis (1)

Technical Appendix

CVSS Score
6.9/ 10
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N

Affected Systems

Gogs (Self-Hosted Git Service)

Affected Versions Detail

Product
Affected Versions
Fixed Version
Gogs
Gogs
< 0.14.20.14.2
AttributeDetail
CVE IDCVE-2026-26196
CVSS v4.06.9 (Medium)
CWE IDCWE-598
ImpactInformation Disclosure (Credential Leak)
Attack VectorNetwork (Passive)
Patch Commit295bfba7299

MITRE ATT&CK Mapping

T1552.003Unsecured Credentials: Bash History
Credential Access
T1040Network Sniffing
Credential Access
CWE-598
Information Exposure Through Query Strings in GET Request

Use of GET Request Method With Sensitive Query Strings

Known Exploits & Detection

GHSAGitHub Security Advisory Details

Vulnerability Timeline

Vulnerability Fixed in Main Branch
2026-02-13
Public Disclosure & CVE Published
2026-03-05
Version 0.14.2 Released
2026-03-05

References & Sources

  • [1]GHSA-x9p5-w45c-7ffc
  • [2]Pull Request #8177

Attack Flow Diagram

Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.