Skip to content

Fix: OpenVINO EP DeserializeImpl allows unbounded uint64 allocation#1158

Open
vthaniel wants to merge 1 commit into
ovep-developfrom
fix_security_issues
Open

Fix: OpenVINO EP DeserializeImpl allows unbounded uint64 allocation#1158
vthaniel wants to merge 1 commit into
ovep-developfrom
fix_security_issues

Conversation

@vthaniel

@vthaniel vthaniel commented Jun 23, 2026

Copy link
Copy Markdown

Description

Added bounds check which will throw if certain BSON fields does not lie fully within the stream.
Added testcase to simulate this scenario

Motivation and Context

OpenVINO EP DeserializeImpl allows unbounded uint64 allocation, which can create security issues
This PR adds a bounds check to fix this

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Hardens OpenVINO EP-context cache deserialization against malicious/corrupted OVEP_BIN payloads that can trigger unbounded allocations by validating advertised BSON/blob ranges against the actual stream size, and adds a regression test exercising the failure path.

Changes:

  • Adds stream-size-based bounds checking for the BSON region prior to BSON allocation/parse.
  • Adds stream-size-based bounds checking for embedded blob ranges prior to allocating/reading blob data.
  • Adds a unit test that embeds a crafted OVEP_BIN header in an EPContext node and asserts deserialization rejects an oversized BSON region.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
onnxruntime/core/providers/openvino/ov_bin_manager.cc Adds stream-size calculation and range validation for BSON and embedded blob allocations during deserialization.
onnxruntime/test/providers/openvino/openvino_ep_context_test.cc Adds regression test building an embedded EPContext model with a malicious OVEP_BIN header to ensure deserialization fails safely.

Comment on lines +352 to +355
stream.seekg(0, std::ios::end);
ORT_ENFORCE(stream.good(), "Error: Failed to seek to end of stream.");
const uint64_t stream_size = static_cast<uint64_t>(stream.tellg());

Comment on lines +166 to +168
std::string model_data;
model.SerializeToString(&model_data);
return model_data;
Comment on lines +188 to +190
auto& logging_manager = DefaultLoggingManager();
logging_manager.SetDefaultLoggerSeverity(logging::Severity::kERROR);

@n1harika n1harika left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vthaniel LGTM. We need this change as the blob size is deserialized from disk, not memory, here:

uint64_t blob_size = blob_entry[BSONFields::kSize].get<uint64_t>();

Since the file can be corrupted, this is a robustness check.

In ABI-EP, the bin file is memory mapped first: https://github.com/intel-innersource/frameworks.ai.onnxruntime.openvino-plugin-ep/blob/39d6af4d734e0e8c91f40cf31e1b5eebef036a9f/plugin_impl/ov_bin_manager.cc#L165 and then the blob size is checked here: https://github.com/intel-innersource/frameworks.ai.onnxruntime.openvino-plugin-ep/blob/39d6af4d734e0e8c91f40cf31e1b5eebef036a9f/plugin_impl/ov_bin_manager.cc#L215

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants