Skip to main content

QSHIELD

Security analysis for quantum circuits and the software that ships them.

Find suspicious circuit behavior, check equivalence, and audit dependencies—with evidence your team can review before a circuit reaches a run.

PyPI version Python versions License: Apache 2.0

Live Workbench · Install from PyPI · Threat model · Changelog

Software-only by design. No QPU, device SDK, or hardware acceptance path. Core analysis runs offline; the browser Workbench runs the real engine locally. Findings are evidence for human review—not proof that a circuit is safe or malicious.

At a glance

Surface Use it for
CLI & CI Scan OpenQASM, compare circuits, audit dependencies, emit SARIF / JSON / HTML / PDF
Python API Parse and analyze circuits from Qiskit, Cirq, PennyLane, and Amazon Braket
Workbench Interactive browser-local or local-server review: scan, compare, robustness probe, and policy scoring
WASI plugins Add explicit, resource-limited detector extensions without changing core verdicts

Measured scope: 417 bundled fixtures (202 clean / 215 malicious); fixture-corpus rates, not field rates. See limits and threat model.

What it does

Command / surface What it gives you
qshield scan Severity-ranked findings for a circuit (structural analysis + builtin threat signatures); --fail-on high as a CI gate
qshield compare Equivalence of two circuits — exact ZX-calculus proof or randomized identity testing
qshield verify Unitary check of a circuit against an expected matrix (≤12 qubits)
qshield audit-deps Quantum supply-chain audit of a requirements.txt (typosquatting, vulnerable pins)
qshield sig Manage the built-in threat signature pack (offline, sha256-verified)
qshield ui Workbench — local web UI: scan, compare, Policy Studio (score policies against the fixture corpus when available), Robustness Probe (does a finding survive semantics-preserving camouflage?)
Reports SARIF (GitHub Security tab) · JSON · HTML · PDF

Everything runs offline: no hardware, no cloud, no accounts, no network calls.

Why

Everyone is busy with post-quantum cryptography (PQC) — security for classical data against quantum attacks. Almost nobody is securing quantum software itself. Classical SAST/DAST/SCA tools cannot analyze quantum circuits: gates are unitary matrices, states can't be copied for inspection, and measurement is destructive. QSHIELD is purpose-built for this territory.

Install

pip install qshield                     # core (OpenQASM parser, static analysis, CLI)
pip install 'qshield[qiskit,cirq]'     # + framework parsers (qiskit-aer used by --full)
pip install 'qshield[braket]'           # + Amazon Braket Circuit parser
pip install 'qshield[formal]'          # + ZX-calculus verification (PyZX, Z3)

Docker: docker pull ghcr.io/katepallewarprathmesh-sketch/qshield:1.4.0 (or build from source: docker build -t qshield .). Run it with docker run --rm -p 127.0.0.1:8765:8765 qshield to keep the unauthenticated Workbench available only on host loopback. The container binds internally with an explicit non-loopback opt-in; keep the host port mapping on loopback. Do not publish the Workbench beyond localhost without network restrictions and an authenticated TLS proxy. For source installs, a non-loopback bind requires qshield ui --host 0.0.0.0 --allow-remote and prints a security warning.

From source: git clone https://github.com/katepallewarprathmesh-sketch/QShield.git && cd QShield && pip install -e '.[dev]'

Requires Python ≥ 3.10.

For releases produced after the provenance workflow change, verify a downloaded wheel or sdist against GitHub's signed build provenance before installing (requires GitHub CLI with gh attestation):

gh attestation verify "$WHEEL_OR_SDIST" --repo katepallewarprathmesh-sketch/QShield

The Workbench's Policy Studio includes the bundled fixture corpus in wheel and Docker installs (202 clean + 215 malicious circuits). For a custom corpus, point QSHIELD_FIXTURES_DIR at a directory containing clean_circuits/ and malicious_circuits/; scan and compare work independently of corpus scoring.

Quickstart

qshield scan circuit.qasm                       # scan (text report)
qshield scan circuit.qasm --fail-on high        # CI gate: exit 1 on high+ findings
qshield scan . --recursive --format sarif -o out.sarif   # GitHub Security tab
qshield compare original.qasm suspicious.qasm --formal   # ZX-calculus equivalence proof
qshield audit-deps --requirements requirements.txt       # quantum supply-chain audit
qshield ui                                      # Workbench at http://127.0.0.1:8765

Python API:

import qshield

results = qshield.scan("circuit.qasm")          # quick static scan
print(results.is_clean, results.summary.total)

Amazon Braket circuits can be converted explicitly or via parse_any after installing qshield[braket]. Supported standard gates map into the shared IR; unsupported operators raise an error rather than being silently approximated. Braket qubit labels are normalized to dense indices and retained in IR metadata.

from braket.circuits import Circuit
from qshield.core.parsers import parse_any

circuit_ir = parse_any(Circuit().h(4).cnot(4, 6).rz(6, 0.5))

Pre-commit hook

Install pre-commit, then add QSHIELD to .pre-commit-config.yaml. Pin rev to a QSHIELD commit or release that contains the hook:

