Skip to content
DoS Disclosed report Intermediate CVE-2024-12055

Ollama Allows Out-of-Bounds Read

A malicious user could upload a crafted gguf model file to a public Ollama server, causing an out-of-bounds read in gguf.go when the server processes it. This crashes the server, resulting in a denial of service.

github.com/ollama/ollama

Originally disclosed on huntr

A vulnerability in Ollama versions <=0.3.14 allows a malicious user to create a customized gguf model file that can be uploaded to the public Ollama server. When the server processes this malicious model, it crashes, leading to a Denial of Service (DoS) attack. The root cause of the issue is an out-of-bounds read in the gguf.go file.

From the GitHub Advisory Database (GHSA-89qx-m49c-8crf, CC BY 4.0).

The original report as published on the GitHub Advisory Database. Images and videos are our own copies; raw HTML is shown as text. View it on GitHub Advisory Database.

The original is short, so this covers everything it reports, then explains this kind of bug in general: how it works, how to test for it and how it is fixed. The general sections are about the bug class, not this target. Written with AI and checked against the original; the original is the record. 4 min read.

What the report shows

The target is Ollama, an open source project for running large language models locally and on servers. The report covers versions up to and including 0.3.14. The feature involved is the handling of GGUF model files, the binary container format used to package models and their metadata.

The researcher's finding is that a malicious user can craft a customised GGUF model file and upload it to a public Ollama server. When the server processes that model, it crashes. The report describes the result as a denial of service.

The root cause is stated plainly: an out-of-bounds read in the gguf.go file. The report does not include a proof of concept, a crafted file, a request, a command or a stack trace, so there is no payload to reproduce here. It also gives no bounty amount and no fix commit. The report gives no bounty amount and no fix commit. The text is drawn from the GitHub Advisory Database entry GHSA-89qx-m49c-8crf.

Root cause

The report points to an out-of-bounds read in gguf.go. In practice this means the parser reads past the end of a buffer while interpreting the structure of an uploaded model file. GGUF files are attacker-controlled input: they carry a header, a metadata key/value section and tensor descriptors, each with lengths and counts that the parser must trust and validate. If a length or count in the file is inconsistent with the bytes actually present, a naive parser will index beyond the allocated buffer. The report does not say which specific field or code path is at fault, The report does not say which specific field or code path is at fault..

Impact

Within the report's own framing, the impact is availability: a crafted model file causes the server process to crash, which is a denial of service against that server. The report does not claim memory disclosure, code execution or any other consequence, and an out-of-bounds read does not by itself imply those. The precondition is that the attacker can get the file processed, which the report describes as uploading it to a public Ollama server.

How this kind of bug works

An out-of-bounds read happens when code computes an address outside the bounds of an allocated buffer and then reads from it. In binary format parsers the usual cause is trusting a length, count or offset taken from the input. The parser reads a 32-bit or 64-bit length, allocates or indexes accordingly, and then either loops that many times or seeks to that offset without checking it against the real size of the data. A short or inconsistent file then drives the read past the end of the buffer.

The consequences range from a crash, when the read lands on an unmapped page, to leaking adjacent memory into output or logs, when it does not. Parsers written in memory-safe languages turn such reads into a bounds-check panic rather than undefined behaviour, but the availability impact remains. The defences are structural: validate every length and offset against the remaining input before use, use checked arithmetic so that offset plus length cannot wrap, prefer slice or view types that carry their own bounds, and fuzz the parser with malformed and truncated inputs so that these paths are exercised continuously.

How to test for it

Look for features that accept a structured binary or serialised file and parse it server-side: model files, archives, image formats, document converters, import and restore endpoints. The interesting surface is wherever a length, count or offset field in the file controls a read.

  1. Obtain a valid sample file and confirm the normal path works.
  2. Mutate one field at a time: set length and count fields to zero, to one, to values larger than the file, and to values near the integer maximum. Truncate the file at each section boundary so that declared sizes exceed the bytes present.
  3. Submit each mutant through the same upload or import path a normal user would use, and watch the server's response, logs and process state.
  4. A positive result is a crash, a restart, a hang or an error that reveals memory contents. A clean rejection with a validation error is the expected safe behaviour.

