CVE-2026-21729
Executive Summary
CVE-2026-21729 is a denial-of-service (DoS) vulnerability in Grafana Loki, a log aggregation system. The flaw allows an unauthenticated attacker to craft queries with excessively large limit parameters, causing the service to allocate massive amounts of memory. This can lead to resource exhaustion and service unavailability, particularly in deployments without resource quotas or rate limiting. The vulnerability has a CVSS score of 7.5 (High) and currently has no official patch. Mitigation requires strict configuration controls, such as limiting query limits, enabling rate limiting, and using resource quotas.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
Loki is distributed as a Go binary and via Docker images. While no direct supply chain compromise is reported, the vulnerability highlights the risk of default configurations that allow unbounded resource consumption. Organizations using Loki should verify their deployment’s configuration and apply security controls to prevent abuse.
CVSS Breakdown & Threat Level
- CVSS Score: 7.5 (High)
- Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
- Attack Vector: Network
- Attack Complexity: Low
- Privileges Required: None
- User Interaction: None
- Scope: Unchanged
- Confidentiality Impact: None
- Integrity Impact: None
- Availability Impact: High
The vulnerability is easily exploitable remotely without authentication, making it a significant threat to Loki service availability.
Deep Dive & Mechanics
Loki’s query API accepts a limit parameter to control the number of log lines returned. When a query with an extremely large limit (e.g., 10^9) is submitted, the system attempts to allocate memory proportional to that limit. Without proper bounds checking or resource throttling, this can exhaust available memory, causing the Loki process to crash or become unresponsive.
The issue is rooted in the query execution path, where the limit is used to size internal buffers and result sets. In distributed deployments, the impact can cascade across queriers and ingesters, amplifying the denial-of-service effect.
Vulnerable vs. Patched Code
Vulnerable Code (Conceptual):
func (q *Querier) Query(ctx context.Context, params QueryParams) (Result, error) {
limit := params.Limit
// No validation on limit size
results := make([]LogEntry, 0, limit)
// ... fetch and append logs
return results, nil
}
Patched Code (Conceptual):
func (q *Querier) Query(ctx context.Context, params QueryParams) (Result, error) {
limit := params.Limit
if limit > maxQueryLimit {
limit = maxQueryLimit
}
results := make([]LogEntry, 0, limit)
// ... fetch and append logs
return results, nil
}
The fix involves adding a configuration option max_query_limit and enforcing it server-side. Without an official patch, administrators must implement this via configuration or a reverse proxy.
Exploitation & Lab Setup
Red Team
- Identify Target: Scan for Loki HTTP endpoints (default port 3100).
- Craft Malicious Query: Send a GET request with an excessively large
limitparameter.curl "http://target:3100/loki/api/v1/query_range?query={job=\"varlogs\"}&limit=999999999999&start=0&end=9999999999" - Observe Impact: Monitor target memory usage; the service may become unresponsive or crash.
Blue Team
- Detection: Monitor for queries with abnormally high
limitvalues in Loki logs or network traffic. - Mitigation: Configure Loki with
query_timeoutandmax_query_limitin the configuration file:querier: query_timeout: 30s max_query_limit: 5000 - Rate Limiting: Use a reverse proxy (e.g., Nginx) to limit request rates and block large
limitvalues.location /loki/api/v1/query_range { if ($arg_limit ~ "^[0-9]{7,}$") { return 403; } proxy_pass http://loki_backend; }
Indicators of Compromise (IOCs)
- Network: HTTP GET requests to
/loki/api/v1/query_rangewithlimitparameter exceeding 10,000. - Logs: Loki logs showing
out of memoryerrors orquery timeoutfor queries with large limits. - System: High memory usage on Loki nodes, potential OOM killer events.
Detection Engineering
YARA Rule
rule Loki_Large_Limit_DoS {
meta:
description = "Detects Loki queries with excessively large limit parameter"
author = "Valters IT"
date = "2026-01-01"
reference = "CVE-2026-21729"
strings:
$limit_param = /limit=[0-9]{7,}/ nocase
condition:
$limit_param
}
Sigma Rule
title: Loki Large Query Limit DoS Attempt
id: 12345678-1234-1234-1234-123456789012
status: experimental
description: Detects HTTP requests to Loki with abnormally large limit parameter
author: Valters IT
logsource:
category: webserver
product: nginx
detection:
selection:
cs-method: 'GET'
cs-uri-query|contains: 'limit='
cs-uri-query|re: 'limit=[0-9]{7,}'
condition: selection
falsepositives:
- Legitimate queries with large limits (rare)
level: high
Suricata Rule
alert http any any -> any any (msg:"CVE-2026-21729 Loki Large Limit DoS Attempt"; flow:to_server; http.uri; content:"/loki/api/v1/query_range"; http.uri; content:"limit="; pcre:"/limit=[0-9]{7,}/"; classtype:attempted-dos; sid:1000001; rev:1;)
Remediation & Mitigation
- Configuration Hardening: Set
max_query_limitin Loki configuration to a reasonable value (e.g., 5000). - Rate Limiting: Implement rate limiting at the reverse proxy or load balancer.
- Resource Quotas: Use container orchestration (e.g., Kubernetes) to limit memory and CPU for Loki pods.
- Monitoring: Alert on high memory usage and query timeouts.
- Update: Monitor for official patches from Grafana Labs and apply promptly.
Valters IT
Securing Digital Frontiers