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-2025-64175

Gogs 2FA Bypass: The Universal Skeleton Key in Your Git Server

Amit Schendel
Amit Schendel
Senior Security Researcher

Feb 6, 2026·5 min read·71 visits

Executive Summary (TL;DR)

Gogs failed to verify ownership of 2FA recovery codes. An attacker with your password can log in to your account using *their* recovery codes. Patch to 0.13.4 immediately.

A critical logic error in the Gogs self-hosted Git service allows attackers to bypass Two-Factor Authentication (2FA) by using recovery codes belonging to a different account. If an attacker possesses a victim's primary credentials (username/password), they can successfully authenticate as the victim by supplying a recovery code generated from an account they control. This effectively neutralizes the 2FA protection layer, turning a credential leak into a full account takeover.

The Hook: Security Theater

We often treat Two-Factor Authentication (2FA) like a magic shield. You lose your password in a breach? No problem, the hacker doesn't have your phone or your YubiKey. You're safe. But in software engineering, security features are only as good as the logic implementing them. In the case of Gogs, a popular self-hosted Go Git service, that logic was flawed in the most comedic way possible.

Imagine a bank vault that requires a key to open. You show up, claiming to be the owner of Vault 101. The guard asks for your key. You hand them the key to your own house. The guard looks at the key, checks a list, and says, "Yep, that's a valid key that exists in the world," and opens Vault 101 for you. That is exactly what is happening here.

CVE-2025-64175 isn't a complex memory corruption bug or a mathematical break in cryptography. It's a fundamental logic error where the application forgot to ask whose key was being used.

The Flaw: A Case of Missing Identity

The root cause resides in the authentication flow for recovery codes. When a user loses access to their TOTP app (like Google Authenticator), they can use a one-time recovery code. The backend needs to verify two things: 1) Is this code valid and unused? 2) Does this code belong to the user trying to log in?

Gogs nailed the first part and completely ghosted the second. In the internal/db/two_factor.go file (or models in older structures), the function responsible for validating the code accepted a userID, but—and this is the kicker—it explicitly ignored it.

The database query was constructed to search the entire two_factor_recovery_code table for a matching string. If it found any row in the table that matched the code provided by the attacker, it returned success. It didn't matter if that code belonged to the admin, a random user, or the attacker themselves.

The Code: The Smoking Gun

Let's look at the Go code that caused this mess. In Go, the underscore _ is used as a blank identifier to ignore values. Usually, this is fine for unused return values. Here, it was used on the input argument userID. That should have been the first red flag during code review.

Vulnerable Code:

// UseRecoveryCode validates recovery code of given user and marks it is used if valid.
func UseRecoveryCode(_ int64, code string) error {
    recoveryCode := new(TwoFactorRecoveryCode)
    // CRITICAL BUG: No filter for user_id!
    // It only checks if the code string exists and hasn't been used yet.
    has, err := x.Where("code = ?", code).And("is_used = ?", false).Get(recoveryCode)
    
    if err != nil {
        return fmt.Errorf("get unused code: %v", err)
    } else if !has {
        return ErrTwoFactorRecoveryCodeNotFound{Code: code}
    }
    // ... marks code as used and returns success
}

See the _ int64? That's the function saying, "I'm taking a User ID, but I promise not to look at it." The ORM query x.Where("code = ?", code) scans the global table. Since recovery codes are often random strings, collisions are rare, but that's irrelevant here. The attacker doesn't need to guess your code; they just need to provide a valid code that the database knows about.

The Exploit: Bring Your Own Key (BYOK)

To exploit this, an attacker needs two things: the victim's password (easy enough via phishing, credential stuffing, or reuse) and an account on the same Gogs instance (also easy if registration is open, or if the attacker is a rogue insider/contractor).

Here is the kill chain:

  1. Preparation: The attacker logs into their own account and enables 2FA. They generate a list of recovery codes. Let's say one of them is deadbeef-1337.
  2. Infiltration: The attacker goes to the login page and enters the victim's username and password.
  3. The Bypass: The system prompts for 2FA. The attacker clicks "Use Recovery Code".
  4. Execution: The attacker types in deadbeef-1337 (their own code).
  5. Access Granted: The backend queries the DB: "Is deadbeef-1337 a valid, unused code?" The DB replies "Yes". The system logs the attacker into the victim's session.

The attacker has now bypassed the 2FA protection entirely. The system marks the attacker's recovery code as used, which is a small price to pay for full admin access.

The Impact: From Bypass to Supply Chain Attack

This is a "High" severity issue for a reason. Gogs is used to host source code. If an attacker compromises a developer's account, they don't just steal data; they can modify it.

With this bypass, an attacker can:

  • Inject Backdoors: Push malicious code into production repositories.
  • Delete History: Wipe repositories or rewrite git history to hide tracks.
  • Steal Secrets: Access private repos containing API keys or deployment credentials.

Since this bypass requires the primary password, it effectively downgrades the security of 2FA-enabled accounts to that of 1FA accounts. If your password leaked, your 2FA saves you. With CVE-2025-64175, it doesn't.

The Fix: One Line of SQL

The remediation is straightforward: actually use the userID that was passed to the function. The developers patched this in version 0.13.4 (and 0.14.0+dev) by adding a constraint to the query.

Patched Code:

func (db *twoFactors) UseRecoveryCode(ctx context.Context, userID int64, code string) error {
    return db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
        var recoveryCode TwoFactorRecoveryCode
        // FIX: Added "user_id = ?"
        err := tx.Where("user_id = ? AND code = ? AND is_used = ?", userID, code, false).First(&recoveryCode).Error
        // ...
    })
}

If you are running a self-hosted Gogs instance, you must upgrade immediately. If you cannot upgrade, disable open registration to prevent attackers from easily creating accounts to generate recovery codes, though this won't stop insider threats.

