Add bounds validation for LinearClassifier coefficients
Merged
VR
7mo ago+56+56+01234567890123456789-0-0-0123456789
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_ > 0andcoefficients_.size() % class_count_ == 0 - Compute(): Validate
coefficients_.size() == class_count * num_featuresbefore 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.