From 080f3d966817506079538715e973bae6efe97b69 Mon Sep 17 00:00:00 2001 From: DanS Date: Wed, 22 Jul 2026 02:12:45 -0500 Subject: [PATCH] fix(build): enforce build-from-source for the lite backend (F15-1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The lite-backend "signature verification" was attestation theater: build-lite-backend-artifact.sh recorded a self-attested signature_verification.verification_status="verified" with no cryptographic check (the "verified" SHA was simply the artifact's own SHA), and CMake's DRAGONX_LITE_BACKEND_REQUIRE_SIGNATURE gate trusted it — so a hand-edited manifest could link an arbitrary prebuilt backend into ObsidianDragonLite. Per the chosen remediation (build-from-source is the trust root): - build-lite-backend-artifact.sh: reject --artifact/--no-build (prebuilt) and all --signature-* flags; the backend is always built from the vendored in-tree source (third_party/silentdragonxlite). Record built_from_source:true in the manifest provenance. Usage/header updated. - CMakeLists.txt: remove the DRAGONX_LITE_BACKEND_REQUIRE_SIGNATURE option and its manifest signature-verification gate (kept the real required-symbol inventory check); update the config summary line. Full-node CMake reconfigure + build pass; script bash -n clean and the removed flags now hard-error. (The lite-backend link path needs cargo + backend and was not runtime-tested in this environment.) Co-Authored-By: Claude Fable 5 --- CMakeLists.txt | 34 ++-------- scripts/build-lite-backend-artifact.sh | 91 +++++--------------------- 2 files changed, 22 insertions(+), 103 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ef092b..6832f1c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,7 +53,6 @@ set_property(CACHE DRAGONX_LITE_BACKEND_LINK_MODE PROPERTY STRINGS imported) set(DRAGONX_LITE_BACKEND_ABI "sdxl-c-v1" CACHE STRING "Expected lite backend C ABI version") set(DRAGONX_LITE_BACKEND_SYMBOLS_FILE "" CACHE FILEPATH "Path to generated lite backend exported-symbol inventory") set(DRAGONX_LITE_BACKEND_MANIFEST "" CACHE FILEPATH "Optional path to generated lite backend artifact manifest") -option(DRAGONX_LITE_BACKEND_REQUIRE_SIGNATURE "Require verified signature metadata in the lite backend artifact manifest" OFF) set(DRAGONX_LITE_BACKEND_REQUIRED_SYMBOLS litelib_wallet_exists litelib_initialize_new @@ -126,31 +125,12 @@ if(DRAGONX_ENABLE_LITE_BACKEND) if(DRAGONX_LITE_BACKEND_MANIFEST AND NOT EXISTS "${DRAGONX_LITE_BACKEND_MANIFEST}") message(FATAL_ERROR "DRAGONX_LITE_BACKEND_MANIFEST does not exist: ${DRAGONX_LITE_BACKEND_MANIFEST}") endif() - if(DRAGONX_LITE_BACKEND_REQUIRE_SIGNATURE) - if(NOT DRAGONX_LITE_BACKEND_MANIFEST) - message(FATAL_ERROR "DRAGONX_LITE_BACKEND_REQUIRE_SIGNATURE requires DRAGONX_LITE_BACKEND_MANIFEST") - endif() - file(READ "${DRAGONX_LITE_BACKEND_MANIFEST}" DRAGONX_LITE_BACKEND_MANIFEST_JSON) - string(JSON DRAGONX_LITE_SIGNATURE_STATUS ERROR_VARIABLE DRAGONX_LITE_SIGNATURE_STATUS_ERROR GET "${DRAGONX_LITE_BACKEND_MANIFEST_JSON}" signature_verification verification_status) - if(DRAGONX_LITE_SIGNATURE_STATUS_ERROR) - message(FATAL_ERROR "DRAGONX_LITE_BACKEND_MANIFEST is missing signature verification status") - endif() - if(NOT DRAGONX_LITE_SIGNATURE_STATUS STREQUAL "verified") - message(FATAL_ERROR "DRAGONX_LITE_BACKEND_REQUIRE_SIGNATURE requires verified signature metadata") - endif() - string(JSON DRAGONX_LITE_SIGNATURE_VERIFIED_SHA ERROR_VARIABLE DRAGONX_LITE_SIGNATURE_VERIFIED_SHA_ERROR GET "${DRAGONX_LITE_BACKEND_MANIFEST_JSON}" signature_verification verified_artifact_sha256) - string(JSON DRAGONX_LITE_ARTIFACT_SHA ERROR_VARIABLE DRAGONX_LITE_ARTIFACT_SHA_ERROR GET "${DRAGONX_LITE_BACKEND_MANIFEST_JSON}" artifact sha256) - if(DRAGONX_LITE_SIGNATURE_VERIFIED_SHA_ERROR OR DRAGONX_LITE_ARTIFACT_SHA_ERROR) - message(FATAL_ERROR "DRAGONX_LITE_BACKEND_MANIFEST is missing artifact/signature SHA-256 metadata") - endif() - if(NOT DRAGONX_LITE_SIGNATURE_VERIFIED_SHA STREQUAL DRAGONX_LITE_ARTIFACT_SHA) - message(FATAL_ERROR "DRAGONX_LITE_BACKEND_MANIFEST signature metadata does not verify the artifact SHA-256") - endif() - string(JSON DRAGONX_LITE_SIGNATURE_PERFORMED ERROR_VARIABLE DRAGONX_LITE_SIGNATURE_PERFORMED_ERROR GET "${DRAGONX_LITE_BACKEND_MANIFEST_JSON}" signature_verification verification_performed) - if(DRAGONX_LITE_SIGNATURE_PERFORMED_ERROR OR NOT DRAGONX_LITE_SIGNATURE_PERFORMED) - message(FATAL_ERROR "DRAGONX_LITE_BACKEND_REQUIRE_SIGNATURE requires verification_performed=true") - endif() - endif() + # Note (F15-1): the former signature-metadata gate was removed. It trusted a + # "verification_status: verified" field that scripts/build-lite-backend-artifact.sh + # self-attested with no cryptographic check (the "verified" SHA was just the artifact's + # own SHA). The trust root is now build-from-source: that script builds the backend from + # the vendored in-tree source and refuses prebuilt artifacts, so the library linked here + # is the one built from reviewed source. The required-symbol inventory check above stays. add_library(dragonx_lite_backend UNKNOWN IMPORTED) set_target_properties(dragonx_lite_backend PROPERTIES @@ -1097,5 +1077,5 @@ message(STATUS " Lite backend: ${DRAGONX_LITE_BACKEND_READY}") message(STATUS " Lite lib: ${DRAGONX_LITE_BACKEND_LIBRARY}") message(STATUS " Lite symbols: ${DRAGONX_LITE_BACKEND_SYMBOLS_FILE}") message(STATUS " Lite manifest: ${DRAGONX_LITE_BACKEND_MANIFEST}") -message(STATUS " Lite signature: ${DRAGONX_LITE_BACKEND_REQUIRE_SIGNATURE}") +message(STATUS " Lite trust: built-from-source (vendored third_party/silentdragonxlite)") message(STATUS "") diff --git a/scripts/build-lite-backend-artifact.sh b/scripts/build-lite-backend-artifact.sh index e83b021..66292c1 100755 --- a/scripts/build-lite-backend-artifact.sh +++ b/scripts/build-lite-backend-artifact.sh @@ -67,25 +67,9 @@ Options: --backend-dir PATH SilentDragonXLite/lib source directory. --silentdragonxlitelib-dir PATH Override the wrapper's silentdragonxlitelib dependency path. --out-dir PATH Output directory for copied artifact and metadata. - --artifact PATH Inventory an existing artifact instead of building. - --no-build Do not run cargo; requires --artifact. --reproducible Add deterministic Rust path remaps for clean builds. --remap-path-prefix FROM=TO Extra rustc path remap used with --reproducible. --builder NAME Redacted builder/provenance label. Default: local. - --signature-required Fail if verified signature metadata is not supplied. - --signature-file PATH Existing sidecar signature file to record. - --signature-format FORMAT Signature format: minisign, gpg, sigstore, external, or other. - --signature-verification-tool T Verification tool and version used by the release builder. - --signature-verification-command C - Verification command already run by the release builder. - --signature-key-fingerprint F Reviewed public-key fingerprint, when applicable. - --signature-certificate-identity ID - Reviewed certificate identity, when applicable. - --signature-certificate-issuer I - Reviewed certificate issuer, when applicable. - --signature-transparency-log-url URL - Transparency log entry, when applicable. - --signature-verified-sha256 SHA Artifact SHA-256 verified by the signature check. -j, --jobs N Cargo parallel jobs. --cargo-arg ARG Extra argument forwarded to cargo build. -h, --help Show this help. @@ -95,9 +79,13 @@ Outputs: //lite-backend-symbols.txt //lite-backend-artifact-manifest.json -The script captures symbols, checksums, and optional read-only signature -verification metadata only. It does not load the library, resolve function -pointers, call SDXL, sign, upload, or publish artifacts. +The lite backend is always built from the vendored in-tree source +(third_party/silentdragonxlite), which is the trust root. Prebuilt artifacts +and self-attested signature metadata are NOT accepted (F15-1) — the previous +scheme only recorded an unverified "verified" claim. The script captures the +freshly-built artifact's symbols and checksum, and records build provenance. +It does not load the library, resolve function pointers, call SDXL, sign, +upload, or publish artifacts. EOF } @@ -166,15 +154,8 @@ while [[ $# -gt 0 ]]; do OUT_DIR="$(absolute_path "$2")" shift 2 ;; - --artifact) - [[ $# -ge 2 ]] || die "--artifact requires a value" - ARTIFACT_PATH="$(absolute_path "$2")" - BUILD_ARTIFACT=false - shift 2 - ;; - --no-build) - BUILD_ARTIFACT=false - shift + --artifact|--no-build) + die "$1 was removed (F15-1): the lite backend must be built from the vendored in-tree source (third_party/silentdragonxlite); prebuilt artifacts are no longer accepted." ;; --reproducible) REPRODUCIBLE=true @@ -191,54 +172,11 @@ while [[ $# -gt 0 ]]; do BUILDER="$2" shift 2 ;; - --signature-required) - SIGNATURE_REQUIRED=true - shift - ;; - --signature-file|--signature-path) - [[ $# -ge 2 ]] || die "$1 requires a value" - SIGNATURE_FILE="$(absolute_path "$2")" - shift 2 - ;; - --signature-format) - [[ $# -ge 2 ]] || die "--signature-format requires a value" - SIGNATURE_FORMAT="$2" - shift 2 - ;; - --signature-verification-tool|--signature-tool) - [[ $# -ge 2 ]] || die "$1 requires a value" - SIGNATURE_VERIFICATION_TOOL="$2" - shift 2 - ;; - --signature-verification-command) - [[ $# -ge 2 ]] || die "--signature-verification-command requires a value" - SIGNATURE_VERIFICATION_COMMAND="$2" - shift 2 - ;; - --signature-key-fingerprint) - [[ $# -ge 2 ]] || die "--signature-key-fingerprint requires a value" - SIGNATURE_KEY_FINGERPRINT="$2" - shift 2 - ;; - --signature-certificate-identity) - [[ $# -ge 2 ]] || die "--signature-certificate-identity requires a value" - SIGNATURE_CERTIFICATE_IDENTITY="$2" - shift 2 - ;; - --signature-certificate-issuer) - [[ $# -ge 2 ]] || die "--signature-certificate-issuer requires a value" - SIGNATURE_CERTIFICATE_ISSUER="$2" - shift 2 - ;; - --signature-transparency-log-url) - [[ $# -ge 2 ]] || die "--signature-transparency-log-url requires a value" - SIGNATURE_TRANSPARENCY_LOG_URL="$2" - shift 2 - ;; - --signature-verified-sha256) - [[ $# -ge 2 ]] || die "--signature-verified-sha256 requires a value" - SIGNATURE_VERIFIED_SHA256="$2" - shift 2 + --signature-required|--signature-file|--signature-path|--signature-format|\ +--signature-verification-tool|--signature-tool|--signature-verification-command|\ +--signature-key-fingerprint|--signature-certificate-identity|--signature-certificate-issuer|\ +--signature-transparency-log-url|--signature-verified-sha256) + die "signature-attestation flags were removed (F15-1): they recorded a self-attested \"verified\" claim without running any cryptographic verifier. The lite backend is built from the vendored in-tree source, which is the trust root." ;; -j|--jobs) [[ $# -ge 2 ]] || die "--jobs requires a value" @@ -766,6 +704,7 @@ MANIFEST_FILE="$PLATFORM_OUT_DIR/lite-backend-artifact-manifest.json" printf ' },\n' printf ' "provenance": {\n' printf ' "owner_ready": true,\n' + printf ' "built_from_source": true,\n' printf ' "metadata_provided": true,\n' printf ' "source": '; json_escape "$BACKEND_SOURCE_DIR"; printf ',\n' printf ' "cargo_build_source": '; json_escape "$BUILD_BACKEND_DIR"; printf ',\n'