Vulnerabilities in pkg:pypi/qiskit-ibm-runtime

PACKAGE
Advisory Identifier: GHSA-x4x5-jv3x-9c7m
Advisory Summary

CVE-2024-29032 is a MODERATE (CVSS 5.3) `qiskit_ibm_runtime.runtimedecoder` can execute arbitrary code vulnerability (CWE-502: Deserialization of Untrusted Data) affecting Qiskit ibm runtime libraries in the PyPI ecosystem. The issue involves `qiskit_ibm_runtime.runtimedecoder` can execute arbitrary code. Remediation is available by upgrading affected packages to version 0.21.2.

2 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:pypi/qiskit-ibm-runtime

2 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:pypi/qiskit-ibm-runtime. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-x4x5-jv3x-9c7m CVE-2024-29032 MODERATE `qiskit_ibm_runtime.RuntimeDecoder` can execute arbitrary code
GHSA-cq96-9974-v8hm - LOW Dynamic Variable Evaluation in qiskit-ibm-runtime

CVE-2024-29032 at a Glance

CVE Identifier CVE-2024-29032
GHSA Identifier GHSA-x4x5-jv3x-9c7m
Severity MODERATE
CVSS v3.1 Base Score 5.3
CWE Classification CWE-502: Deserialization of Untrusted Data
Affected Product Qiskit ibm runtime
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 5.3

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L).

Attack Vector Local (AV:L)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability Low (A:L)

How to Fix CVE-2024-29032

To remediate this vulnerability, upgrade all affected Qiskit ibm runtime dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

qiskit-ibm-runtime fixed: 0.21.2
pip install qiskit-ibm-runtime>=0.21.2
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show qiskit-ibm-runtime

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2024-29032, inspect your installed packages using pip:

pip show qiskit-ibm-runtime

Analyze the terminal output to locate any version of Qiskit ibm runtime in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.21.2), your application is affected.

Note: The pip show qiskit-ibm-runtime command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-502: Deserialization of Untrusted Data, where the product deserializes untrusted data without sufficiently ensuring that the resulting data will be valid. In Qiskit ibm runtime, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary deserializing json data using `qiskit_ibm_runtime.RuntimeDecoder` can be made to execute arbitrary code given a correctly formatted input string ### Details `RuntimeDecoder` is supposed to be able to deserialize JSON strings containing various special types encoded via `RuntimeEncoder`. However, one can structure a malicious payload to cause the decoder to spawn a subprocess and execute arbitrary code, exploiting this block of code: https://github.com/Qiskit/qiskit-ibm-runtime/blob/16e90f475e78a9d2ae77daa139ef750cfa84ca82/qiskit_ibm_runtime/utils/json.py#L156-L159 ### PoC ```python malicious_data = { "__type__": "settings", "__module__": "subprocess", "__class__": "Popen", "__value__": { "args": ["echo", "hi"] }, } json_str = json.dumps(malicious_data) _ = json.loads(json_str, cls=qiskit_ibm_runtime.RuntimeDecoder) # prints "hi" to the terminal ``` (where obviously "echo hi" can be replaced with something much more malicious) notably the following also makes it through the runtime API, with `malicious_data` serialized client-side via `RuntimeEncoder` (and therefore presumably deserialized server-side via `RuntimeDecoder`?) ```python service = qiskit_ibm_runtime(<ibm_cloud_credentials>) job = service.run("qasm3-runner", malicious_data) print(job.status()) # prints "JobStatus.QUEUED" ``` ### Impact i don't know if `qiskit_ibm_runtime.RuntimeDecoder` is used server-side so this may or may not be a serious vulnerability on your end (however it's definitely a security hole for anyone using the library to deserialize third-party data)

CVE-2024-29032 Affected Qiskit ibm runtime Versions

1 component(s)
Fixed Versions:
0.21.2
Product / Package Ecosystem Affected Versions Fixed Version
qiskit-ibm-runtime
PyPI
≥ 0.1.0
< 0.21.2
0.21.2

References

Frequently Asked Questions

