pytorch / pytorch/executorch

[Arm/Ethos-U] vela_bin_stream parser does not bounds-check block sizes or IO descriptors

Open
#22,579 1 comment 0 reactions 2 assignees View on GitHub

@usamahz is already working on this.

Since Sep 11, 2026.

bug module: arm partner: arm security-fix triaged
Dominant language
Python
Stars
5k
Forks
1.2k
Avg merge
2d 10h
Merged PRs (30d)
581

Description

[Arm/Ethos-U] vela_bin_stream parser does not bounds-check block sizes or IO descriptors

🐛 Describe the bug

The Ethos-U runtime parser vela_bin_read() in
backends/arm/runtime/VelaBinStream.cpp reads per-block size fields and the
inputs/outputs descriptor counts and offsets straight from the delegate blob
without validating them against the buffer:

  • The per-block size field advances the parse cursor and defines each block's
    payload with no check that it fits in the remaining bytes, so a block can point
    its payload (and the cursor) past the end of the delegate buffer.
  • An inputs/outputs block payload is reinterpret_cast to VelaIOs
    ({ int count; VelaIO io[]; }) with no check that the payload is large enough
    to hold count entries.
  • At execute time (EthosUBackend.cpp, EthosUBackend_Cortex_M.cpp) the
    io[i].offset and count values from the blob are used to index the scratch
    buffer and the delegate args span with no bound.

The only pre-parse check, vela_bin_validate(), validates alignment and the
vela_bin_stream/vela_end_stream magic strings; it does not inspect any block
size. As a result a malformed or corrupt delegate blob can cause
out-of-bounds reads at model-load time and out-of-bounds access when copying
to/from the Ethos-U scratch buffer at execute time.

This is a memory-safety hardening gap: sibling backends already validate their
delegate blob before use (XNNPACK runs a FlatBuffer verifier, Vulkan bounds-checks
offsets, the Qualcomm delegate was bounds-checked in #22237). The Ethos-U parser
was not covered by that hardening pass.

Affected files
  • backends/arm/runtime/VelaBinStream.cpp
  • backends/arm/runtime/EthosUBackend.cpp
  • backends/arm/runtime/EthosUBackend_Cortex_M.cpp
Versions

Present on main (verified at bf88c643ce); the parser has never had these
bounds checks.

Fix

A fix that adds the missing bounds validation and negative tests is in the linked
PR.

cc @digantdesai @freddan80 @per @zingo @oscarandersson8218 @mansnils @Sebastian-Larsson @robell @rascani

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.