Reject nodes that feed inputs to a zero-input operator schema - #32633
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
🟡 Changes recommended
The new validation path needs a regression test covering the previously crashing model-local function scenario.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds validation to prevent out-of-bounds access when a model-local function declares no inputs but receives inputs.
Changes:
- Rejects mismatched zero-input schemas with a clear error.
- Simplifies input-count adjustment after handling the empty-schema case.
File summaries
| File | Description |
|---|---|
onnxruntime/core/graph/graph.cc |
Validates zero-input operator/function nodes during graph resolution. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Hi, Dmitri Smirnov (@yuslepukhin), could you please take a look? This PR is for security hardening. |
|
FYI, test result without the fix:
|
613bc03
into
microsoft:main
Description
Add an explicit validation in
Node::UpdateInputArgCount()to reject a node that supplies actual inputs while its bound operator/function schema declares no formal input parameters.Motivation and Context
When
op.inputs()is empty but the node has ≥1 input, the arg-count adjustment loop was skipped yet the trailinginput_arg_count.push_back(arg_count_left)still ran unconditionally, producingInputArgCount().size() == 1againstop.inputs().size() == 0. This size-invariant violation later caused an out-of-bounds read atop.inputs()[i]inInferAndVerifyTypeMatchduringGraph::Resolve().This is reachable only via a model-local function in a custom domain: for registered ops,
OpSchema::Verifyin the ONNX checker rejects the extra inputs first, but for custom-domain function calls the checker performs no arity validation.