Common false positives: a crash caused by resource exhaustion from a huge but well-formed file rather than a bounds error; a client-side crash in a local viewer rather than the server; and errors that come from a missing dependency or an unsupported format version. Confirm the crash is reproducible with a minimal file and that it disappears when the offending field is corrected.

How it is fixed

The standard fix is to add bounds checks at every point where an input-derived length or offset is used, rejecting the file with a clear error when the declared size exceeds the remaining data. Checked arithmetic prevents overflow in offset plus length calculations. Parsers should also cap counts and sizes to sane limits, validate section ordering, and fail closed on truncated input. Regression tests built from the crashing sample, plus a fuzzing harness over the parser, keep the fix from regressing.

Hunting notes

This class of bug hides in import, upload, restore and conversion features, especially where a custom binary format is parsed by hand rather than through a well-tested library. Recon signals include endpoints that accept model, archive or document files, format version negotiation, and error messages that mention parsing or offsets. Showing impact means demonstrating a reproducible crash or memory disclosure from a minimal crafted file, describing the precondition (who can upload), and stating clearly what the attacker gains. A crash alone is usually accepted as a denial of service; claiming more than the evidence shows weakens the report.

The original is short, so this covers everything it reports, then explains this kind of bug in general: how it works, how to test for it and how it is fixed. The general sections are about the bug class, not this target. Written with AI and checked against the original; the original is the record. 7 min read.

What happened, in plain words

Ollama is an open source project for running large language models (the software behind chat assistants) on your own computer or on a server. The report covers versions up to and including 0.3.14. The part of Ollama involved is how it handles GGUF model files. A GGUF file is a container, a single file that packages a model together with information about it, much like a box that holds both an object and a label describing it.

The finding is simple to state: a malicious user can build a customised GGUF model file and upload it to a public Ollama server. When the server processes that model, it crashes. The report calls this a denial of service, meaning the service stops working for everyone who relies on it.

The root cause is given plainly: an out-of-bounds read in the gguf.go file. The report does not include a proof of concept, a crafted file, a request, a command or a stack trace, so there is no payload to reproduce here. It also gives no bounty amount and no fix commit. The report gives no bounty amount and no fix commit. The text is drawn from the GitHub Advisory Database entry GHSA-89qx-m49c-8crf.

Root cause

The report points to an out-of-bounds read in gguf.go. To understand that, picture a reader working through a book with a bookmark. An out-of-bounds read is what happens when the reader is told to keep reading past the last page: the code asks for data at a position outside the memory it was given, and reads whatever lies there.

In practice this means the parser, the part of the program that interprets the structure of an uploaded model file, reads past the end of a buffer while doing its job. GGUF files are attacker-controlled input: they carry a header, a metadata key/value section and tensor descriptors, each with lengths and counts that the parser must trust and validate. If a length or count in the file is inconsistent with the bytes actually present, a naive parser will index beyond the allocated buffer. The report does not say which specific field or code path is at fault, The report does not say which specific field or code path is at fault..

Impact

Within the report's own framing, the impact is availability: a crafted model file causes the server process to crash, which is a denial of service against that server. The report does not claim memory disclosure, code execution or any other consequence, and an out-of-bounds read does not by itself imply those. The precondition is that the attacker can get the file processed, which the report describes as uploading it to a public Ollama server.

How this kind of bug works

In general, an out-of-bounds read happens when code computes an address outside the bounds of an allocated buffer and then reads from it. In binary format parsers the usual cause is trusting a length, count or offset taken from the input. The parser reads a 32-bit or 64-bit length, allocates or indexes accordingly, and then either loops that many times or seeks to that offset without checking it against the real size of the data. A short or inconsistent file then drives the read past the end of the buffer.

The consequences range from a crash, when the read lands on an unmapped page, to leaking adjacent memory into output or logs, when it does not. Parsers written in memory-safe languages turn such reads into a bounds-check panic rather than undefined behaviour, but the availability impact remains. The defences are structural: validate every length and offset against the remaining input before use, use checked arithmetic so that offset plus length cannot wrap, prefer slice or view types that carry their own bounds, and fuzz the parser with malformed and truncated inputs so that these paths are exercised continuously.

