/

CVE-2026-62958

Severity:

HIGH RISK

(7.9)

Out-of-Bounds Read (CWE-125) in libriscv ELF Binary Loader

CVE-2026-62958

Deferred

Vulnerability type

Category:

Out-of-Bounds Read

CWE:

CWE-20, CWE-125

Impact:

Host Process Crash and Potential Memory Disclosure

Severity:

HIGH RISK

(7.9)

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

A malformed RISC-V ELF binary can cause libriscv to read outside its host emulator buffer because section-header offsets and sizes are not consistently checked against the binary length. This may crash the emulator and, under certain memory layouts or integer-overflow conditions, could expose out-of-buffer host memory to the guest.

A malformed RISC-V ELF binary can cause libriscv to read outside its host emulator buffer because section-header offsets and sizes are not consistently checked against the binary length. This may crash the emulator and, under certain memory layouts or integer-overflow conditions, could expose out-of-buffer host memory to the guest.

Affected context

The issue occurs in libriscv versions before 1.18 when the emulator loads or examines crafted ELF binaries. Although program-header bounds are checked, paths handling the .text and .symtab sections may trust section-header offsets and sizes without confirming that the referenced ranges remain within the loaded binary buffer.

The issue occurs in libriscv versions before 1.18 when the emulator loads or examines crafted ELF binaries. Although program-header bounds are checked, paths handling the .text and .symtab sections may trust section-header offsets and sizes without confirming that the referenced ranges remain within the loaded binary buffer.

Exploit preconditions

  • Attack surface: ELF binary loading and section-table processing in the host emulator - Required access: Ability to supply or cause the emulator to process a crafted ELF binary - Trigger point: Processing of .text or .symtab section metadata during loading or lookup - Why exploitation is possible: Section-header ranges can bypass program-header checks and reference data outside the host binary buffer
  • Attack surface: ELF binary loading and section-table processing in the host emulator - Required access: Ability to supply or cause the emulator to process a crafted ELF binary - Trigger point: Processing of .text or .symtab section metadata during loading or lookup - Why exploitation is possible: Section-header ranges can bypass program-header checks and reference data outside the host binary buffer

Why this happens

The underlying bug is incomplete validation of externally controlled integer offsets and sizes before buffer access. The loader validates some program-header ranges but does not apply equivalent file-bound checks to section-header values used by serialize_execute_segment() and lookup(). This maps primarily to CWE-125, Out-of-bounds Read, and is also related to CWE-20 because malformed input is accepted without comprehensive validation.

The underlying bug is incomplete validation of externally controlled integer offsets and sizes before buffer access. The loader validates some program-header ranges but does not apply equivalent file-bound checks to section-header values used by serialize_execute_segment() and lookup(). This maps primarily to CWE-125, Out-of-bounds Read, and is also related to CWE-20 because malformed input is accepted without comprehensive validation.

Potential impact

  • A crafted ELF file may crash the host emulator with a segmentation fault.
  • The emulator could read unintended host heap memory.
  • Host memory contents may potentially become visible to guest code under suitable memory-layout conditions.
  • Availability of services relying on rvlinux may be disrupted.
  • A crafted ELF file may crash the host emulator with a segmentation fault.
  • The emulator could read unintended host heap memory.
  • Host memory contents may potentially become visible to guest code under suitable memory-layout conditions.
  • Availability of services relying on rvlinux may be disrupted.

General mitigation guidance

Mitigation generally focuses on treating all ELF metadata as untrusted and validating every offset-plus-size range before it is used. Secure patterns include centralizing checked range arithmetic, rejecting arithmetic overflow, requiring section and segment ranges to remain within the complete input buffer, and avoiding unchecked conversions between integer types. Parsing should fail closed before any guest mapping or host buffer access occurs. Running the emulator with least privilege, isolation, and restricted access to sensitive host resources can reduce the impact of a parser failure.

Mitigation generally focuses on treating all ELF metadata as untrusted and validating every offset-plus-size range before it is used. Secure patterns include centralizing checked range arithmetic, rejecting arithmetic overflow, requiring section and segment ranges to remain within the complete input buffer, and avoiding unchecked conversions between integer types. Parsing should fail closed before any guest mapping or host buffer access occurs. Running the emulator with least privilege, isolation, and restricted access to sensitive host resources can reduce the impact of a parser failure.

How teams detect issues like this

Detection can include static analysis for unchecked additions, subtractions, casts, and buffer indexing involving ELF offsets or sizes. Code review should look for inconsistent validation between program headers and section headers, especially before segment creation and symbol lookup. Fuzzing malformed ELF files with address sanitizers, undefined-behavior sanitizers, boundary-value metadata, and integer-overflow checks can reveal crashes and unintended memory accesses. CI policy can require parser fuzzing and checked-range helpers for binary-format handling.

Detection can include static analysis for unchecked additions, subtractions, casts, and buffer indexing involving ELF offsets or sizes. Code review should look for inconsistent validation between program headers and section headers, especially before segment creation and symbol lookup. Fuzzing malformed ELF files with address sanitizers, undefined-behavior sanitizers, boundary-value metadata, and integer-overflow checks can reveal crashes and unintended memory accesses. CI policy can require parser fuzzing and checked-range helpers for binary-format handling.

Sources

SourceLink
github.comgithub.com/libriscv/libriscv/commit/61ef9ca82c8876dd80b33780893ba512af780e93
github.comgithub.com/libriscv/libriscv/commit/7bd1c189f9f9d54368cde096b07b194ad680f9fa
github.comgithub.com/libriscv/libriscv/releases/tag/v1.18
github.comgithub.com/libriscv/libriscv/security/advisories/GHSA-gm4g-6c78-gr3w

Frequently asked

questions

It can be reached wherever an attacker can supply an ELF binary to a

libriscv-based service or cause such a service to process one. Exploitability

depends on how the emulator is exposed and how untrusted binaries are handled.

The attacker needs a way to provide or influence an ELF file processed by the

emulator. Direct access to the host is not necessarily required if a service

accepts guest binaries remotely.

Validate every section and segment offset and size against the complete input

buffer using overflow-safe range arithmetic, and reject malformed binaries

before mapping or reading their contents.

Use centralized bounds-checking helpers, fuzz binary parsers, enable memory

safety instrumentation in testing, apply least privilege and isolation, and

include malformed-format validation rules in code review and CI policies.

It can be reached wherever an attacker can supply an ELF binary to a

libriscv-based service or cause such a service to process one. Exploitability

depends on how the emulator is exposed and how untrusted binaries are handled.

The attacker needs a way to provide or influence an ELF file processed by the

emulator. Direct access to the host is not necessarily required if a service

accepts guest binaries remotely.

Validate every section and segment offset and size against the complete input

buffer using overflow-safe range arithmetic, and reject malformed binaries

before mapping or reading their contents.

Use centralized bounds-checking helpers, fuzz binary parsers, enable memory

safety instrumentation in testing, apply least privilege and isolation, and

include malformed-format validation rules in code review and CI policies.

Find out what's already
exploitable in your codebase.