What is CVE-2024-29032?
CVE-2024-29032 is a security vulnerability in Qiskit ibm runtime involving `qiskit_ibm_runtime.RuntimeDecoder` can execute arbitrary code under CWE-502: Deserialization of Untrusted Data.
Which Qiskit ibm runtime versions are affected?
Affected versions include releases prior to 0.21.2 across affected packages: qiskit-ibm-runtime.
What version fixes CVE-2024-29032?
Upgrading to 0.21.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is qiskit-ibm-runtime affected?
Yes, qiskit-ibm-runtime is affected in releases prior to 0.21.2. Upgrade your dependency to 0.21.2 or later.
What is the CVSS score of CVE-2024-29032?
CVE-2024-29032 has a CVSS v3.1 base score of 5.3 (MODERATE) with vector string CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L.
What CWE is associated with CVE-2024-29032?
CVE-2024-29032 is classified under CWE-502: Deserialization of Untrusted Data (The product deserializes untrusted data without sufficiently ensuring that the resulting data will be valid.).
How can I check PyPI dependencies for CVE-2024-29032?
Run the dependency tree command: 'pip show qiskit-ibm-runtime'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-x4x5-jv3x-9c7m",
  "modified" : "2024-03-20T21:37:56Z",
  "published" : "2024-03-20T15:44:22Z",
  "aliases" : [ "CVE-2024-29032" ],
  "summary" : "`qiskit_ibm_runtime.RuntimeDecoder` can execute arbitrary code",
  "details" : "### Summary\n\ndeserializing json data using `qiskit_ibm_runtime.RuntimeDecoder` can be made to execute arbitrary code given a correctly formatted input string\n\n### Details\n\n`RuntimeDecoder` is supposed to be able to deserialize JSON strings containing various special types encoded via `RuntimeEncoder`. However, one can structure a malicious payload to cause the decoder to spawn a subprocess and execute arbitrary code, exploiting this block of code: https://github.com/Qiskit/qiskit-ibm-runtime/blob/16e90f475e78a9d2ae77daa139ef750cfa84ca82/qiskit_ibm_runtime/utils/json.py#L156-L159\n\n### PoC\n\n```python\nmalicious_data = {\n    \"__type__\": \"settings\",\n    \"__module__\": \"subprocess\",\n    \"__class__\": \"Popen\",\n    \"__value__\": {\n        \"args\": [\"echo\", \"hi\"]\n    },\n}\njson_str = json.dumps(malicious_data)\n\n_ = json.loads(json_str, cls=qiskit_ibm_runtime.RuntimeDecoder)  # prints \"hi\" to the terminal\n```\n(where obviously \"echo hi\" can be replaced with something much more malicious)\n\nnotably the following also makes it through the runtime API, with `malicious_data` serialized client-side via `RuntimeEncoder` (and therefore presumably deserialized server-side via `RuntimeDecoder`?)\n```python\nservice = qiskit_ibm_runtime(<ibm_cloud_credentials>)\njob = service.run(\"qasm3-runner\", malicious_data)\nprint(job.status())  # prints \"JobStatus.QUEUED\"\n```\n\n### Impact\n\ni don't know if `qiskit_ibm_runtime.RuntimeDecoder` is used server-side so this may or may not be a serious vulnerability on your end (however it's definitely a security hole for anyone using the library to deserialize third-party data)",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "qiskit-ibm-runtime"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.1.0"
      }, {
        "fixed" : "0.21.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/Qiskit/qiskit-ibm-runtime/security/advisories/GHSA-x4x5-jv3x-9c7m"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-29032"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Qiskit/qiskit-ibm-runtime/commit/b78fca114133051805d00043a404b25a33835f4d"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/Qiskit/qiskit-ibm-runtime"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Qiskit/qiskit-ibm-runtime/blob/16e90f475e78a9d2ae77daa139ef750cfa84ca82/qiskit_ibm_runtime/utils/json.py#L156-L159"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-502" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-03-20T15:44:22Z",
    "nvd_published_at" : "2024-03-20T21:15:31Z"
  }
}