When Nothing Ran, It Said Yes

Claude drafted this from the commit history of two of my public repos. I edited it.

I keep a public draft spec for signed receipts on AI-assisted work. The idea is that a model provider signs a small record of what it produced, and anyone can check the signature later. The spec ships with a reference verifier, a short Node script. You hand it a receipt and a key set, and it prints a result and exits. 0 means valid. 1 means anything else.

That contract is the whole interface for a calling script. A CI step or a shell pipeline doesn't read the JSON the verifier prints. It reads the exit code.

On October 1, three fixes went into that verifier. Each one was a way for it to say the wrong thing without anything looking wrong.

It exited 0 without running

The script decided whether it was being run directly, rather than imported, with this line:

if (import.meta.url === `file://${process.argv[1]}`) {

That compares a real URL to one built by hand from a file path. They match for a plain path. They don't match when the path has a space in it, because the real URL escapes the space and the hand-built one doesn't. They don't match through a symlink either, like the /tmp folder on a Mac, because the real URL resolves the link and the argument doesn't.

When they didn't match, the script loaded its functions, skipped the part that does the work, printed nothing and exited 0. A calling script would read that as valid. Any receipt, from anyone, checked from a folder with a space in its name.

The fix compares URL to URL, after resolving the real path. The regression test is the part I'd copy. It copies the verifier into a temp folder literally named "with space" and runs it there, so it tests the way the script gets invoked, not just the function inside it.

It accepted a signature with junk on it

Node's base64 decoders are forgiving. They skip characters that aren't in the alphabet, and they ignore trailing data. So a valid receipt with whitespace, extra padding or junk added to its signature still decoded to the same 64 bytes and still verified as valid.

That's not a forgery. The signature underneath is real. It's still wrong for a verifier, because a receipt that's been changed should come back tampered, and this one came back clean. The fix accepts only canonical encodings of exactly 64 bytes, in the two forms the spec and its test vectors use. Anything else is tampered.

A typo looked like a forgery

A missing file, invalid JSON, or a receipt that wasn't a JSON object crashed the script with a stack trace and exit status 1. That's the same status as tampered. A calling script couldn't tell a forged receipt from a mistyped path.

The verifier now has a third exit status. 2 means no result could be produced at all, and the error goes to stderr. That one change is the heart of this whole essay. "Pass," "fail" and "I didn't get to decide" are three different answers, and a tool that only has two codes will fold the third into one of the others.

All four of the spec's conformance vectors passed before these fixes and after them. They also pass under both of the verification orders that the spec's reference implementation and this example verifier still disagree on, which is an open decision in the repo. Passing vectors told me the math was right. They didn't tell me anything about how the tool behaved at its edges.

A month later, the same bug in a different library

On October 30 the same shape turned up in piidetect, the Go redaction library I published in September. Its job is to find personal data in text and mask it before the text goes anywhere else.

A Chain is the thing that runs the detectors. A Chain with no detectors in it, the zero value you get from writing &Chain{}, used to hand the text back in the clear with no error. Nothing ran, and the caller got its text back looking processed.

Two more came with it. The built-in regex floor ignored cancellation, so 4 MB of text with an already-cancelled context ran for about 2.5 seconds and returned no error. And when one detector failed, the chain threw away the spans that detector had already found before the failure.

The fixes all point the same way. An empty Chain now runs the built-in regex floor in place of the missing detectors and reports an error that says so. The floor checks for cancellation between passes and reports it. A failed detector's spans are kept and masked. The docs now say plainly that any error means a value may have been missed, so a caller handling regulated data should mask or drop the whole text rather than pass the partial result along.

What I check for now

None of these bugs were in the interesting code. The signature math was right. The detectors found what they were built to find. Every one of them was in what the tool said when it didn't do its job, and every time, it said something that sounded like success.

So these are the questions I ask of anything that answers yes or no now:

  • What does it return when nothing ran? An empty config, a zero value, an entry point that didn't trigger. If the answer is the same as success, that's the bug.
  • Does "couldn't decide" have its own answer? A separate exit code, a separate error, anything but folding it into pass or fail.
  • Is the input it accepts exactly the input it checked? A forgiving decoder in front of a strict check makes the check forgiving too.
  • Do the tests run it the way callers run it? From a strange path, through a symlink, with nothing configured, with the context already cancelled.

A verifier that says yes without looking is worse than no verifier, because people stop looking once it's there.

-- Justin Higgins. Software Engineer, Midwest. Found out his verifier said valid from any folder with a space in it, and gave "couldn't decide" its own exit code.


Companion pieces: A Receipt Nobody Issues Yet - the spec this verifier ships with. The Test Logged the Miss and Went Green - another quiet pass in the same redaction library. Spider-Man Is Not a Person - the gateway the library came out of.

Reactions, disagreements, war stories: jchigg2000.dev@gmail.com