Commit dca5ef1
Github Executorch
Fix XNNPACK FlatBuffer verification and header bounds checking (TOB-EXECUTORCH-33, TOB-EXECUTORCH-34)
TOB-EXECUTORCH-33: XNNCompiler::compileModel() processed FlatBuffer data
via fb_xnnpack::GetXNNGraph() without first running the FlatBuffer verifier.
A malformed or truncated payload could cause out-of-bounds reads when the
FlatBuffer library follows internal offset tables. This adds a
flatbuffers::Verifier pass (matching the pattern used in program.cpp) before
any FlatBuffer accessors are called, and tracks the flatbuffer_size so the
verifier knows the exact bounds of the serialized data.
TOB-EXECUTORCH-34: XNNHeader::Parse() read flatbuffer_offset,
flatbuffer_size, constant_data_offset, and constant_data_size from untrusted
header bytes but never validated that the resulting regions actually fit within
the provided buffer. Crafted offset/size values could point past the end of
the buffer, leading to out-of-bounds reads in compileModel(). This adds
overflow-safe bounds checks that ensure both the flatbuffer and constant data
regions fall within [0, size).
This PR was authored with the assistance of Claude.1 parent 21d9c64 commit dca5ef1
2 files changed
Lines changed: 43 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1816 | 1816 | | |
1817 | 1817 | | |
1818 | 1818 | | |
| 1819 | + | |
1819 | 1820 | | |
1820 | 1821 | | |
1821 | 1822 | | |
1822 | 1823 | | |
1823 | 1824 | | |
1824 | 1825 | | |
| 1826 | + | |
1825 | 1827 | | |
1826 | 1828 | | |
1827 | 1829 | | |
1828 | 1830 | | |
| 1831 | + | |
1829 | 1832 | | |
1830 | 1833 | | |
1831 | 1834 | | |
| |||
1843 | 1846 | | |
1844 | 1847 | | |
1845 | 1848 | | |
| 1849 | + | |
| 1850 | + | |
| 1851 | + | |
| 1852 | + | |
| 1853 | + | |
| 1854 | + | |
| 1855 | + | |
| 1856 | + | |
| 1857 | + | |
1846 | 1858 | | |
1847 | 1859 | | |
1848 | 1860 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
67 | 98 | | |
68 | 99 | | |
69 | 100 | | |
| |||
0 commit comments