OSEC-2026-20

See a problem?
Import Source
https://github.com/ocaml/security-advisories/blob/generated-osv/2026/OSEC-2026-20.json
JSON Data
https://api.osv.dev/v1/vulns/OSEC-2026-20
Aliases
  • CVE-2026-89087
Published
2026-09-10T10:00:00Z
Modified
2026-09-10T20:30:04Z
Severity
  • 7.3 (High) CVSS_V3 - CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L CVSS Calculator
Summary
Cstruct indexing bugs can corrupt filtered output and reverse parsing results
Details

Several functions in cstruct may use wrong data, leading to unexpected exceptions and return corrupted data.

Impact

  • Cstruct.filter_map writes retained bytes at their original input positions, producing corrupted output when earlier bytes are dropped.
  • Cstruct.tail ~rev:true removes two bytes instead of one and raises an exception for single-byte views.
  • Cstruct.cuts ~rev:true may compare input against the wrong data, split at incorrect positions, and construct results using offsets outside the requested view.
  • Cstruct.find and Cstruct.find_sub ~rev:true may 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
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"
}
References
Credits
    • Anil Madhavapeddy - REPORTER
    • Thomas Gazagnaire - REMEDIATION_REVIEWER
    • Anil Madhavapeddy - REMEDIATION_DEVELOPER

Affected packages

opam / cstruct

Package

Name
cstruct
Purl
pkg:opam/cstruct

Affected ranges

Type
ECOSYSTEM
Events
Introduced
0 Unknown introduced version / All previous versions are affected
Fixed
6.3.0
Type
GIT
Repo
https://github.com/mirage/ocaml-cstruct
Events
Introduced
0 Unknown introduced commit / All previous commits are affected
Fixed

Affected versions

0.*
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.*
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.*
2.0.0
2.1.0
2.2.0
2.3.0
2.3.1
2.3.2
2.4.1
3.*
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.*
4.0.0
5.*
5.0.0
5.1.1
5.2.0
6.*
6.0.0
6.0.1
6.1.0
6.1.1
6.2.0
ocaml-cstruct-0.*
ocaml-cstruct-0.3
ocaml-cstruct-0.4.0
ocaml-cstruct-0.5.0
ocaml-cstruct-0.5.1
ocaml-cstruct-0.5.2
ocaml-cstruct-0.5.3
ocaml-cstruct-0.6.1
ocaml-cstruct-0.7.0
ocaml-cstruct-0.7.1
v0.*
v0.8.0
v0.8.1
v1.*
v1.0.0
v1.0.1
v1.2.0
v1.3.0
v1.3.1
v1.4.0
v1.5.0
v1.6.0
v1.8.0
v1.9.0
v2.*
v2.0.0
v2.1.0
v2.2.0
v2.3.0
v2.3.1
v2.3.2
v2.3.3
v2.4.0
v2.4.1
v3.*
v3.0.0
v3.0.1
v3.0.2
v3.1.0
v3.1.1
v3.2.0
v3.2.1
v3.3.0
v3.4.0
v3.5.0
v3.6.0
v3.7.0
v4.*
v4.0.0
v5.*
v5.0.0
v5.1.0
v5.1.1
v5.2.0
v6.*
v6.0.0
v6.1.0
v6.1.1

Ecosystem specific

{
    "affected_bindings": [
        "Cstruct.filter_map",
        "Cstruct.tail",
        "Cstruct.cuts",
        "Cstruct.find",
        "Cstruct.find_rev"
    ],
    "opam_constraint": "cstruct {< \"6.3.0\"}"
}

Database specific

source
"https://github.com/ocaml/security-advisories/blob/generated-osv/2026/OSEC-2026-20.json"