Add M10.9c-1 session fuzzing and in-process abuse tests
Foundation / checks (deploy) (push) Successful in 6s
Foundation / checks (checks) (push) Successful in 17s
Foundation / checks (ecs) (push) Successful in 12s
Foundation / checks (client) (push) Successful in 1m47s
Foundation / checks (tsan) (push) Successful in 5m44s
Foundation / checks (network) (push) Successful in 13m29s
Foundation / checks (postgres) (push) Successful in 44m22s
Foundation / server-image (push) Successful in 31s
Foundation / postgres-tools (push) Successful in 1m34s
Foundation / image (push) Successful in 2m37s
Foundation / checks (deploy) (push) Successful in 6s
Foundation / checks (checks) (push) Successful in 17s
Foundation / checks (ecs) (push) Successful in 12s
Foundation / checks (client) (push) Successful in 1m47s
Foundation / checks (tsan) (push) Successful in 5m44s
Foundation / checks (network) (push) Successful in 13m29s
Foundation / checks (postgres) (push) Successful in 44m22s
Foundation / server-image (push) Successful in 31s
Foundation / postgres-tools (push) Successful in 1m34s
Foundation / image (push) Successful in 2m37s
ADR-0097. A libFuzzer target for session protocol v4, grants, tickets and snapshot assembly (canonical re-encoding, verifiers always refuse, a completed snapshot is applied), with the code under test compiled in, and a seeded smoke CTest of the same target on every platform. Four quic-sessions abuse tests measure an honest session tick by tick under a Hello flood (garbage, untrusted grants, silence), a datagram flood, a slow peer and a connect/disconnect storm; it keeps every snapshot and receipt while connections and retained state stay bounded. evo-session-probe run --grants FILE [--grant N] logs in from an existing bundle (a dev renewal's) without an issuer key. client_lifecycle uses SDL_getenv (MSVC rejected std::getenv). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
// M10.9c (ADR-0097) session protocol v4 fuzz target. Any input:
|
||||
// - decoding never crashes, and an accepted message has a stable canonical form
|
||||
// (decode, encode, decode, encode gives the same bytes: no field is silently dropped);
|
||||
// - an accepted snapshot chunk reaches the client's assembler without crashing;
|
||||
// - grant and ticket verification refuse it (no claim byte is trusted before the
|
||||
// signature: a fuzzer cannot forge ECDSA), also for the grant slot of a decoded Hello.
|
||||
// Built as a libFuzzer target with EVO_BUILD_FUZZER (Linux Clang) and as a seeded smoke
|
||||
// test everywhere (tests/fuzz/session_fuzz_smoke.cpp).
|
||||
#include "evo/network/handoff_ticket.hpp"
|
||||
#include "evo/network/replication.hpp"
|
||||
#include "evo/network/session_grant.hpp"
|
||||
#include "evo/network/session_protocol.hpp"
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <optional>
|
||||
#include <span>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
namespace {
|
||||
using namespace evo::network;
|
||||
constexpr evo::world::WorldIdentity world{9, 2};
|
||||
constexpr std::uint64_t region = 21;
|
||||
constexpr std::uint64_t now = 1'000'000;
|
||||
|
||||
// Verifiers holding one fixed, valid key each (the fuzzer never has its private half).
|
||||
struct Verifiers {
|
||||
std::optional<GrantVerifier> grants;
|
||||
std::optional<HandoffVerifier> tickets;
|
||||
Verifiers() {
|
||||
std::array<std::uint8_t, grant_private_key_bytes> scalar{};
|
||||
scalar.back() = 0x2A;
|
||||
const auto issuer = GrantSigningKey::import(DeploymentEnvironment::dev, 1, scalar);
|
||||
auto g = GrantVerifier::create(DeploymentEnvironment::dev);
|
||||
if (!issuer || !g || !g->add_key(1, *issuer->public_key()))
|
||||
std::abort();
|
||||
grants.emplace(std::move(*g));
|
||||
const auto source = HandoffSigningKey::import(DeploymentEnvironment::dev, 4, scalar);
|
||||
auto t = HandoffVerifier::create(DeploymentEnvironment::dev, world, region);
|
||||
if (!source || !t || !t->add_key(4, 4, *source->public_key()))
|
||||
std::abort();
|
||||
tickets.emplace(std::move(*t));
|
||||
}
|
||||
};
|
||||
const Verifiers& verifiers() {
|
||||
static const Verifiers v;
|
||||
return v;
|
||||
}
|
||||
void refused(std::span<const std::uint8_t> bytes) {
|
||||
const auto& v = verifiers();
|
||||
if (!v.grants || !v.tickets || v.grants->verify(bytes) || v.tickets->verify(bytes, now))
|
||||
std::abort();
|
||||
(void)looks_like_handoff_ticket(bytes);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data, std::size_t size) {
|
||||
const std::span<const std::uint8_t> bytes{data, size};
|
||||
refused(bytes);
|
||||
const auto decoded = decode_session(bytes);
|
||||
if (!decoded)
|
||||
return 0;
|
||||
const auto canonical = encode_session(*decoded);
|
||||
const auto again = decode_session(canonical);
|
||||
if (!again || encode_session(*again) != canonical)
|
||||
std::abort();
|
||||
if (const auto* hello = std::get_if<SessionHello>(&*decoded))
|
||||
refused(hello->grant);
|
||||
if (const auto* chunk = std::get_if<SnapshotChunk>(&*decoded)) {
|
||||
SnapshotAssembler client{world, chunk->epoch};
|
||||
if (const auto accepted = client.accept(*chunk);
|
||||
accepted && *accepted && client.latest() == nullptr)
|
||||
std::abort(); // A completed snapshot must be applied.
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user