/

CVE-2025-66960

Severity:

HIGH RISK

(7.5)

Improper Input Validation / Denial of Service

CVE-2025-66960

Analyzed

Vulnerability type

Category:

Improper Input Validation / Denial of Service

CWE:

CWE-20, CWE-400

Impact:

Denial of Service via Uncontrolled Resource Consumption

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Ollama v0.12.10 contains an input validation flaw in its GGUF metadata parser, where the readGGUFV1String function trusts a string length value taken directly from untrusted model metadata.

A remote attacker who can supply crafted GGUF data may trigger excessive memory allocation or processing, leading to denial of service (DoS) of the Ollama service.

Affected context

The vulnerability occurs in Ollama's handling of GGUF model files, specifically when parsing metadata fields from untrusted inputs.

When readGGUFV1String reads a string length from the GGUF metadata, it does not sufficiently constrain or validate the value before using it.

Environments that accept or load GGUF models from external or user-supplied sources, including remote model repositories or uploads, are more exposed to this issue.

Exploit preconditions

  • Attack surface: GGUF model ingestion/parsing interface (e.g., loading or importing GGUF models in Ollama).
  • Required access: Ability to provide or influence a GGUF file or stream that Ollama will parse.
  • Trigger point: Invocation of the readGGUFV1String function during GGUF metadata parsing.
  • Why exploitation is possible: The parser uses a length value directly from untrusted metadata without adequate bounds checking or sanity limits, leading to potentially large allocations or prolonged processing.

Why this happens

The core issue maps to CWE-20: Improper Input Validation combined with CWE-400: Uncontrolled Resource Consumption.

The GGUF parsing logic assumes that the length field in metadata is well-formed and reasonable, failing to enforce constraints such as maximum allowed size, structural validity, or defensive limits.

As a result, a crafted GGUF file can cause the application to allocate excessive memory, read large amounts of data, or otherwise consume CPU and I/O cycles until service responsiveness degrades or the process fails.

Potential impact

  • Ollama process may consume excessive memory, leading to crashes or out-of-memory conditions.
  • CPU and I/O resources can be exhausted, degrading performance for legitimate users.
  • Service unavailability or timeouts for model loading and inference operations.
  • Potential cascading impact on shared infrastructure if Ollama runs on multi-tenant systems.

General mitigation guidance

Effective mitigation generally involves strengthening input validation and applying robust resource limits at the parsing boundary:

  • Enforce strict maximum lengths for strings and other variable-size fields in GGUF metadata before allocation or read operations.
  • Introduce sanity checks to reject malformed, inconsistent, or excessively large metadata values early in the parsing pipeline.
  • Apply defensive programming patterns such as capped allocation sizes, read quotas, and early bail-out on suspicious inputs.
  • Run the model loading component under resource quotas (memory/CPU limits, container cgroups) so that abuse of parsing logic cannot easily impact the wider host.
  • Treat all externally supplied model artifacts as untrusted data, applying the same scrutiny as other file upload or network input surfaces.

How teams detect issues like this

Detection tends to focus on both code-level patterns and runtime behavior:

  • Static analysis / code review:
  • Flag uses of length or size values derived directly from external data without range checks.
  • Look for parsing code that allocates buffers or slices based solely on untrusted metadata fields.
  • Examine GGUF parsing routines for absence of global or per-field size limits.
  • Runtime monitoring:
  • Track memory and CPU spikes correlated with GGUF model loading operations.
  • Use logs to detect repeated failures or timeouts during metadata parsing.
  • Policy and tooling:
  • Integrate automated scanners or linters that detect unsafe allocation patterns and missing bounds checks.
  • Enforce architectural guidelines that any file-format parser must define explicit maximums for dynamic fields.

Sources

SourceLink
github.comgithub.com/ollama/ollama/issues/9820
zero.shotlearni.ngzero.shotlearni.ng/blog/cve-2025-66960guf-v1-string-length-cause-panic-in-readggufv1string/

Frequently asked

questions

Exploitability depends on whether an attacker can supply or influence GGUF models that Ollama will parse. In deployments that only load trusted, pre-vetted models, exposure is reduced; in environments accepting external or user-submitted models, the risk is higher.

Not necessarily. The key requirement is the ability to feed a crafted GGUF file into the system. If model uploads, imports, or downloads from untrusted locations are possible without strong controls, an unauthenticated attacker may leverage that path.

Implement strict, centralized validation of all variable-length fields in GGUF metadata, including hard upper bounds, consistency checks, and graceful rejection of oversized or malformed inputs before allocating resources based on them.

Treat all file formats and model artifacts as untrusted input, enforce defensive limits in every parser, establish coding guidelines for safe allocation from external lengths, and use automated reviews or static analysis to catch missing bounds checks early in development.

Find out what's already
exploitable in your codebase.