My scanner had the right rule, read the right files, every run, for days. Two of those files were running the one command the rule forbids.
On 13 September an assistant debugging a failed push printed a live GitHub
token into my terminal. I wrote a rule that day. It says: never run a command
whose output is a credential, and it forbids gh auth token by name.
Then I wrote a scanner to enforce the rule. It reads every tracked file on every run. It has a positive control, because a scanner that finds nothing in a clean repository looks exactly like a scanner that finds nothing at all.
This week I found two files in my own repository running the forbidden command. One of them was the tool I had written to keep credentials out of the terminal in the first place.
The scanner had read both of them, every run, for days. It passed every time.
Here it is. Do not run this.
subprocess.run(["gh", "auth", "token"], capture_output=True)
The scanner searched for the forbidden command as plain text. That line does
not contain it. It contains gh, then a quote, a comma, a space, then
auth.
The rule was right. The scanner was right. The file was read on every run. The match was defeated by punctuation.
I had done the thing you are supposed to do. The scan plants a known-bad file and proves it can see a violation, so that a clean result means something. Mine planted the forbidden command the way a shell script would write it.
It matched. So the scan reported that it could detect a real breach, and I believed it.
But a control only proves the scan catches breaches shaped like the control. Mine was shaped like a shell script. The breach was shaped like a Python argument list. For as long as both existed, the control passed and the breach sat two directories away.
The fix is four lines. Strip list punctuation, then match against both forms.
def as_argv(line):
for ch in "\"',[]()":
line = line.replace(ch, " ")
return " ".join(line.split())
Then plant both shapes in the control, not one.
I checked the fix the only way worth checking a test. I deleted it and confirmed the control went red:
FAIL the scan cannot find a planted one, so 'clean' means nothing
Then I put it back. The repaired scan immediately found a second violation I did not know about, in a file older than the one I was chasing.
A different check in the same repository counts the Daml test scripts and compares the total against the number printed in my README. For two days it failed in continuous integration with this:
FAIL daml scripts: README says 165, the file has 103
That reads like a stale claim in my documentation. I have a rule against those too. So I opened the README to correct it.
The README was right.
The check builds two Daml packages and counts the scripts in each. One of them
takes a data dependency on an interface package that the check never built, and
it ignored what daml build returned. On a clean checkout the build
failed, the test run found nothing, the total came back 103 instead of 165, and
the check presented that to me as dishonesty in my own writing.
A swallowed exit code was reported as a false claim. Three commits went into a number that was never wrong.
It now builds in dependency order, and a failed build returns -1
and prints the compiler error. The failure message went from naming an innocent
file to naming the actual fault. That is the whole improvement, and it is worth
more than the number being right.
Three checks, all written deliberately, all with a stated purpose, all wrong in the same way: each one reported confidently about something it had not actually looked at.
| Check | Reported on | Where the fault was |
|---|---|---|
| Credential scanner | text | punctuation |
| Script counter | a documented claim | a swallowed exit code |
| Build dashboard | a test result | a concurrent process |
The third was the same day. My build dashboard reported 40 of 41 green while a mutation run was live in another process with files deliberately broken on disk. Three different totals in one hour, none of them measured on a quiet tree. On a quiet tree it is 43 of 43.
What these share is not a bug. It is that the thing doing the checking was never checked in the form the failure would actually arrive in.
Not “does it pass”. Not even “does it fail when I break the code”, which is better and still not enough.
What shape will the real breach have, and have I ever planted that shape?
A control in the wrong shape is worse than having none, because it buys confidence at full price and delivers nothing. I had one for six weeks and it reported success the entire time.
Everything above is in one public repository, pushed before this was written.
git clone https://github.com/dominicrume/cantor8_kya_rails
cd cantor8_kya_rails
# the scanner, with both control shapes
python3 tests/security_lint.py
# break the fix on purpose; the control must go red
python3 - <<'EOF'
p = "tests/security_lint.py"
s = open(p).read().replace("if cmd in line or cmd in flat:", "if cmd in line:")
open(p, "w").write(s)
EOF
python3 tests/security_lint.py
git checkout -- tests/security_lint.py
# the counter, from a clean state, in dependency order
rm -rf step-0-refusal/interface/.daml/dist step-0-refusal/.daml/dist
python3 tests/balance_lint.py # 165, not 103
# the whole sweep, on a quiet tree
python3 tools/dashboard.py # 43/43
The commit is 43ed104. Its message says what was wrong, in the open, with the reason, because a correction found by a reader costs more than one declared by the author.
None of it has run on Canton DevNet. I do not have a credential yet. These are local checks over Daml packages and Python, and that is all they are. Weigh them as a design until that changes.
What is on a public registry is the Daml work they guard, and that part is reproducible. Both published packages rebuild byte for byte from committed source, and the digests match what a stranger pulls anonymously:
canton-journal-interface-1.0.0.dar 255139 bytes
sha256 97ce4baaf2505493903974a7d591cce380180e97ad402cd43bd6b4066fb83a4d
canton-refusal-record-1.0.0.dar 396449 bytes
sha256 a72a61918f6c75d7f839439d6338ee8ce8a738864a702cab40d81882b3a69df8
Pull either from
ghcr.io/dominicrume/canton-journal-interface:1.0.0 or take them from
the
release. There is no latest tag, on purpose.
To make one of your own assets unmovable without a ledger record of the attempt, you need the first of those two files and nothing else. One word on your signatory line, one interface instance:
template Wallet
with holder : Party; guard : Party; balance : Decimal
where
signatory holder, guard -- the whole fix
interface instance Journalled for Wallet where
view = JournalledView with owner = holder; guardian = guard
perform = do ... -- your work, untouched
The honest caveat on that: it is a control when the guard party is operated by somebody who is not the actor, and a convention when one person submits as both. A test in the repository performs that bypass and shows the counter never moves.