Official Patches

GogsOfficial fix commit on GitHub

Fix Analysis (1)

Technical Appendix

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

Affected Systems

Gogs (Self-hosted Git Service)

Affected Versions Detail

Product
Affected Versions
Fixed Version
Gogs
Gogs
< 0.13.40.13.4
AttributeDetail
CWE IDCWE-287 (Improper Authentication)
CVSS v4.07.7 (High)
Attack VectorNetwork
Attack ComplexityLow
Privileges RequiredLow (Any valid account on instance)
ImpactFull Account Takeover

MITRE ATT&CK Mapping

T1110Brute Force
Credential Access
T1556Modify Authentication Process
Credential Access
T1078Valid Accounts
Defense Evasion
CWE-287
Improper Authentication

Known Exploits & Detection

TheoreticalExploit involves logging in as victim and supplying an unused recovery code generated from the attacker's own account.

Vulnerability Timeline

Vulnerability Published
2026-02-06
Patch Released (v0.13.4)
2026-02-06

References & Sources

  • [1]GitHub Advisory
  • [2]CWE-287: Improper Authentication

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.

More Reports

•2 days ago•CVE-2026-58254
6.5

CVE-2026-58254: Authorization Bypass in NATS Server Message Tracing for Leaf Node Connections

NATS Server prior to versions 2.12.8 and 2.14.3 contains an incorrect authorization vulnerability (CWE-863) in its message tracing subsystem. When evaluating whether a connection is permitted to publish trace events to a destination subject specified in the Nats-Trace-Dest header, the server only checks standard client permissions and omits permission checks for leaf node connections. This allows a connected leaf node operator with restricted publishing privileges to emit internal trace events to unauthorized subjects and suppress standard message delivery using the Nats-Trace-Only header.

Alon Barad
Alon Barad
11 views•10 min read
•2 days ago•CVE-2026-63341
7.5

CVE-2026-63341: Unauthenticated Denial of Service via Unbounded Topic Depth in Aedes MQTT Broker

CVE-2026-63341 is a high-severity Denial of Service (DoS) vulnerability in the Aedes MQTT broker for Node.js affecting all versions prior to 1.1.1. The flaw stems from missing input validation on the hierarchical depth of incoming MQTT topic strings before they are passed to the underlying topic-matching engine, qlobber. Because qlobber enforces a hardcoded limit of 100 topic levels and throws a synchronous exception when this threshold is exceeded, an attacker can send a single MQTT packet containing 101 or more forward-slash-separated levels to trigger an uncaught exception that immediately terminates the Node.js broker process.

Alon Barad
Alon Barad
14 views•12 min read
•2 days ago•CVE-2026-61725
6.1

CVE-2026-61725: Path Traversal and Arbitrary File Overwrite in sevenz-rust2

CVE-2026-61725 is a path traversal vulnerability (CWE-22) in the sevenz-rust2 Cargo package prior to version 0.21.1. The vulnerability occurs because the decompression utility fails to validate or sanitize archive entry filenames before joining them with the destination directory path via std::path::Path::join. An attacker who supplies a crafted 7z archive containing parent directory traversal sequences or absolute paths can write or overwrite arbitrary files on the host filesystem with the privileges of the extracting process.

Alon Barad
Alon Barad
6 views•12 min read
•2 days ago•CVE-2026-77309
8.8

CVE-2026-77309: Unauthenticated Remote Code Execution in NASA-AMMOS AIT-GUI via Incomplete File Cleanup and Path Traversal

CVE-2026-77309 (GHSA-jrjx-9jjw-747m) is a high-severity unauthenticated remote code execution vulnerability affecting NASA-AMMOS AIT-GUI versions 1.0.0 through 2.5.0. The flaw results from chaining an incomplete file cleanup error in the telemetry query endpoint (/tlm/query) with a directory traversal flaw in the script execution endpoint (/script/run). An attacker on an adjacent network can stage arbitrary Python statements into a static file on disk and execute that file under the privileges of the AIT-GUI web server process.

Amit Schendel
Amit Schendel
15 views•10 min read
•2 days ago•CVE-2026-77332
2.3

CVE-2026-77332: Surfaced-Memory Envelope Injection and Stored Prompt Injection in memtomem-stm

A vulnerability classified under CWE-116 (Improper Encoding or Escaping of Output) exists in memtomem-stm versions 0.1.0 through 0.1.33. The software acts as a Model Context Protocol (MCP) short-term memory proxy gateway for AI agent architectures. When surfacing retrieved memories and scratchpad items into downstream Large Language Model (LLM) context envelopes, the SurfacingFormatter component fails to properly sanitize untrusted memory attributes. An attacker with the ability to plant untrusted content into the agent's long-term or working memory store can inject arbitrary structural delimiters, close the <surfaced-memories> XML boundary prematurely, visually obscure instructions using Unicode bidirectional overrides, and execute stored prompt injection attacks against downstream LLM agents.

Alon Barad
Alon Barad
19 views•10 min read
•2 days ago•CVE-2026-77331
2.0

CVE-2026-77331: Race Condition and Session State Corruption in memtomem-stm

CVE-2026-77331 (GHSA-72jh-722p-rqr3) is a concurrency and session-state synchronization vulnerability in memtomem-stm, a short-term memory proxy gateway for AI agents. In versions 0.1.2 prior to 0.1.34, concurrent Model Context Protocol (MCP) Remote Procedure Call (RPC) failures or mid-flight task cancellations can initiate duplicate reconnect loops and permit dirty or cancelled transport sessions to be reused. This deficiency results in session-state integrity loss and local service degradation.

Amit Schendel
Amit Schendel
8 views•9 min read