onnxruntime
bca9d15b - Harden shape inference for contrib ops (#32607)

Commit
10 days ago
Harden shape inference for contrib ops (#32607) ### Summary Strengthens attribute/input validation in three contrib-op shape-inference functions in bert_defs.cc so malformed or malicious models are rejected at `Graph::Resolve` instead of triggering out-of-bounds reads or signed-integer overflow during shape inference. ### Changes `CausalConvWithState`: validate the ndim attribute is in [1, 3] and cross-check tensor ranks against it (weight == ndim+2, channels-first input == ndim+2, channels-last input >= 3) before the spatial-dim loop indexes input.dim(2+i). Previously only a rank >= 2 guard existed, so ndim=2/3 with a low-rank input read past the shape's dimensions. `GatedDeltaNet`: require the head counts/sizes to be positive and add step-by-step overflow guards before computing the state_update capsule width, preventing signed int64 overflow (UB) in state_update_capacity * (num_heads_v + num_heads_k*head_size_qk + num_heads_v*head_size_v). `GroupQueryAttention` / `SparseAttention`: check the parsed `total_sequence_length` initializer is non-empty before indexing data[0].
Author
Parents
Loading