feat(trust): signed SLSA attestations and OSV advisory audit (G5)
VoidBuildSystem CI / 1 · Requirements (push) Successful in 8s
VoidBuildSystem CI / 2A · Linux build (debug) (push) Successful in 2m55s
VoidBuildSystem CI / 2B · Windows Wine build (debug) (push) Successful in 2m37s
VoidBuildSystem CI / 2A · Linux build (coverage) (push) Successful in 4m7s
VoidBuildSystem CI / 2A · Linux build (sanitizers) (push) Successful in 4m57s
VoidBuildSystem CI / 2B · Windows Wine build (relwithdebinfo) (push) Successful in 4m38s
VoidBuildSystem CI / 3B · Windows Wine test (debug) (push) Successful in 26s
VoidBuildSystem CI / 3B · Windows Wine test (relwithdebinfo) (push) Successful in 27s
VoidBuildSystem CI / 2A · Linux build (relwithdebinfo) (push) Successful in 8m38s
VoidBuildSystem CI / 3A · Linux test (coverage) (push) Failing after 29s
VoidBuildSystem CI / 3A · Linux test (sanitizers) (push) Successful in 1m36s
VoidBuildSystem CI / 3A · Linux test (debug) (push) Failing after 5m13s
VoidBuildSystem CI / 3A · Linux test (relwithdebinfo) (push) Failing after 5m4s
VoidBuildSystem CI / 4A2 · VBS installers (linux target) (push) Skipped
VoidBuildSystem CI / 4A2 · VBS installers (windows target) (push) Skipped
VoidBuildSystem CI / 5 · Release (push) Skipped
VoidBuildSystem CI / 1 · Requirements (push) Successful in 8s
VoidBuildSystem CI / 2A · Linux build (debug) (push) Successful in 2m55s
VoidBuildSystem CI / 2B · Windows Wine build (debug) (push) Successful in 2m37s
VoidBuildSystem CI / 2A · Linux build (coverage) (push) Successful in 4m7s
VoidBuildSystem CI / 2A · Linux build (sanitizers) (push) Successful in 4m57s
VoidBuildSystem CI / 2B · Windows Wine build (relwithdebinfo) (push) Successful in 4m38s
VoidBuildSystem CI / 3B · Windows Wine test (debug) (push) Successful in 26s
VoidBuildSystem CI / 3B · Windows Wine test (relwithdebinfo) (push) Successful in 27s
VoidBuildSystem CI / 2A · Linux build (relwithdebinfo) (push) Successful in 8m38s
VoidBuildSystem CI / 3A · Linux test (coverage) (push) Failing after 29s
VoidBuildSystem CI / 3A · Linux test (sanitizers) (push) Successful in 1m36s
VoidBuildSystem CI / 3A · Linux test (debug) (push) Failing after 5m13s
VoidBuildSystem CI / 3A · Linux test (relwithdebinfo) (push) Failing after 5m4s
VoidBuildSystem CI / 4A2 · VBS installers (linux target) (push) Skipped
VoidBuildSystem CI / 4A2 · VBS installers (windows target) (push) Skipped
VoidBuildSystem CI / 5 · Release (push) Skipped
- vbs attest create renders an in-toto Statement v1 / SLSA provenance v1 predicate (subjects with sha256 digests, build definition with project/profile/targets/lock revision, internal parameters, run details) and wraps it in a DSSE envelope signed with the existing Ed25519 primitives over the PAE; creation fails closed without a signing backend. - vbs attest verify requires a trusted key, verifies the DSSE PAE signature, checks the statement type and requires every supplied artifact digest to be covered; wrong artifacts, tampered payloads and untrusted keys are rejected. - vbs audit matches OSV advisories (array or "vulnerabilities" object; introduced/fixed/last_affected/limit ranges and exact versions) against every package entry in vbs.lock, with --severity-threshold and --json; findings fail the command. - vbs doctor reports Ed25519 signing availability. Implemented with VoidLibrary: Void::Text::Base64 (DSSE payload), Void::Json::Strict (statement/envelope/audit output), Void::Semver (version ranges), Void::Str, plus the existing Signing primitives. Verified: attest_create_and_verify_detects_tampering and audit_matches_osv_advisories_against_lock pass; CLI contracts pass; clang-format clean.
This commit is contained in:
1 parent
ff3bfd03a1
commit
8b21583eeb
11 files changed
+1185
-5
No files matched your search
@@ -9,6 +9,7 @@
|
||||
#include <Void/Build/Install/Installer.hpp>
|
||||
#include <Void/Build/Modules/ModuleScanner.hpp>
|
||||
#include <Void/Build/Package/Archive.hpp>
|
||||
#include <Void/Build/Package/Audit.hpp>
|
||||
#include <Void/Build/Package/Fetch.hpp>
|
||||
#include <Void/Build/Package/Lockfile.hpp>
|
||||
#include <Void/Build/Package/Solver.hpp>
|
||||
@@ -17,6 +18,7 @@
|
||||
#include <Void/Build/Platform/ProcessSupervisor.hpp>
|
||||
#include <Void/Build/Provenance/Sbom.hpp>
|
||||
#include <Void/Build/Provenance/Signing.hpp>
|
||||
#include <Void/Build/Provenance/Attestation.hpp>
|
||||
#include <Void/Build/Sandbox/Sandbox.hpp>
|
||||
#include <Void/Build/Provider/Provider.hpp>
|
||||
#include <Void/Build/Provider/Translator.hpp>
|
||||
@@ -4793,3 +4795,190 @@ VOID_TEST(FullV1Tests, sandbox_strict_allows_project_builds_and_hides_outside_fi
|
||||
output.find("not found") != std::string::npos);
|
||||
}
|
||||
}
|
||||
|
||||
// === Trust layer: signed in-toto/SLSA attestations ===
|
||||
VOID_TEST(FullV1Tests, attest_create_and_verify_detects_tampering) {
|
||||
const auto vbs_bin = locate_vbs_binary();
|
||||
Void::Testing::expect(!vbs_bin.empty() && std::filesystem::exists(vbs_bin));
|
||||
if (vbs_bin.empty() || !std::filesystem::exists(vbs_bin)) {
|
||||
return;
|
||||
}
|
||||
if (!Provenance::signing_available()) {
|
||||
return; // No Ed25519 backend: the CLI fails closed, nothing to verify.
|
||||
}
|
||||
Void::FileSystem::TempDir tmp{"vbs_attest_"};
|
||||
const auto artifact = tmp / "app.tar";
|
||||
write_file(artifact, "artifact-bytes");
|
||||
const auto seed = tmp / "signing.key";
|
||||
Void::Testing::require(Provenance::generate_signing_seed(seed).has_value());
|
||||
auto public_key = Provenance::public_key_from_seed(seed);
|
||||
Void::Testing::require(public_key.has_value());
|
||||
|
||||
auto run_vbs = [&](std::vector<std::string> args) {
|
||||
Platform::ProcessRequest req;
|
||||
req.executable = vbs_bin;
|
||||
req.arguments = std::move(args);
|
||||
req.timeout = std::chrono::seconds{300};
|
||||
return Platform::run_supervised(req);
|
||||
};
|
||||
const auto attestation = tmp / "attestation.json";
|
||||
auto created = run_vbs({"attest", "create", "--artifact", artifact.string(), "--output",
|
||||
attestation.string(), "--signing-key", seed.string(), "--epoch",
|
||||
"1700000000", "--profile", "release", "--target", "app"});
|
||||
Void::Testing::expect(created.has_value() && created->succeeded());
|
||||
if (created && !created->succeeded()) {
|
||||
std::cerr << created->stdout_data << created->stderr_data << '\n';
|
||||
}
|
||||
auto envelope_text = Void::FileSystem::read_file(attestation);
|
||||
Void::Testing::require(envelope_text.has_value());
|
||||
auto envelope = Void::Json::Strict::parse(*envelope_text);
|
||||
Void::Testing::require(envelope.has_value());
|
||||
const auto *envelope_object = std::get_if<Void::Json::Strict::Value::Object>(&envelope->value);
|
||||
Void::Testing::require(envelope_object != nullptr);
|
||||
const auto *payload_type = std::get_if<std::string>(
|
||||
&envelope_object->at("payloadType").value);
|
||||
Void::Testing::require(payload_type != nullptr);
|
||||
Void::Testing::expect_eq(*payload_type, std::string{"application/vnd.in-toto+json"});
|
||||
const auto *signatures =
|
||||
std::get_if<Void::Json::Strict::Value::Array>(&envelope_object->at("signatures").value);
|
||||
Void::Testing::require(signatures != nullptr);
|
||||
Void::Testing::expect_eq(signatures->size(), std::size_t{1});
|
||||
|
||||
auto verified = run_vbs({"attest", "verify", "--attestation", attestation.string(),
|
||||
"--artifact", artifact.string(), "--trusted-public-key",
|
||||
*public_key});
|
||||
Void::Testing::expect(verified.has_value() && verified->succeeded());
|
||||
if (verified && !verified->succeeded()) {
|
||||
std::cerr << verified->stdout_data << verified->stderr_data << '\n';
|
||||
}
|
||||
|
||||
// A different artifact digest is rejected.
|
||||
const auto other = tmp / "other.tar";
|
||||
write_file(other, "tampered");
|
||||
auto mismatched = run_vbs({"attest", "verify", "--attestation", attestation.string(),
|
||||
"--artifact", other.string(), "--trusted-public-key",
|
||||
*public_key});
|
||||
Void::Testing::expect(mismatched.has_value() && !mismatched->succeeded());
|
||||
|
||||
// Tampering with the payload invalidates the signature.
|
||||
auto tampered_text = *envelope_text;
|
||||
const auto payload_pos = tampered_text.find("\"payload\":\"");
|
||||
Void::Testing::require(payload_pos != std::string::npos);
|
||||
const auto char_pos = payload_pos + std::string{"\"payload\":\""}.size();
|
||||
tampered_text[char_pos] = tampered_text[char_pos] == 'A' ? 'B' : 'A';
|
||||
const auto tampered = tmp / "tampered.json";
|
||||
write_file(tampered, tampered_text);
|
||||
auto tampered_result = run_vbs({"attest", "verify", "--attestation", tampered.string(),
|
||||
"--artifact", artifact.string(), "--trusted-public-key",
|
||||
*public_key});
|
||||
Void::Testing::expect(tampered_result.has_value() && !tampered_result->succeeded());
|
||||
|
||||
// An untrusted key is rejected, and verification without keys is a usage error.
|
||||
auto untrusted = run_vbs({"attest", "verify", "--attestation", attestation.string(),
|
||||
"--artifact", artifact.string(), "--trusted-public-key",
|
||||
std::string(64, '0')});
|
||||
Void::Testing::expect(untrusted.has_value() && !untrusted->succeeded());
|
||||
auto missing_keys = run_vbs({"attest", "verify", "--attestation", attestation.string()});
|
||||
Void::Testing::expect(missing_keys.has_value() && missing_keys->exit_code == 2);
|
||||
}
|
||||
|
||||
// === Trust layer: OSV advisory audit against vbs.lock ===
|
||||
VOID_TEST(FullV1Tests, audit_matches_osv_advisories_against_lock) {
|
||||
const auto vbs_bin = locate_vbs_binary();
|
||||
Void::Testing::expect(!vbs_bin.empty() && std::filesystem::exists(vbs_bin));
|
||||
if (vbs_bin.empty() || !std::filesystem::exists(vbs_bin)) {
|
||||
return;
|
||||
}
|
||||
Void::FileSystem::TempDir tmp{"vbs_audit_"};
|
||||
const auto lock_path = tmp / "vbs.lock";
|
||||
const auto make_context = [&]() {
|
||||
Package::LockContextRecord context;
|
||||
context.context_key = "debug:gcc:Linux:x86_64:target";
|
||||
context.profile_name = "debug";
|
||||
context.compiler = "gcc";
|
||||
context.os = "Linux";
|
||||
context.architecture = "x86_64";
|
||||
context.machine_role = "target";
|
||||
return context;
|
||||
};
|
||||
auto vulnerable = make_context();
|
||||
for (const auto &[name, version] :
|
||||
{std::pair<std::string, std::string>{"zlib", "1.2.11"},
|
||||
std::pair<std::string, std::string>{"openssl", "3.0.0"}}) {
|
||||
Package::LockedSourceEntry entry;
|
||||
entry.alias = name;
|
||||
entry.package_name = name;
|
||||
entry.version = version;
|
||||
entry.source_kind = "package";
|
||||
entry.sha256 = std::string(64, 'a');
|
||||
vulnerable.entries.push_back(entry);
|
||||
}
|
||||
auto published = Package::publish_lock_context_cas(lock_path, "", vulnerable, false);
|
||||
Void::Testing::require(published.has_value());
|
||||
|
||||
const auto advisories = tmp / "osv.json";
|
||||
write_file(advisories, R"json([
|
||||
{"id":"OSV-ZLIB-1","summary":"zlib overflow","database_specific":{"severity":"HIGH"},
|
||||
"affected":[{"package":{"name":"zlib","ecosystem":"OSS-Fuzz"},
|
||||
"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"1.2.0"},{"fixed":"1.2.13"}]}]}]},
|
||||
{"id":"OSV-OPENSSL-1","summary":"openssl issue","database_specific":{"severity":"medium"},
|
||||
"affected":[{"package":{"name":"openssl"},
|
||||
"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"3.0.0"},{"fixed":"3.0.1"}]}]}]}
|
||||
])json");
|
||||
auto run_vbs = [&](std::vector<std::string> args) {
|
||||
Platform::ProcessRequest req;
|
||||
req.executable = vbs_bin;
|
||||
req.arguments = std::move(args);
|
||||
req.timeout = std::chrono::seconds{120};
|
||||
return Platform::run_supervised(req);
|
||||
};
|
||||
auto audit = run_vbs({"audit", "--lock", lock_path.string(), "--advisories",
|
||||
advisories.string()});
|
||||
Void::Testing::expect(audit.has_value() && audit->exit_code == 1);
|
||||
if (audit) {
|
||||
Void::Testing::expect(audit->stdout_data.find("zlib 1.2.11") != std::string::npos);
|
||||
Void::Testing::expect(audit->stdout_data.find("openssl 3.0.0") != std::string::npos);
|
||||
}
|
||||
auto high_only = run_vbs({"audit", "--lock", lock_path.string(), "--advisories",
|
||||
advisories.string(), "--severity-threshold", "high"});
|
||||
Void::Testing::expect(high_only.has_value() && high_only->exit_code == 1);
|
||||
if (high_only) {
|
||||
Void::Testing::expect(high_only->stdout_data.find("zlib 1.2.11") != std::string::npos);
|
||||
Void::Testing::expect(high_only->stdout_data.find("openssl") == std::string::npos);
|
||||
}
|
||||
auto critical_only = run_vbs({"audit", "--lock", lock_path.string(), "--advisories",
|
||||
advisories.string(), "--severity-threshold", "critical"});
|
||||
Void::Testing::expect(critical_only.has_value() && critical_only->succeeded());
|
||||
auto json = run_vbs({"audit", "--lock", lock_path.string(), "--advisories",
|
||||
advisories.string(), "--json"});
|
||||
Void::Testing::expect(json.has_value() && json->exit_code == 1);
|
||||
if (json) {
|
||||
auto parsed = Void::Json::Strict::parse(json->stdout_data);
|
||||
Void::Testing::require(parsed.has_value());
|
||||
const auto *object = std::get_if<Void::Json::Strict::Value::Object>(&parsed->value);
|
||||
Void::Testing::require(object != nullptr);
|
||||
const auto *count = std::get_if<std::int64_t>(&object->at("count").value);
|
||||
Void::Testing::require(count != nullptr);
|
||||
Void::Testing::expect_eq(*count, 2LL);
|
||||
}
|
||||
|
||||
// Fixed versions are not reported.
|
||||
auto fixed = make_context();
|
||||
for (const auto &[name, version] :
|
||||
{std::pair<std::string, std::string>{"zlib", "1.2.13"},
|
||||
std::pair<std::string, std::string>{"openssl", "3.0.1"}}) {
|
||||
Package::LockedSourceEntry entry;
|
||||
entry.alias = name;
|
||||
entry.package_name = name;
|
||||
entry.version = version;
|
||||
entry.source_kind = "package";
|
||||
entry.sha256 = std::string(64, 'b');
|
||||
fixed.entries.push_back(entry);
|
||||
}
|
||||
auto updated =
|
||||
Package::publish_lock_context_cas(lock_path, published->revision_hash, fixed, false);
|
||||
Void::Testing::require(updated.has_value());
|
||||
auto clean = run_vbs({"audit", "--lock", lock_path.string(), "--advisories",
|
||||
advisories.string()});
|
||||
Void::Testing::expect(clean.has_value() && clean->succeeded());
|
||||
}
|
||||
Reference in new issue
Block a user