The first fuzz run on cnx01 found it: a drawn signature of 798 bytes
whose PNG header says 300 x 738,197,594 pixels made krilla ask for
885 GB. A failed allocation aborts the process, so one such signature
on any client link (or such an upload in a pack) would have ended the
app for everyone; reproduced on a normal build, with a valid IHDR
checksum.
krilla decodes a picture as soon as it makes it, so papers::pixels
reads the size from the header first, with the decoder krilla uses
(png, zune-jpeg, image-webp; already in Cargo.lock, now direct
dependencies), and papers::picture refuses more than MAX_PIXELS (50
megapixels, about 200 MB decoded) before krilla sees the file. The pack
and the Documents tab print a note for such a file, the signed copy
refuses it, and the client page refuses the signature (422, "did not
arrive whole") before anything is stored.
tests/fuzz_cases/signed_copy/png-claims-885-gigabytes is the finding,
replayed on every push; unit tests for the header sizes and the limit,
and the agreements test sends the forged signature.
Lanna Desk is the legal side of buildfor.life (B4L), and the client link,
its agreements, the demo agreement and the messages now name Lanna Desk:
"Lanna Desk looks after your visa ...", "Send to Lanna Desk", "Lanna
Desk keeps the signed copy". B4L stays where it is the company itself:
the employer in the Non-B pack and its BOI application.
README and PLAN say the same.
Checks: fmt, clippy, 109 unit and 57 integration tests.
While an active agreement is unsigned in its current version, the
link's other parts are locked: the overview shows them dashed with
"After signing" and no Send button, and every other page of the link
(About you, Contact, Passport, Address, Documents, Send) redirects to the
agreement and takes nothing posted to it. A new version locks them again
until it is signed.
Checks: fmt, clippy, 105 unit and 56 integration tests (tests/agreements.rs
asserts the redirects, that nothing posted before signing is saved, and
that the parts open after signing and close at a new version); the
locked overview checked on a phone in light and dark.
Built into the app rather than a separate signing service: any number of
agreements (the processing of the client's data first, legal services
and consultations later), each in versions whose text never changes.
- Staff (Agreements in the sidebar, src/web/agreements.rs): paste the
lawyers' text (empty line = paragraph, "# " heading, "- " list item),
preview it as the client reads it, publish version 1; a changed text is
the next version, the same text again is refused, and the database
refuses any change to a published one (migrations/0007, trigger).
Switch an agreement off and links stop asking for it.
- Client: every active agreement is the first step of every link. The
client reads it, ticks that they accept, types their name and signs
with a finger or the mouse (static/signature.js; a PNG of the pad). A
text changed while they read it is refused. A new version is asked for
again at the next link.
- The signed copy (src/agreements/pdf.rs, Sarabun so Thai prints, long
Thai words cut without parting marks from their letter): the text, the
name, the record, the time, the drawing, the link, the forwarded
address, the browser and the text's SHA-256; kept as the person's
encrypted document of kind "agreement", all in one transaction with the
signature and the audit rows (actor link N).
- The person's page shows each agreement's state (signed, not signed, to
sign again) and every signed copy.
- Phones: the section row now scrolls sideways instead of wrapping, so it
keeps one height with five sections and Sign out.
- Demo data: an invented agreement with a Thai paragraph.
Checks: fmt, clippy; 105 unit and 56 integration tests (tests/agreements.rs:
versions that never change, signing with a drawing, address and browser
recorded, the PDF, signing again after a change, a stale version refused,
switched off); layout check light/dark desk/phone on the agreement pages,
the client's agreement page, the person page and the people list: no
problems; a drawn signature in Edge at 390x844 signed and printed.