Safely deserialize inputs/buffers/tensors from the PTE file.
@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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.