Commit 9c90e79
authored
Add bounds validation for LinearClassifier coefficients (#27989)
### Description
Add input validation to the LinearClassifier operator to prevent an
out-of-bounds heap read in GEMM when a crafted model provides mismatched
coefficients/intercepts sizes.
Fixes
https://portal.microsofticm.com/imp/v5/incidents/details/31000000559851/summary
### Changes
- **Constructor**: Validate `class_count_ > 0` and `coefficients_.size()
% class_count_ == 0`
- **Compute()**: Validate `coefficients_.size() == class_count *
num_features` before GEMM call
- **Tests**: Two regression tests for invalid coefficient sizes
### Motivation and Context
MSRC case 109185 (VULN-176698): OOB read via GEMM from crafted model in
LinearClassifier operator. Root cause is missing validation that the
coefficients vector size matches `[class_count, num_features]` before
passing raw pointers to GEMM.1 parent 127704c commit 9c90e79
2 files changed
Lines changed: 56 additions & 0 deletions
File tree
- onnxruntime
- core/providers/cpu/ml
- test/providers/cpu/ml
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
39 | 45 | | |
40 | 46 | | |
41 | 47 | | |
| |||
146 | 152 | | |
147 | 153 | | |
148 | 154 | | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
149 | 163 | | |
150 | 164 | | |
151 | 165 | | |
| |||
Lines changed: 42 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
169 | 211 | | |
170 | 212 | | |
0 commit comments