How to test for it

In general, look for features that accept a structured binary or serialised file and parse it server-side: model files, archives, image formats, document converters, import and restore endpoints. The interesting surface is wherever a length, count or offset field in the file controls a read.

  1. Obtain a valid sample file and confirm the normal path works.
  2. Mutate one field at a time: set length and count fields to zero, to one, to values larger than the file, and to values near the integer maximum. Truncate the file at each section boundary so that declared sizes exceed the bytes present.
  3. Submit each mutant through the same upload or import path a normal user would use, and watch the server's response, logs and process state.
  4. A positive result is a crash, a restart, a hang or an error that reveals memory contents. A clean rejection with a validation error is the expected safe behaviour.

Common false positives: a crash caused by resource exhaustion from a huge but well-formed file rather than a bounds error; a client-side crash in a local viewer rather than the server; and errors that come from a missing dependency or an unsupported format version. Confirm the crash is reproducible with a minimal file and that it disappears when the offending field is corrected.

How it is fixed

In general, the standard fix is to add bounds checks at every point where an input-derived length or offset is used, rejecting the file with a clear error when the declared size exceeds the remaining data. Checked arithmetic prevents overflow in offset plus length calculations. Parsers should also cap counts and sizes to sane limits, validate section ordering, and fail closed on truncated input. Regression tests built from the crashing sample, plus a fuzzing harness over the parser, keep the fix from regressing.

Hunting notes

In general, this class of bug hides in import, upload, restore and conversion features, especially where a custom binary format is parsed by hand rather than through a well-tested library. Recon signals include endpoints that accept model, archive or document files, format version negotiation, and error messages that mention parsing or offsets. Showing impact means demonstrating a reproducible crash or memory disclosure from a minimal crafted file, describing the precondition (who can upload), and stating clearly what the attacker gains. A crash alone is usually accepted as a denial of service; claiming more than the evidence shows weakens the report.

Glossary

  • Ollama: an open source project for running large language models locally and on servers.
  • Large language model: software trained on text that can generate or analyse language.
  • GGUF: a binary container format used to package models and their metadata in one file.
  • Model file: a file holding a model and the information needed to load it.
  • Server: a computer program that provides a service to other computers over a network.
  • Denial of service (DoS): an attack that makes a service stop working for its normal users.
  • Out-of-bounds read: reading data from a position outside the memory buffer the program was given.
  • Buffer: a block of memory set aside to hold data.
  • Parser: the part of a program that reads a file and interprets its structure.
  • Header: the opening section of a file that describes what follows.
  • Metadata: data that describes other data, such as names and settings.
  • Tensor descriptor: an entry in a model file that describes a block of numeric model data.
  • Length, count, offset: numbers in a file that say how much data follows, how many items there are, or where a section starts.
  • Malformed input: a file that does not follow the format's rules.
  • Truncated file: a file cut short so that it ends before its declared content does.
  • Crash: an abrupt stop of a program, usually because it hit an error it could not handle.
  • Memory disclosure: leaking the contents of memory to someone who should not see it.
  • Code execution: making a program run code the attacker supplied.
  • Availability: whether a service is up and usable when people need it.
  • Bounds check: a test that confirms a position lies inside the allowed memory before it is used.
  • Checked arithmetic: arithmetic that detects overflow instead of silently wrapping around.
  • Integer overflow: a calculation that produces a number too large for its type and wraps to a small value.
  • Fuzzing: feeding a program many malformed or random inputs to find crashes automatically.
  • Proof of concept: a small demonstration that shows a vulnerability is real.
  • Stack trace: a report of the function calls a program was making when it failed.
  • Severity: a rating of how serious a vulnerability is.
  • CVSS: a standard scoring system for vulnerability severity.
  • GitHub Advisory Database: a public collection of security advisories for open source software.
  • GHSA-89qx-m49c-8crf: the identifier of the advisory this report is drawn from.

More from github.com/ollama/ollama

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.