Skip to content

Memory access violation when execute optimization and inference #23258

@Cookiee235

Description

@Cookiee235

Describe the issue

A crash occurs when creating an ONNX Runtime inference session with the ORT_ENABLE_BASIC graph optimization level. The issue causes a memory access violation (segmentation fault) during session initialization, resulting in the process exiting with code -1073741819 (0xC0000005). This crash is linked to improper handling of graph optimizations in ONNX Runtime. It may disrupt systems relying on ONNX for model inference, leading to potential denial of service. This vulnerability is triggered specifically by the use of the ORT_ENABLE_BASIC optimization level.

Callstack
Process finished with exit code -1073741819 (0xC0000005)

To reproduce

  1. Install ONNXRuntime using pip.
pip install onnxruntime==1.19.2
  1. Download the ONNX model via this link model:
    Execute the following Python script:
import onnxruntime as rt

sess_options = rt.SessionOptions()
sess_options.graph_optimization_level = rt.GraphOptimizationLevel.ORT_ENABLE_BASIC  # Only enabling the optimization can lead to this vulnerability
session = rt.InferenceSession("transpose_opt.onnx", sess_options)  # crash here

### Urgency

_No response_

### Platform

Linux

### OS Version

Ubuntu 20.04

### ONNX Runtime Installation

Released Package

### ONNX Runtime Version or Commit ID

1.19.2

### ONNX Runtime API

Python

### Architecture

X64

### Execution Provider

Default CPU

### Execution Provider Library Version

_No response_

Metadata

Metadata

Assignees

No one assigned

    Labels

    core runtimeissues related to core runtime

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions