Add fuzz coverage for NewManifestFromReader #65
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
grep -rn "^func Fuzz" .returns nothing. There is no fuzz coverageanywhere in the repo and no
testdata/fuzzcorpus.NewManifestFromReaderis the function that parses attacker-controlledbytes: a magic prefix, a protobuf outer message, a zlib-compressed inner
payload, and an embedded signature. That is a deserializer for untrusted
input in a tool whose entire purpose is to be pointed at files fetched from
the network. It is the single highest-value fuzz target in the codebase and
currently has none.
Definition of done
FuzzNewManifestFromReaderexists and exercises the full parse path fromraw bytes.
mfer/testdata/fuzz/containing atminimum: a valid minimal manifest, a valid signed manifest, truncated
input at several offsets, correct magic with garbage after it, wrong
magic, empty input, a zlib bomb (small compressed, huge declared size),
and a declared size that disagrees with the actual decompressed length.
a manifest or an error, and must never panic, never hang, and never
allocate unboundedly.
its input is added to the committed corpus as a regression seed.
make testruns the seed corpus as ordinary unit tests (Go does thisautomatically for
Fuzz*without-fuzz) and stays within the testtimeout.
make checkpasses.TODO.mdupdated in the same commit.Implementation requirements
-fuzztoscript/test. Continuous fuzzing must not run inCI on every push — the seed corpus regression run is what belongs in
make test. If a longer fuzz run is worth having, add a separate,explicitly-invoked
make fuzztarget with a bounded-fuzztime, and sayso in the README Entrypoints section.
no gpg subprocess, no real filesystem writes outside
t.TempDir().input that causes a panic or an unbounded allocation, that is a bug in the
parser and gets fixed as one, with a note in the commit message.
MaxDecompressedSize,mfer/constants.go:13) actually holds under fuzzing — the zlib-bomb seedis there specifically to test it.
(closes #65).