pytorch / pytorch/executorch

Safely deserialize inputs/buffers/tensors from the PTE file.

Open
#16,810 0 comments 0 reactions 1 assignee View on GitHub

@lucylq is already working on this.

Since Jan 23, 2026.

Dominant language
Python
Stars
5k
Forks
1.2k
Avg merge
2d 10h
Merged PRs (30d)
581

Description

Recommendations from report.

Consider using a safer abstraction for deserializing scalar values from buffers
that encapsulates the size check. A templated helper function that reads exactly
sizeof(T) bytes and fails if insufficient data is available would eliminate the possibility of
introducing similar vulnerabilities in future code paths handling external data.

Implement comprehensive input validation for all fields in .pte files during
deserialization, before any memory operations are performed. Add range checks that
reject invalid values, such as offsets near SIZE_MAX or sizes exceeding reasonable model
data limits.

Implement validation at the PTE parsing layer to reject tensor specifications with
dimensions that would cause overflow when computing byte sizes. Additionally, modify the
torch::executor::HierarchicalAllocator::get_offset_address validation to
reject size_bytes = 0 for tensors with numel > 0, as this combination indicates a
calculation error.

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.