strawberry/fuzz/fuzz_cmdline_redactor.cpp
trvon c452be93d4
Some checks failed
Build and Test / build (debug, clang) (push) Has been cancelled
Build and Test / build (debug, gcc) (push) Has been cancelled
Build and Test / build (release, clang) (push) Has been cancelled
Build and Test / build (release, gcc) (push) Has been cancelled
Build and Test / docker (push) Has been cancelled
Unify file ids, record uid/comm, redact command lines
File node ids: include/strawberry/node_ids.hpp is now the only place
they are built (file_<sha256> or file_path_<sha256 of path>). The three
modules disagreed: correlation used a 16-digit path hash and behavior
detections the raw path, so path-keyed evidence never met the rest. An
exec detection with a known hash also writes a same_path edge from the
path id to the content id. Source invariant R8 rejects hand-built file
ids in src/ and include/.

Processes carry the real uid and kernel comm: from the eBPF exec event
(which now includes the uid) or /proc. Stored on process nodes and in
process_exec telemetry (fields 14, 15).

Command lines are redacted before any storage (capture_redact_cmdline,
default on): sensitive flags and KEY=value pairs, Authorization/Bearer
credentials, URL passwords, tokens used as URL user names, well-known
token shapes (GitHub, GitLab, Slack, AWS key ids, sk-, JWTs) and mysql
-p<password>. The rules repeat to a fixed point, so redaction is
idempotent by construction. tests/test_redact.cpp covers the rules plus
idempotence, size and planted-secret properties; fuzz_cmdline_redactor
found two idempotence bugs and a leak (--password --token X) that are
fixed here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 17:58:48 -06:00

19 lines
667 B
C++

// Command-line redactor over arbitrary bytes: never crashes, idempotent,
// output bounded (redact.hpp properties).
#include "strawberry/redact.hpp"
#include <algorithm>
#include <cstdint>
#include <string>
using namespace strawberry;
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
const std::string_view in(reinterpret_cast<const char*>(data), size);
const auto once = redact_cmdline(in);
if (redact_cmdline(once) != once) __builtin_trap();
const std::size_t tokens = static_cast<std::size_t>(std::count(in.begin(), in.end(), ' ')) + 1;
if (once.size() > in.size() + 80 * tokens) __builtin_trap();
return 0;
}