QYVORA — security audit engine
The permanent audit infrastructure required by the owner's instruction of 2026-12-04 (CLAUDE.md,
"MANDATORY — full wallet security audit"). One command re-runs the whole audit and regenerates the
reports:
./scripts/security-audit.sh # quick: every check, reduced counts (about 3 minutes on the laptop)
./scripts/security-audit.sh --full --nodes "M3U96a M3U96b M2U64" --timing-node M4M64aWhat this is. An internal, automated technical audit run on the project's own machines. What it is not: an independent certification, a proof of security, or a substitute for the independent cryptographic review required before any recommendation to use the wallet with real funds. A tool that cannot run is recorded as NOT RUN with its reason, never as passed; every number in a report comes from the results file produced by the run.
Post-quantum cryptography in QYVORA protects the local vault, backups, transfers and the separate identity. It does not make Bitcoin or Ethereum transactions quantum-resistant; the audit rates the two separately everywhere.
Layout
| Path | Content |
|---|---|
Scripts/security-audit.sh |
Entry point. The repository's script directory is Scripts/; ./scripts/security-audit.sh is the same file on the case-insensitive volumes macOS uses by default (on a case-sensitive volume call Scripts/security-audit.sh). |
security/audit/orchestrator.py |
Runs the steps in three concurrent lanes, merges tool results with the findings register, evaluates the release gate, writes the results file, calls the report generator. Python standard library only. |
security/audit/runners/ |
One runner per tool: each returns a tool result (status RUN / NOT RUN / FAILED, version, coverage statement, metrics, test records, findings) in the common schema of lib/common.py. Each runs standalone (python3 security/audit/runners/<name>.py). |
security/audit/lib/ |
Shared helpers: schema (common.py), Swift builds and cluster helpers (build.py), disassembly and branch counting (machinecode.py). |
security/audit/report/generate.py |
Markdown, self-contained HTML and PDF reports from the results file (PDF rendered locally with WeasyPrint; headless Chrome or wkhtmltopdf as fallbacks). |
security/audit/findings/ |
The findings register: one JSON file per finding (root cause, severity, CVSS, CWE, MASVS, location, status, fix commit, regression test). Prefixes: QYV-CRY primitives review, QYV-SVC service layer, QYV-APP application and design, QYV-BIN binary, QYV-FUZ fuzzing, QYV-AUD found by the audit tests. |
security/audit/review/ |
Registers of the manual source reviews (constant-time verdicts, parser traps, memory hygiene). |
security/audit/install-tools.sh |
Installs the pinned tools under security/.tools (git-ignored). |
security/audit/install-hooks.sh, security/audit/ci/ |
Pre-push hook and server-side integration (below). |
security/tests/ |
Swift package QyvoraSecurityAudit, depending on the engine by path (production targets untouched): conformance replay, Wycheproof, differential, property tests, fuzz-corpus replay, the fuzzer qyfuzz, the timing tool qytiming. |
security/tests/oracles/ |
Python reference oracle and its pinned requirements (test environment only). mc/ holds the oracles of the multi-chain tests (Ed25519, Solana, TRON, UTXO coins, EVM), run in a second environment security/.tools/venv-mc (requirements-multichain.txt: PyNaCl, cryptography, solders, tronpy, eth-account, bip-utils, bitcash…). |
security/vectors/ |
Third-party vectors (Wycheproof, BIP) at pinned revisions with MANIFEST.json; see its README. |
security/fuzzing/ |
Seed corpus, crash reproducers, campaign summaries, sanitizer run records; see its README. |
security/policies/ |
Severity policy, release gate, tool pins, Semgrep rules, Gitleaks configuration, framework mappings (MASVS, MASTG, Coinspect, wallet audit, Dontrust), triage decisions; see its README. |
security/reports/ |
Generated: SECURITY_AUDIT_RESULTS.json, SECURITY_AUDIT_REPORT.{md,html,pdf}, CRYPTOGRAPHIC_VALIDATION_REPORT.{html,pdf}. raw/ (tool output, logs) is git-ignored. |
SECURITY.md, docs/THREAT_MODEL.md |
Disclosure address, supported versions, honest status; threat model with the audit-status section. |
Installation
security/audit/install-tools.sh # idempotent; --check lists what is installedCreates security/.tools/venv (Python) with the pinned Semgrep, mobsfscan and the reference oracle's
requirements (coincurve/libsecp256k1, pycryptodome, argon2-cffi, embit, mnemonic), a second environment
security/.tools/venv-mc with the references of the multi-chain tests (kept apart because some of them
require older versions of the same packages), checks Gitleaks
(Homebrew), caches the Semgrep registry packs, and copies the spbqc tool and libspb_pqc.dylib of the
owner's Rust library when a release build exists. Pins: security/policies/tools.json. Dontrust is
installed separately (python3 security/audit/runners/frameworks.py --install-dontrust, needs Node and
pnpm). MobSF needs Docker on the configured host (security/policies/mobsf.json, default BHS128). Xcode,
xcodegen and WeasyPrint are expected on the machine.
Nothing leaves the project's machines: Semgrep and mobsfscan run with the network denied
(sandbox-exec), MobSF runs in a container without network on the project's own server and is removed
after each run, the only downloads are public rule packs, tools and vector files.
What the command does
| Step | Tools reported | Quick | Full |
|---|---|---|---|
vectors |
vectors |
SHA-256 of the third-party vector files against the manifest | same |
engine-tests |
engine-tests |
every test target of the root package, release build | + large-data hash vectors (QYVORA_LDT=1) |
swift-audit |
swift-audit |
ACVP/CAVP/BIP replay with counts per parameter set, Wycheproof, differential tests, property tests, corpus replay — reduced random counts | ten times the counts, complete SLH-DSA ACVP files when present, all twelve SLH-DSA sets |
timing |
ct-machine-code, dudect-timing |
conditional branches in the compiled code of the secret-handling functions (secp256k1, ML-KEM, AES, Ed25519, SHA-512…); dudect test on this machine at 15 % of the sample counts, on the production build and, for the Ed25519 internals with chosen scalars, on a second build with testability | timing on --timing-node (or the first of --nodes), full counts |
fuzz |
qyfuzz |
about one minute over the targets (93 since the multi-chain extension), local | long campaigns on --nodes, coverage-guided build |
sanitizers |
sanitizers |
NOT RUN (recorded) | AddressSanitizer / UndefinedBehavior / ThreadSanitizer builds of selected suites (the Ed25519, Solana and TRON suites under both AddressSanitizer and ThreadSanitizer) |
semgrep, gitleaks, mobsfscan, static-checks |
same names | run | run |
frameworks |
coinspect-wsf, owasp-masvs, owasp-mastg, wallet-audit, dontrust |
run (evidence references re-verified at each run) | run |
ipa-build, mobsf, binary-checks |
same names | NOT RUN (recorded) unless --with-app |
unsigned Release archive, MobSF on the project's server, own binary checks |
ct-ios |
ct-machine-code-ios |
NOT RUN (recorded) unless --with-app |
the branch-count check repeated on the iOS application binary of the archive (symbols from its dSYM) |
Options: --no-mobsf, --with-app, --nodes "A B", --timing-node N, --only a,b, --skip a,b,
--jobs N, --no-report, --list. Environment: QY_AUDIT_SCRATCH (build directories, default
/tmp/qy-audit-build), QY_AUDIT_REPORTS (write results elsewhere than security/reports),
QY_AUDIT_SEED (deterministic random campaigns), QY_AUDIT_REPLAY_SEED (replay one recorded campaign).
Cluster use: the working tree is copied with rsync to <node>:qyvora-build/audit/ (timing) and
<node>:qyvora-build/audit-fuzz/ (fuzzing) — only those directories are written on a node, nothing is
killed by name, and each runner records machine, duration, executions and crashes.
Exit status: 0 release gate passed · 1 gate failed · 2 usage error · 3 report generation failed.
Release gate
security/policies/release-gate.json. Publication is blocked by: an unresolved critical or high finding;
a failed case in an executed test (vectors, engine suites, audit tests, machine-code check, fuzzing,
sanitizers); a fuzzing crash; an untriaged secret; a required tool that failed or did not run (the full
list of required tools applies to --full). Everything else is a warning (open medium findings, tools
not run, checks not run, quick mode). Severity rules: security/policies/severity-policy.md — the
severity is the higher of the CVSS v3.1 band and the wallet-impact class; an agent never accepts a risk
on the owner's behalf.
Findings workflow
- A problem found by a person, a review or a test gets one file in
security/audit/findings/with the fields oflib/common.py: finding(). Tool findings are produced at run time and triaged insecurity/policies/triage.json(keyed by fingerprint; every entry carries its justification). - A fix is a minimal change with a regression test; the finding then records
status: fixed, the fix commit and the test. Fixes in the engine must pass on the laptop's toolchain. - The orchestrator merges register and tool findings by identifier (the live tool status wins), so a finding that a tool no longer reports is shown as resolved at that commit.
Reproducing a result
- A failed random campaign prints its seed and stores it in the results file:
QY_AUDIT_REPLAY_SEED=<seed> swift test -c release --package-path security/tests --filter <test>. - One target group of the test package only (faster iteration):
QY_AUDIT_ONLY=PropertyAuditTests swift test -c release --package-path security/tests. - Timing:
swift build -c release --package-path security/tests --product qytiming, thenqytiming --only <target> --scale 5 [--dit]on a quiet machine.--ditsets the processor's data-independent-timing flag for the measurement. Two properties of the harness matter as much as the code under test (QYV-AUD-005, a timing "leak" that was a measurement artefact). (1) Both classes of a target keep their inputs in one block of memory whose slots are dealt to the classes at random (ClassStore): a class kept in its own buffers differs from the other by a constant 1 to 3 ns per run whatever the contents. (2) The timed region is separated from the preparation of the inputs by a serialising barrier (dsb sy; isb): without it the processor is still finishing the copy of the input when the clock is read.--no-barrierrestores the former timed region:qytiming --only info-former-preparation-ML-KEM-768 --scale 10 --no-barrierreproduces the reported artefact (|t| ≈ 6 to 12); that target keeps the former asymmetric preparation as a record and has no verdict. Controls run every time:control-leaky-compareandcontrol-positive-mlkem-leak-ML-KEM-768must be detected;control-same-class,control-negative-aes-random-keysandcontrol-negative-mlkem-ciphertexts-*(same distribution in both classes) must not. The targetsdiag-*only run when named (diag-<case>-<parameter set>with the casessame-single-vs-copies,copies-vs-pool,pool-vs-pool,single-vs-single,u-only,v-only,single-touch-vs-copies;diag-branch-ML-KEM-768;diag-aes-null,diag-aes-zero-vs-zero,diag-aes-random-vs-random,diag-aes-fixed-vs-random,diag-aes-zero-single-vs-random): they keep each class in its own buffers, as before the correction, to reproduce and localise the artefacts.--pool Nchanges the number of values per class (default 512). - Timing of the Ed25519 internals (scalar chosen directly, which the public interface does not allow):
QY_TIMING_INTERNALS=1 swift build -c release -Xswiftc -enable-testing --package-path security/tests --scratch-path /tmp/qy-timing-internals --product qytiming, thenqytiming --internals --dit --scale 10. The verdict is taken with--dit, because the production entry points set the data-independent-timing flag before reaching these functions; without--ditthe same targets are reported asinfo-nodit-…(no verdict).info-public-…targets measure the variable-base multiplication, which serves verification only. The campaigns that found and closed QYV-AUD-006 are insecurity/audit/review/ed25519-timing-2026-12-05.json. - Multi-chain differential tests:
QY_AUDIT_ONLY=DifferentialAuditTests swift test -c release --package-path security/tests --filter Ed25519Differential(orSolana,Tron,UTXOCoins,EVMChains); a campaign whose reference is not installed is recorded NOT RUN. - Fuzzing:
qyfuzz list,qyfuzz run …,qyfuzz repro <target> <file>(seesecurity/fuzzing/README.md). - Machine code:
python3 security/audit/runners/timing.pyprints the branch counts of the functions listed insecurity/policies/constant-time-functions.json.
CI/CD
The forge is self-hosted (spbgit: bare repositories on the gateway M1M32); there is no hosted runner. Three pieces are provided.
(a) Pre-push hook (local).
security/audit/install-hooks.sh # install; --remove to uninstallBefore a push that touches Sources/, Tests/, App/, security/, Package.swift or the entry script,
the hook runs the quick audit with its output redirected to a scratch directory (the committed reports
are not rewritten) and refuses the push when the release gate fails. QY_SKIP_AUDIT=1 git push skips it
and says so. An existing pre-push hook is kept as pre-push.local and runs first.
(b) Server-side integration (ready, NOT installed). security/audit/ci/post-receive-audit.sh is
meant to be called from the bare repository's post-receive hook. For each pushed refs/heads/main it
clones the pushed revision into a scratch directory on a build node, runs
Scripts/security-audit.sh --quick there, and writes ~/qyvora-audit-status/<sha>.json and
latest-main.json on the gateway (commit, node, start and end, exit status, gate result, blockers,
summary, path of the log). The push is never blocked: the audit runs detached. It was tested against a
local bare clone with QY_CI_BUILD_NODE=local (clone, checkout, run, status file, clean-up); it has not
been run on M1M32, and nothing was installed there.
Installation, to be approved and run by the owner (one command from the laptop; it copies the script next
to the hooks of the bare repository gitsrv:srv/git/qyvora.git and appends one line to post-receive):
scp security/audit/ci/post-receive-audit.sh gitsrv:srv/git/qyvora.git/hooks/qyvora-audit.sh && ssh gitsrv 'chmod +x srv/git/qyvora.git/hooks/qyvora-audit.sh && printf "%s\n" "tee >(QY_CI_BUILD_NODE=M3U96b \"\$(dirname \"\$0\")/qyvora-audit.sh\") >/dev/null" >> srv/git/qyvora.git/hooks/post-receive'The appended line is
tee >(QY_CI_BUILD_NODE=M3U96b "$(dirname "$0")/qyvora-audit.sh") >/dev/nullIt hands a copy of the hook's standard input (the pushed references) to the script. It needs a post-receive
written for bash (process substitution); if the hook does not exist yet, create it with #!/usr/bin/env bash
as first line and make it executable. To remove: delete that line and hooks/qyvora-audit.sh.
Before enabling it: check how the existing post-receive of spbgit uses its standard input (if it
already reads it, place the line before that command), run security/audit/install-tools.sh once on the build node
(the script keeps a persistent tool directory qyvora-build/ci/tools there and installs on first use),
and note that the Rust oracle and Dontrust are absent on a node unless installed (their campaigns are
then NOT RUN and reported as such). Settings are environment variables documented at the top of the
script (QY_CI_BUILD_NODE, QY_CI_BRANCHES, QY_CI_AUDIT_ARGS, QY_CI_STATUS_DIR…).
(c) .github/workflows/security-audit.yml. An example of the equivalent for a mirror on a forge
with macOS runners. Unused, never run, clearly marked as such.
Limits (summary; the reports give the complete list)
- Internal audit; no independent review of the cryptography or of this engine.
- Fuzzing is our own engine (mutation-based; edge-coverage feedback only in the instrumented build); libFuzzer is not available in the Xcode toolchain.
- Timing tests are statistical evidence on one machine and one build (macOS build of the package). The iOS application binary is disassembled for branch counts in full runs, but not timed on a device.
- Static tools have limited Swift support; framework mappings are self-assessments by source review.
- MobSF and the binary checks analyse an unsigned archive statically; no dynamic test on a device.
- No real funds, no live network in the audit.
- Multi-chain extension (2026-12-05): the new families were audited by source review, vectors, differential
tests against independent libraries, property tests and fuzzing on stub transports. No transaction built by
the wallet was broadcast to a real node of the new chains: acceptance by the networks rests on byte identity
with the references and with public transactions. The application screens of the new chains were not
reviewed by this extension (open
QYV-APP-0xxitems).