1. A length too long for any stock is a named refusal. Length.parse narrowed the micrometres to an int before it applied the 2 m limit, so "84600in" or "99999in" threw ArithmeticException: the opaque RENDER_FAILED, and an error instead of a REFUSED answer when collecting. The limit is now compared in long before narrowing, so it is SCENE_INVALID at the pointer of the length. 2. The printable area holds a box of its own size at every resolution. It was floor(far edge) less ceil(near margin), which can be one dot smaller than a box of the stated printable width: 100 mm stock with 3 mm margins and a 94 mm box fitted at 203 and 600 dpi and was refused at 300. It is now floor((W - L - R) x dpi) by floor((H - T - B) x dpi), the rounding of a box size, starting at ceil(L x dpi), ceil(T x dpi), moved back one dot where it would otherwise pass the page edge. New golden case `margins` with fractional-dot margins; the three existing goldens at 600 dpi are regenerated (the area grew by one dot each way; 203 and 300 unchanged). 3. The version 2 mutation campaign accepts only a Refusal (the package's own invariants are IllegalArgumentExceptions too) and renders about one input in four, reading the label back and comparing with validation. It found nothing at 20000 or 100000 iterations for either seed. 4. A refused answer carries no label bytes: with COLLECT and an error the answer had base64 of a label with elements missing. Scene2.render answers no label for a refused scene and the answer has no document fields. This changes the wire contract of section B.1 of the design, which records it. 5. One scene may paint sixteen times its printable area, an overlap counted each time, counted before any ink and in validation too. The element that would pass it is SCENE_INVALID with measured.paintedPercent against limit.paintedPercent 1600. 1000 fills of a 64 million dot canvas were 8 GB of byte writes; the worst scene is now 128 MB. 6. The README states what changed in the version 1 answer envelope in 0.2.0 (diagnostics on every answer; SCENE_INVALID with detail where unreadable JSON and a missing or unknown schema were RENDER_FAILED) and what the bridge must handle. The version 1 ZPL bytes are unchanged. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
7.4 KiB
Parser fuzzing
Scope and properties
K22-TEST-25 applies: this repository parses untrusted input at two boundaries. Templates are written by users, and the isolated renderer is treated as compromisable, so its output is untrusted to the host.
| Target | Module | Input | Campaign |
|---|---|---|---|
Version 1 scene parser, ZplRenderer.validate |
renderer |
A qqq-zpl-scene/1 source |
MutationCampaignTest.theVersionOneSceneParserAcceptsOnlyVersionOneScenes |
Version 2 scene parser, canvas and emitter behind the worker's routing, RendererMain.process with VALIDATE and, for about one input in four, RENDER |
renderer |
A qqq-zpl-scene/2 source |
MutationCampaignTest.theVersionTwoSceneParserAcceptsOnlyVersionTwoScenes |
Host printer gate, ZplOutputPolicy.validate |
bridges/renderer |
ZPL bytes returned by the worker | MutationCampaignTest.theHostPrinterGateAcceptsOnlyTheRendererCommandSet |
The harness is MutationCampaign, one copy in each module's test tree (the modules share no test code). It
mutates valid inputs from the version 1 compatibility corpus (renderer/src/test/resources/compat-v1) and the
version 2 layout cases (renderer/src/test/resources/scene2/cases): bit flips, byte and range edits,
truncation, duplication and tokens of the format spliced in. Each campaign checks unsafe acceptance, not only
crashes:
- Version 1 scene parser. An accepted input, read again by a second and differently configured JSON parser,
is a version 1 scene of known element types within the element limit. A refusal is the parser's
IllegalArgumentExceptionor exactly one of the JSON reader's exceptions for text that is not one JSON value (JsonParseException,JsonEOFException,MismatchedInputException,StreamConstraintsException). Any other exception (aNullPointerException, an index out of bounds), a stack overflow or a failed acceptance check is a finding. - Version 2 scene parser. The target is the worker's own routing, so a mutated source may also become a
version 1 scene, which is then held to the version 1 property. An accepted version 2 scene, read by the
second parser, has only the declared top-level properties, a physical design size, at most 1000 elements
with unique ids of the fixed pattern, only
boxandgroupelements with only their declared properties (the other types are refused until their packages exist), groups at most four deep, every length a number and a unit, and overrides only for the three resolutions and for declared ids. About one version 2 input in four, chosen by its bytes so that a replay does the same, is rendered instead of validated: the label is read back into a page, must be only the header, uncompressed graphic fields and the end of a label, must put no ink outside the printable area, and validation of the same input must give the same answer (accepted with the same findings, or refused with the same diagnostic). A refusal is the scene's ownRefusal, the exception that carries a diagnostic, and nothing else: the routing turns unreadable JSON and an unknown schema into one. A plainIllegalArgumentExceptionis a finding, because the package raises those for its own broken invariants (CANVAS_BOUNDS,CANVAS_LIMIT,LENGTH_NOT_ABSOLUTE,LENGTH_NOT_PHYSICAL), which no scene may reach. The one exception is a source the routing sends to the frozen version 1 parser, whose own refusal is a plainIllegalArgumentException; such sources are validated only. The campaign also asserts that it rendered labels. - Printer gate. An accepted input contains only the commands the renderer may emit and no tilde command.
A refusal is the gate's
IllegalArgumentException, or the strict decoder'sCharacterCodingExceptionfor field text that is not UTF-8. Any other failure, or a failed acceptance check, is a finding.
Each campaign also asserts that it reached both acceptance and refusal, so a campaign that only ever refuses cannot pass.
This is seeded generated-input fuzzing, not coverage-guided instrumentation. Do not claim OSS-Fuzz or ClusterFuzzLite enrolment.
Running and replaying
The campaigns run in the normal test phase, so every ./mvnw verify, and therefore every CI build of a pull
request or a push, runs them. No network, clock or unseeded randomness is used: a seed and an iteration
number determine the input.
# What CI runs: seeds 20261111 and 7919, 20000 iterations each, per target.
./mvnw -B -pl renderer,bridges/renderer -am verify
# Replay a finding, or run a longer campaign before a MINOR or MAJOR release (both seeds at 100000).
./mvnw -B -pl renderer -am test -Dtest=MutationCampaignTest -Dsurefire.failIfNoSpecifiedTests=false -Dfuzz.seed=20261111 -Dfuzz.iterations=100000
./mvnw -B -pl bridges/renderer -am test -Dtest=MutationCampaignTest -Dsurefire.failIfNoSpecifiedTests=false -Dfuzz.seed=20261111 -Dfuzz.iterations=100000
A failure lists each finding as Finding[seed, iteration, failure]. MutationCampaign.input(seed, iteration)
returns that exact input against the same checkout. Reduce it to a named regression test beside the parser's
other tests, fix the parser, and rerun both seeds. Report a suspected vulnerability privately rather than in a
public issue.
Limits: inputs are at most 1 MiB, a campaign is at most 100000 iterations, and the corpus entries used are under 20 KiB. The harness writes no files, launches no process and reads no credentials. Generated ZPL is never sent to a printer. Generated version 2 scenes are rendered in memory on a 2 x 1 in stock at 203 dpi, a canvas of 374 by 171 dots; generated version 1 scenes are only validated.
Adding a target
A new parser of untrusted input adds one test method to the MutationCampaignTest of its module, with a
corpus of valid inputs, a dictionary of the format's tokens, the refusal it declares and an independent check
of what it accepts, and adds a row to the table above. ZplRaster is the next target.
Review record
- Added: 2026-11-11, with the version 1 scene parser and printer gate campaigns.
- 2026-11-12: the version 2 scene parser campaign was added with the parser. The version 1 campaign had counted any exception as a refusal, so a crash in the parser would have passed; it now accepts only the declared refusals. Both seeds at 20000 iterations, and both at 100000, found nothing under the stricter rule.
- 2026-11-12, review of the scene 2 core: the version 2 campaign had counted any
IllegalArgumentExceptionas a refusal and only validated. It now accepts only aRefusaland renders about a quarter of its inputs, reading each label back. Both seeds at 20000 iterations, and both at 100000, found nothing under the stricter rule. The defect the review found by reading (a length such as84600inoverflowing anintof micrometres, anArithmeticException) was already outside the old rule; the mutations did not reach it because they rarely write a five-digit length, so it is covered by named tests instead (LengthTest,Scene2Test). - The first run of the printer gate campaign showed the
CharacterCodingExceptionrefusal, which the property had not declared. It is a refusal, not a defect; the property now names it. - Not yet done: a weekly long campaign and the
docs/security/assurance.jsonrecord that K22-TEST-25 also asks for. The long campaign is the manual command above until a scheduled job exists. - Reassess the targets when a parser boundary changes.