CVE-2026-25591

CVE-2026-25591 is a high-severity security vulnerability in github.com/QuantumNous/new-api (go), affecting versions < 0.10.8-alpha.10. It is fixed in 0.10.8-alpha.10.

Summary

A SQL LIKE wildcard injection vulnerability in the /api/token/search endpoint allows authenticated users to cause Denial of Service through resource exhaustion by crafting malicious search patterns.

Details

The token search endpoint accepts user-supplied keyword and token parameters that are directly concatenated into SQL LIKE clauses without escaping wildcard characters (%, _). This allows attackers to inject patterns that trigger expensive database queries.

Vulnerable Code

File: model/token.go:70

err = DB.Where("user_id = ?", userId).
       Where("name LIKE ?", "%"+keyword+"%").     // No wildcard escaping
       Where(commonKeyCol+" LIKE ?", "%"+token+"%").
       Find(&tokens).Error

PoC

After creating over 2 million tokens, creating millions token entries is not difficult, because the rate limiting only applies to IP addresses, so multiple IP addresses can share one session, allowing for the creation of an unlimited number of tokens in batches.

These data are not all loaded at once under normal circumstances, as shown in the image, and are displayed correctly. But if a request like this is submitted:

# A single request causes PostgreSQL to unconditionally retrieve all tokens belonging to that user. These requests buffer will all go into the buffer zone, causing an overflow and preventing the program from functioning properly.
curl 'http://localhost:3000/api/token/search?keyword=%&token='

It will cause DoS.

import requests
from concurrent.futures import ThreadPoolExecutor

def attack(session_cookie):
    requests.get(
        'http://localhost:3000/api/token/search',
        params={'keyword': '%_%_%_%_%_%', 'token': ''},
        cookies={'session': session_cookie},
        headers={'New-API-User': '1'}
    )

# Launch 50 concurrent malicious requests
with ThreadPoolExecutor(max_workers=50) as executor:
    for _ in range(50):
        executor.submit(attack, '<valid_session>')

RAM Overflow

Postgres unavailable

  • Database CPU usage spike to 100%
  • Application memory exhaustion
  • Legitimate user requests blocked or significantly delayed
  • Potential application crash or database connection pool exhaustion

Database Performance

Testing with 2,000,000 tokens:

Pattern Query Time Rows Impact
test (normal) ~50ms 0 Low
% (full scan) 5,973ms 2,000,000 High
%_%_%_%_%_% 6,200ms+ 2,000,000 Very High

Attack Scalability

  • Single attacker: Can launch 10-50 concurrent requests easily
  • Multiple accounts: Attacker can register multiple accounts (if registration enabled)
  • Proxy rotation: IP-based rate limiting can be bypassed
  • Persistence: Attack can be sustained indefinitely

Resource Consumption

Each malicious request with 2M results:

  • Database: ~6 seconds CPU time
  • Network: ~200MB data transfer
  • Application Memory: ~200MB+ for JSON serialization
  • Connection Time: Database connection held for entire query duration

Exploitation Scenario

  1. Attacker registers or compromises a regular user account
  2. Attacker crafts malicious LIKE patterns using % wildcards
  3. Attacker launches concurrent requests (50-200 concurrent)
  4. Database becomes overwhelmed with slow queries
  5. Application memory exhausts from processing large result sets
  6. Legitimate users experience service degradation or complete unavailability

Patch Recommendations

1. Escape LIKE Wildcards (Critical)

func escapeLike(s string) string {
    s = strings.ReplaceAll(s, "\\", "\\\\")
    s = strings.ReplaceAll(s, "%", "\\%")
    s = strings.ReplaceAll(s, "_", "\\_")
    return s
}

func SearchUserTokens(userId int, keyword string, token string) (tokens []*Token, err error) {
    keyword = escapeLike(keyword)
    token = strings.Trim(token, "sk-")
    token = escapeLike(token)

    err = DB.Where("user_id = ?", userId).
           Where("name LIKE ? ESCAPE '\\\\'", "%"+keyword+"%").
           Where(commonKeyCol+" LIKE ? ESCAPE '\\\\'", "%"+token+"%").
           Limit(1000).
           Find(&tokens).Error
    return tokens, err
}

2. Add User-Level Rate Limiting

tokenRoute.GET("/search",
    middleware.TokenSearchRateLimit(),  // 30 req/min per user
    controller.SearchTokens)

3. Add Query Timeout

ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
err = DB.WithContext(ctx).Where(...).Find(&tokens).Error

Impact

Availability

Affected versions

github.com/QuantumNous/new-api (< 0.10.8-alpha.10)

Security releases

github.com/QuantumNous/new-api → 0.10.8-alpha.10 (go)

Kodem intelligence

Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.

Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.

See it in your environment

Remediation advice

Upgrade github.com/QuantumNous/new-api to 0.10.8-alpha.10 or later to resolve this vulnerability.

Kodem Kai can prioritize this vulnerability in your dependency tree and generate a fix recommendation.

Frequently Asked Questions

  1. What is CVE-2026-25591? CVE-2026-25591 is a high-severity security vulnerability in github.com/QuantumNous/new-api (go), affecting versions < 0.10.8-alpha.10. It is fixed in 0.10.8-alpha.10.
  2. Which versions of github.com/QuantumNous/new-api are affected by CVE-2026-25591? github.com/QuantumNous/new-api (go) versions < 0.10.8-alpha.10 is affected.
  3. Is there a fix for CVE-2026-25591? Yes. CVE-2026-25591 is fixed in 0.10.8-alpha.10. Upgrade to this version or later.
  4. Is CVE-2026-25591 exploitable, and should I be worried? Whether CVE-2026-25591 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
  5. What actually determines whether CVE-2026-25591 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
  6. How do I fix CVE-2026-25591? Upgrade github.com/QuantumNous/new-api to 0.10.8-alpha.10 or later.

Other vulnerabilities in github.com/QuantumNous/new-api

CVE-2026-42339CVE-2026-41432CVE-2026-30886CVE-2026-32879CVE-2026-25591

Stop the waste.
Protect your environment with Kodem.