repos:
  - repo: https://github.com/katepallewarprathmesh-sketch/QShield
    rev: v1.4.0
    hooks:
      - id: qshield-scan
        # Optional: default threshold is high.
        args: [--fail-on, medium]

For a source checkout with QSHIELD installed in the active environment, the equivalent local hook is:

repos:
  - repo: local
    hooks:
      - id: qshield-scan
        name: QSHIELD OpenQASM scan
        entry: python -m qshield.pre_commit
        language: system
        types: [file]
        files: '(?i)\.(qasm|qasm2|qasm3)$'

Then run pre-commit install and pre-commit run --all-files. The hook scans staged .qasm, .qasm2, and .qasm3 files; parse errors fail closed. It runs static and supply-chain checks and blocks findings at or above --fail-on (default: high).

Optional detector plugins (WebAssembly/WASI)

The plugin API is included in v1.4.0 behind the optional .[plugins] extra; plugin execution is explicit and separate from the default scan pipeline. Call WasmPluginRunner().run(plugin_dir, circuit_ir). Plugins use the versioned JSON contract in qshield/plugins/*schema.json; the host verifies the module hash and tags findings with the manifest identity. WASI receives no preopened directories or environment variables, and the runner limits memory, fuel, wall time, input, and output. Only WASI Preview 1 imports are accepted; socket-capable imports are explicitly denied. The manifest hash is integrity checking, not publisher authentication; only run plugins you choose to trust. Plugin findings remain separate evidence and do not silently change core scan results or gate decisions.

A Rust example and build steps are in examples/plugins/identity-pair.

from qshield.core.parsers import parse_file
from qshield.plugins import WasmPluginRunner

circuit = parse_file("circuit.qasm")
result = WasmPluginRunner().run("path/to/plugin-directory", circuit)

Optional AI assistance (cloud, advisory)

pip install sarvamai
export SARVAM_API_KEY=...        # or gitignored .env
qshield ai triage circuit.qasm   # plain-English findings + remediation priority (sends finding summaries, not the raw circuit)
qshield ai report circuit.qasm --to hi-IN   # audit report in Hindi/Marathi/etc.
qshield ai speak "text"          # Bulbul text-to-speech
qshield ai listen clip.wav       # Saaras speech-to-text

Advisory only, never a verdict — the offline core never touches the network; qshield ai is opt-in. The Workbench surfaces the same features (AI Triage tab + the qshield ui page, key stays server-side).

What it detects

Threat Example Verdict
Parameter perturbation / drift rz(π/4 + 0.001) catches cumulative drift
Extra gate injection cancelling cx … cx pairs, count anomalies immediate
Ancilla information leakage ancilla copied out before mixing deterministic
Parameter-encoded payloads angles = bytes on a grid deterministic
Measurement basis manipulation h right before measure immediate
Package tampering typosquatting, vulnerable pins, direct URLs immediate
Compromised compiler / backend pre/post-compile or cross-backend divergence statistical / exact

Honest limits

For assumptions, trust boundaries, and non-goals, see the public QSHIELD threat model.

  • Detection is evidence, never proof that a circuit is honest. Measured on the bundled synthetic fixture corpus (202 clean / 215 malicious) — fixture-corpus rates, not field rates.
  • Randomized equivalence catches large deviations, not angles ≲ 1e-3 rad; use --formal or dense matrix verification where feasible.
  • The community signature pack ships empty by design (candidates that measured TPR ≈ FPR were rejected).
  • Published to PyPI and as a GHCR image; Apache-2.0. Detection rates above are fixture-corpus measurements, not field rates.

Status & license

v1.4.0 — software-only. See CHANGELOG.md for release notes. Apache 2.0 — see LICENSE. Contributions (signatures, analyzers, corpus circuits) welcome.

Development

pip install -e '.[dev,qiskit,cirq,formal]'
python -m pytest tests
ruff check src tests benchmarks
mypy src

Metadata

Release files for qshield 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for qshield 1.4.0
File Size Uploaded Provenance Actions
qshield-1.4.0.tar.gz 353.0 kB With provenance Details for qshield-1.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for qshield 1.4.0
File Interpreter ABI Platform Actions
qshield-1.4.0-py3-none-any.whl Python 3 none any Details for qshield-1.4.0-py3-none-any.whl

Total release size: 686.0 kB

Release files / qshield-1.4.0.tar.gz

Download URL qshield-1.4.0.tar.gz
Size 353.0 kB
Tags Source
SHA-256 checksum
How to use checksums
d59bc39d22ea0eb83274f30af42bb8473326630811c99ba89160bcfa3e21c5c2
BLAKE2b-256 checksum
How to use checksums
6228fe808e0a67ac521fbfa35c34ff666657dfadc88f17c97c43b4499bf3efc7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Release files / qshield-1.4.0-py3-none-any.whl

Download URL qshield-1.4.0-py3-none-any.whl
Size 333.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
057eb670b2f856cd4df7cfc2e15d2349b8e764b5825a4d0da09baef6da3b6906
BLAKE2b-256 checksum
How to use checksums
1aa64de1c3e42ed588a2ba3b03cf6afda49919518d5871e5db97cbe398b0e1a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Security for qshield 1.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for qshield-1.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page