osec-2026-20
Vulnerability from osv_ocaml
Several functions in cstruct may use wrong data, leading to unexpected exceptions and return corrupted data.
Impact
Cstruct.filter_mapwrites retained bytes at their original input positions, producing corrupted output when earlier bytes are dropped.Cstruct.tail ~rev:trueremoves two bytes instead of one and raises an exception for single-byte views.Cstruct.cuts ~rev:truemay compare input against the wrong data, split at incorrect positions, and construct results using offsets outside the requested view.Cstruct.findandCstruct.find_sub ~rev:truemay return slices from the wrong location when operating on non-zero-offset views.
These are a set of logical indexing and bounds-calculation errors (CWE-682), and not direct memory-safety vulnerabilities. However, affected operations may return corrupted data, raise an unexpected exception, split input incorrectly, or return bytes outside the requested Cstruct view but still within its backing buffer.
In security-sensitive parsers, this could cause validation bypasses, denial of service, or unintended disclosure of adjacent buffer contents.
Workarounds
Users unable to upgrade cstruct should backport the corresponding source changes. There is no configuration-based mitigation since these are buggy library calls.
References
Discovered via Scrutineer and Deepseek GLM-5.3 Flash running locally.
Timeline
- 2026-09-04: reported via GitHub to ocaml/security-advisories repository
- 2026-09-05: reported via email to security@ocaml.org
- 2026-09-05: patch proposed and reviewed
- 2026-09-05: release cstruct 6.3.0
- 2026-09-10: published advisory
| URL | Type | |
|---|---|---|
{
"affected": [
{
"ecosystem_specific": {
"affected_bindings": [
"Cstruct.filter_map",
"Cstruct.tail",
"Cstruct.cuts",
"Cstruct.find",
"Cstruct.find_rev"
],
"opam_constraint": "cstruct {\u003c \"6.3.0\"}"
},
"package": {
"ecosystem": "opam",
"name": "cstruct",
"purl": "pkg:opam/cstruct"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "6.3.0"
}
],
"type": "ECOSYSTEM"
},
{
"events": [
{
"introduced": "0"
},
{
"fixed": "936f1010d3e9914da9c5c8a4739e9278a37e1c3e"
}
],
"repo": "https://github.com/mirage/ocaml-cstruct",
"type": "GIT"
}
],
"versions": [
"0.4.0",
"0.4.1",
"0.5.0",
"0.5.1",
"0.5.2",
"0.5.3",
"0.6.0",
"0.6.1",
"0.6.2",
"0.7.0",
"0.7.1",
"0.8.0",
"0.8.1",
"1.0.0",
"1.0.1",
"1.1.0",
"1.2.0",
"1.3.0",
"1.3.1",
"1.4.0",
"1.5.0",
"1.6.0",
"1.7.0",
"1.7.1",
"1.8.0",
"1.9.0",
"2.0.0",
"2.1.0",
"2.2.0",
"2.3.0",
"2.3.1",
"2.3.2",
"2.4.1",
"3.0.0",
"3.0.1",
"3.0.2",
"3.1.0",
"3.1.1",
"3.2.0",
"3.2.1",
"3.3.0",
"3.4.0",
"3.5.0",
"3.6.0",
"3.7.0",
"4.0.0",
"5.0.0",
"5.1.1",
"5.2.0",
"6.0.0",
"6.0.1",
"6.1.0",
"6.1.1",
"6.2.0"
]
}
],
"aliases": [
"CVE-2026-89087"
],
"credits": [
{
"name": "Anil Madhavapeddy",
"type": "REPORTER"
},
{
"name": "Thomas Gazagnaire",
"type": "REMEDIATION_REVIEWER"
},
{
"name": "Anil Madhavapeddy",
"type": "REMEDIATION_DEVELOPER"
}
],
"database_specific": {
"cwe": [
"CWE-682"
],
"human_link": "https://github.com/ocaml/security-advisories/tree/main/advisories/2026/OSEC-2026-20.md",
"osv": "https://github.com/ocaml/security-advisories/tree/generated-osv/2026/OSEC-2026-20.json"
},
"details": "Several functions in cstruct may use wrong data, leading to unexpected exceptions and return corrupted data.\n\n## Impact\n\n- `Cstruct.filter_map` writes retained bytes at their original input positions, producing corrupted output when earlier bytes are dropped.\n- `Cstruct.tail ~rev:true` removes two bytes instead of one and raises an exception for single-byte views.\n- `Cstruct.cuts ~rev:true` may compare input against the wrong data, split at incorrect positions, and construct results using offsets outside the requested view.\n- `Cstruct.find` and `Cstruct.find_sub ~rev:true` may return slices from the wrong location when operating on non-zero-offset views.\n\nThese are a set of logical indexing and bounds-calculation errors (CWE-682), and not direct memory-safety vulnerabilities. However, affected operations may return corrupted data, raise an unexpected exception, split input incorrectly, or return bytes outside the requested Cstruct view but still within its backing buffer.\n\nIn security-sensitive parsers, this could cause validation bypasses, denial of service, or unintended disclosure of adjacent buffer contents.\n\n## Workarounds\n\nUsers unable to upgrade cstruct should backport the corresponding source changes. There is no configuration-based mitigation since these are buggy library calls.\n\n## References\n\nDiscovered via [Scrutineer](https://github.com/alpha-omega-security/scrutineer) and Deepseek GLM-5.3 Flash running locally.\n\n## Timeline\n\n- 2026-09-04: reported via GitHub to ocaml/security-advisories repository\n- 2026-09-05: reported via email to security@ocaml.org\n- 2026-09-05: patch proposed and reviewed\n- 2026-09-05: release cstruct 6.3.0\n- 2026-09-10: published advisory",
"id": "OSEC-2026-20",
"modified": "2026-09-10T20:20:00Z",
"published": "2026-09-10T10:00:00Z",
"references": [
{
"type": "FIX",
"url": "https://github.com/mirage/ocaml-cstruct/pull/324"
}
],
"schema_version": "1.7.4",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L",
"type": "CVSS_V3"
}
],
"summary": "Cstruct indexing bugs can corrupt filtered output and reverse parsing results"
}
Sightings
| Author | Source | Type | Date | Other |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.
The approach is described in our paper Mapping CVEs to MITRE ATT&CK Techniques: A Curated Gold-Set Classifier and the Limits of LLM-Assisted Label Expansion.