|
Embedded SDK
Embedded SDK
|
Fuzzing earns its keep in continuous integration. On every pull request CI fuzzes the changed code for a short budget, so a regression that introduces a crash, memory error, or undefined behaviour is caught in review — before it reaches master and ships in a release. The local campaign (Running a campaign) is for developing and reproducing; CI is where fuzzing runs continuously.
CI runs through ClusterFuzzLite. An app ships a small .clusterfuzzlite/ folder:
| File | Purpose |
|---|---|
| build.sh | Builds the fuzz targets (a thin caller, below) |
| Dockerfile | The build image: OSS-Fuzz base-builder, plus the SDK copied from ledger-app-builder-lite |
| project.yaml | ClusterFuzzLite project settings (language: c) |
The Dockerfile takes the SDK from the public ledger-app-builder-lite image:
FROM ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-lite:latest AS app-builder FROM gcr.io/oss-fuzz-base/base-builder:v1 COPY --from=app-builder /opt/flex-secure-sdk /ledger-secure-sdk
The compiler and sanitizer runtimes come from base-builder; only the SDK is taken from the Ledger image. When the repository defines the APP_BUILDER_REGISTRY variable, the reusable workflow pulls that registry's lite image and tags it with the public name before building, so the same Dockerfile builds against that registry's SDK. A Dockerfile based on another app-builder image keeps the public SDK.
On a PR, ClusterFuzzLite builds the targets with build.sh, runs each one under a sanitizer for a time budget, and reports any crash on the PR with the input attached. It also replays the corpus against a coverage build and uploads the result to Codecov under the fuzzing flag, so the PR comment shows what share of the app the fuzzers currently reach.
CI keeps its own corpus per target, as a build artifact and separate from the committed base corpus. Every run downloads the newest one before fuzzing, so a PR starts from what the last campaign found rather than from seeds alone. Scheduled runs grow it and a pruning run then minimises it; because the newest upload is what later runs pick up, pruning always runs after them. Artifacts expire after about 90 days, so a repository left idle longer than that restarts from generated seeds. The committed base corpus seeds local campaigns; CI computes a different key for it and normally skips it (Corpus in CI).
Every fuzz tree — apps and the SDK self-fuzz suite alike — builds through one shared script, scripts/cfl-build.sh. An app's build.sh only sets a few variables and delegates:
#!/bin/bash -eu
export BOLOS_SDK="${SRC:-/src}/ledger-secure-sdk"
export APP_DIR="${SRC:-/src}/<app>"
exec "${BOLOS_SDK}/fuzzing/scripts/cfl-build.sh"
Add export APP_FUZZ_SUBDIR=tests/fuzzing before the exec line for apps that keep their fuzzing tree outside the default fuzzing/ folder.
cfl-build.sh builds each target, rediscovers the invariant for the CI sanitizer, ships the binary, and packs its seed corpus — merging the promoted base corpus only when its key matches, which is rarely the case in CI (Corpus in CI). Because each sanitizer in the matrix shifts the global layout, CI builds always bootstrap the invariant from scratch (BOOTSTRAP_INVARIANT=1); the committed .zon models are never reused across CI entries.
CI typically runs an address, an undefined-behaviour, and a memory sanitizer entry. Each catches a different class of bug and each has its own global layout, which is why the invariant is regenerated per entry rather than taken from a committed model.
Fuzzing only guards what it can still build and interpret. As an app changes: