5 Auditing a Site
liquibyte edited this page 2026-11-27 14:59:02 -06:00

Auditing a Site

folio-audit checks a copy of a Folio site's record on your own computer. It trusts nothing from the site but its public key: every check is made with git, gpg and public keys. Anyone can run it: a member, someone thinking of installing from the site, an outside auditor. It changes nothing in the copy it reads.

The rule it checks is the site's own: verify, then trust. Every change in the record is signed by whoever made it. A person's change carries that person's signed request; a build node's result is signed by the node; a change the site makes by itself names what authorised it.

What it checks

For every change (commit) in the record, oldest first, along its first-parent line (the record has no other line; a change off it does not hold). folio-audit never runs anything the copy you give it names: it reads the record's objects through a repository of its own (in a folder of its own, reaching them through objects/info/alternates), reads its newest commit from its files, and runs git with no system or user settings, no hooks and no fsmonitor, so that the copy's own .git/config (a gpg.program, a core.fsmonitor) and .git/hooks do nothing.

  1. The site's signature. The change is signed by the site's key: its master, or a signing key under it while that key counted. A signing key that was replaced, ran out or was revoked is counted exactly as admin verify counts it on the server, by the same code (folio-verify.sh). Both print the same line, for example signatures: good 212, replaced 14, unsigned 0, unknown key 0, doubtful 0, accepted 0, not holding 0, so you can see that they agree. A change signed with the site's signing key for the archive does not hold: the master says in each signing key what it is for (the notation use@folio.invalid, archive or record), and only one for the record, or an older one made before signing keys had a use, signs the record. Such a change is reported as it is signed by the site's signing key for the apt archive, which its master allows to sign the archive only, never the record. Time never goes back along the line: a change dated before the change before it is taken as made at that one's time (and named in a WARNING: line). And a signing key revoked as replaced holds only while it is the newest key that signed: once a change signed by the key that replaced it (or any later one) is in the record, nothing the old key signs holds, whatever date it carries, so a copy of an old key cannot add changes dated back.
  2. A person's change. It keeps the person's signed request in its message (the lines between -----BEGIN FOLIO REQUEST----- and the signature). The request must:
    • be the seven lines exactly, in the form the site takes;
    • be signed by the GPG key that account had in the change before (accounts/NAME/pgp.asc and the pgp = line, as the record was just before this change), checked as gpg would have checked it at the time of the change;
    • name the change's author, which is also its Acted-by: line;
    • name this site (the site key's master fingerprint);
    • have a time within ten minutes of the change (six hours for follow, fetch, admit and watch, which can import many repositories);
    • have a nonce no other request used: the same request may explain several changes only for an import (its upload and follow changes);
    • come from an account that was not suspended then, and was allowed to do it then, by the same rules of roles the door keeps (written once, in folio-verify.sh, for both): an administrator or the owner for admin and approve; the owner for admin erase, admin verify accept and handing the site over with admin role NAME owner; for vouch an administrator, the owner or an account that may vouch; for keywords, unfollow, fetch, unflag (of another's flag) and follow of a package there before, one who looked after the package; for comaintainers its maintainer, or an administrator; for disown its maintainer; for admit, accept and reject, a reviewer (or, for reject, who asked or the maintainer). And the owner's protections: only the owner changes the owner's account (admin role, voucher, suspend, pgp), removes the owner's comments, undoes a change to the owner's account, and approves, moves or manages the owner's work (an upload the owner made, or a package whose maintainer is the owner).
  3. What the change did fits the signed command. A valid signature on a harmless command explains nothing else. Each command may change only this (the table below); a change that did more does not hold.
  4. A change the site made by itself names what authorised it:
    • an import (upload NAME VERSION, follow NAME at URL) has Authorised-by: request NONCE, and that request is an earlier one in the record that holds and authorises importing that package from that address: follow URL [NAME], admit OWNER/PROJECT [NAME], or watch ACCOUNT-URL for a repository of that forge account;
    • an import also has Source-commit: HASH signed-by FINGERPRINT: the commit its upload file records, signed by the key of whoever imported it or of the package's maintainers then. Unsigned (Source-commit: HASH unsigned) holds only where the site did not require signatures then;
    • the switch to a new signing key (the site's key: the signing key FPR signs from now on, after OLD) has Authorised-by: key-change FPR, and an earlier change published that key (the site's key: a new signing key, FPR, is published; ..., made when the server took the bundle of folio-site-key new-signing-key with folio-key import).
  5. Changes listed apart. Some changes rightly carry no request. Each is listed with its reason, never passed silently:
    • the first change: the site was made, before any account could sign;
    • the owner's GPG key, set on the server (folio-setup --owner-pgp): made by the owner, changing only the owner's account;
    • changes of the site's key that the owner brought to the server (folio-key import BUNDLE, or another folio-key step there): they change only verify/key-changes and verify/site-key.asc;
    • a request erased with what it named (Request-erased:). Their number may not be more than the erasures in erasures/ say they took out;
    • the owner's request to erase an account, withheld because it names the account (Request: NONCE (withheld: ...)), on the change that records the erasure and nothing else;
    • changes made before signed requests, up to the first change that carries one (the cut-over, which the report names);
    • an import a person asked for, made before imports named the commit they took (Source-commit:);
    • an admin undo of a change that is no longer in the history (an erasure rewrote it), whose request holds but whose changes cannot be compared.
  6. With --builds FOLDER, each build: its signed claim, and its signed result, by the build node whose GPG key the record held when the node signed it (nodes/NAME/pgp.asc); the archive it kept (result.tar) is the one the node signed (its sha256); each package in files/ is the one in that archive; and a published build names the signed result that authorised publishing it (published-result = build NUMBER request NONCE node NAME FINGERPRINT). Builds handed in before nodes signed their results are listed apart.

What each command may change

Signed command May change
vote P / unvote P adds / removes packages/P/votes/ACCOUNT, nothing else
comment P adds one packages/P/comments/...Z-ACCOUNT, whose text has the sha256 the request signed
flag P REASON / unflag P the flagged line of packages/P/meta (for flag: ... by ACCOUNT: REASON)
comaintainers P NAME... the co-maintainers line, set to exactly those names
keywords P WORD... the keywords line
disown P the maintainer and co-maintainers lines
adopt P the maintainer line, set to the account
unfollow P the source and unfollowed lines
follow URL [NAME], fetch P, admit OWNER/PROJECT [NAME] that package's import only: upload P VERSION writes meta (of a package there before, only releases), upload and binaries/; follow P at URL the source and unfollowed lines
watch URL the forge line of the account's own file; and imports of the watched account's repositories, as above
unwatch the forge line
request P ... adds one packages/P/requests/...-ACCOUNT
reject P ID removes packages/P/requests/ID
accept P ID orphan: the request goes, and meta's maintainer and co-maintainers; delete: only removes what is under packages/P/; merge: that, and adds votes under packages/INTO/votes/
approve P the approved and approved-by lines of packages/P/upload, by the account (an administrator or the owner; of the owner's work, only the owner)
pgp set / pgp remove the account's pgp.asc and its pgp line
key add / key remove N adds one accounts/ACCOUNT/ssh/keyN.pub / removes keyN.pub
vouch NAME adds accounts/NAME/ (which was not there), nothing else
admin role NAME R the role line of accounts/NAME/account, set to R; for owner, also the old owner's role, set to administrator
admin voucher NAME on/off the voucher line
admin suspend / unsuspend NAME the suspended line
admin remove-comment P ID removes packages/P/comments/ID
admin erase ... adds files in erasures/, nothing else (the owner)
admin undo CHANGE exactly the files CHANGE changed
admin move P PART the component line, set to PART
admin set KEY [VALUE] the KEY line of settings/site, set to VALUE
admin watch-forge / unwatch-forge the watch-forge and watch-forge-by lines
admin publish-to ADDRESS FINGERPRINT the publish-to and publish-host-key lines, set to the address and the fingerprint signed (the first step, admin publish-to ADDRESS, changes nothing in the record; from an earlier Folio, admin publish-to ADDRESS changed the publish-to line alone)
admin publish-off the publish-to and publish-host-key lines
admin registry-to / registry-off the registry-to line
admin mirror add / remove NAME mirrors/NAME
admin node add NAME adds nodes/NAME/
admin node disable / enable NAME the state line of nodes/NAME/node
admin node key NAME nodes/NAME/pgp.asc and the pgp line
admin pgp NAME accounts/NAME/pgp.asc and the pgp line; on the owner's account only when the owner asks
admin verify accept ... verify/accepted (the owner)
mail ..., decline, rebuild, admin registry-token, admin build remove, admin publish-now nothing in the record: such a request explains no change

Running it, step by step

  1. Install it. It comes with the package folio-client (sudo apt install folio-client), with git and gnupg.
  2. Get a copy of the record. Most sites publish theirs on a forge:
    git clone https://forge.example.org/you/dur-record.git
    
    From a backup (a file folio-backup save wrote on the server), unpack it into an empty folder and use its record/ (and builds/ for --builds):
    mkdir audit && tar -C audit -xf folio-backup.tar
    
    A backup made as root also holds the site's signing keys (in signer/), so only the owner, or someone the owner trusts with that key, has one.
  3. Get the site's key yourself. The record holds the site's public key (verify/site-key.asc), but someone who could change the record could change that too. Take it from somewhere else as well: the site publishes it at https://dur.example.org/apt/archive-keyring.asc, and its home page and setup.sh show its fingerprint. Better still, ask the owner for the fingerprint in person.
    curl --proto '=https' -fsSLO https://dur.example.org/apt/archive-keyring.asc
    
  4. Run it:
    folio-audit --key archive-keyring.asc dur-record
    
    With a backup: folio-audit --key archive-keyring.asc --builds audit/builds audit/record. Without --key it uses the key in the record, and says so: compare the fingerprint it prints with the one you got yourself.
  5. Read the report. It shows the site's key, any WARNING: lines about it (see When the site's key changed), the signature counts, how many changes people made, how many the site made by itself, and every change listed apart, each with its reason. Then each change that does not hold, with its code, date, author, subject and why. The exit status is 0 only if everything holds.
  6. For your own tools, --tsv prints a header line, then one line per change (and per build, with --builds), the fields separated by tabs: status (ok, listed, problem), kind (request, automatic, first, owner-key, key-change, erased, withheld, before-requests, build, signature, none), change, date, author, subject, why; then summary lines with the site's key, a warning line for each warning, the signature counts and the totals.

A report that holds looks like this:

folio-audit: the record in dur-record
The site's key: 3F2A...9C41
  (from archive-keyring.asc, as you gave it)
signatures: good 212, replaced 0, unsigned 0, unknown key 0, doubtful 0, accepted 0, not holding 0
212 changes:
  205 made by people, each with its own signed request that holds
  6 made by the site by itself, each naming what authorised it
  1 listed apart below, each with its reason

Listed apart (they hold, for the reason given):
  1a2b3c4  2026-11-20 10:02  owner  a new site, owned by owner
      the first change: the site was made (folio-setup), before any account could sign

Everything holds.

Where the master is kept. The report says, from the record's verify/key-changes, where the site says its master key is: The site's master key: kept by its owner, off the server, the record says (since DATE), or The site's master key: ON THE SITE'S SERVER, the record says (DATE): whoever breaks into the server gets the site's identity for good (a site made by an older Folio, until its owner moves it), or that the record does not say. This is what the site wrote, not something the audit can check; with --tsv it is the line summary master.

What a problem means

Why What happened
it is not signed, it is signed by a key that is not the site's the change was not made by the site: someone wrote the history by hand, or rewrote it with another key. (admin verify on the server lists unsigned changes and changes signed with a key it does not have, but does not fail for them; folio-audit does)
it is signed by a signing key of the site after that key was revoked or had run out someone signed with a key the site no longer uses, most likely a thief with the stolen key
it is signed by a signing key revoked as replaced, after a change signed by a later key: what such a key signs once its successor signed never holds, whatever its date someone with a copy of an old record key added a change after the key that replaced it had signed, dated back to look older. The owner should treat the old key as stolen (an emergency)
...; it is dated before the change before it added to the reason: its date goes back along the line, which the site's own clock does only when it was set back
it is not on the record's first-parent line (...) the copy holds a side line of changes, which the site never makes
it is signed by a signing key later revoked as stolen, and the owner has not accepted it (admin verify accept) the change was made while a thief may have held the key, and could be the thief's, dated back. The owner compares it with an older copy of the record and accepts it only if it is the site's own
its request is not signed with NAME's GPG key as the change before had it the request was altered, or signed by someone else
the upload was the owner's work; only the owner could approve it, OWNER owned the site then; only OWNER could change that account, NAME did not look after P then (or it was the owner's), P was the owner's; only the owner could do that, the change it undoes was the owner's (made by the owner, or of the owner's account, comments or packages); only the owner could undo it a real request of someone who was not allowed to do that: the door refuses it, so a change like it was not made through the door
what it changed is not what the signed command (...) does: ... a real request was used to explain another change
its request was used before, by change ...: a signed request counts once a request was replayed
it carries no signed request, and names nothing that authorised it a change made on the server without anyone asking for it
an import that names no signed request that authorised it (Authorised-by:) an import nobody set up
its forge commit was signed by FPR, a key of none of its maintainers then the import took a commit nobody responsible for the package signed
result.tar is not the archive its node signed, its result-request is not signed with the build node NAME's key ... a build result was replaced or forged

Any of these means the server, or a copy of its record, was changed by someone other than the people and nodes named. Tell the site's owner, and compare the copy with another (the forge's, an older backup).

When the site's key changed

folio-audit checks every change with one key: the one you gave with --key, or else the record's own copy (verify/site-key.asc, as the newest change has it). The four things below make it say so, in lines that start with WARNING: near the top. They do not make the record fail by themselves, but read them before you trust the report.

Warning What it means
the record's own copy of the site's key (verify/site-key.asc) is X, not the key you gave (Y). ... the record names another key than the one you got from the site. On a site restored or moved without its key, whose owner has not yet run folio-key record (see Backup and Restore), that is expected; otherwise find out which key the site really signs with
the site's key in the record changed from X to Y at change CODE (SUBJECT). ... the record was brought onto a server with a new key at that change (a restore from the forge alone, after which the owner ran folio-key record). With one key, the changes on the other side of it cannot hold: check the older part with the old key, and the newer with the new
changes dated before the change before them (...): CODE... those changes are dated earlier than the one before them; they are checked as made at that one's time. A site whose clock was set back does this; so does whoever signed them, if they chose the date
change CODE (SUBJECT) changed verify/site-key.asc, but it is not a recorded change of the site's key the record's copy of the key was changed by a change that is not one of the site's key (the site's key: ..., or the owner's key set on the server). The door never does that

What it cannot check

  • The site's key itself. Whoever holds the site's master key can sign anything. Get the fingerprint from the owner, not only from the record.
  • A forge commit's own signature. The record says which key signed the commit an import took (Source-commit:); folio-audit checks that this was a maintainer's key, but cannot check the signature without the project's repository. Check it there with git verify-commit HASH.
  • What was never recorded. Changes made beside the record (mail, decline, admin registry-token, admin build remove, admin publish-now) keep their requests only on the server, in private/requests/. A rebuild request is kept beside the build it queued (builds/NUMBER/request), and folio-audit does not check it. Builds are not in the record: only --builds on a backup checks them.
  • What a build node built. A node's signature says that node handed the result in, not that it built honestly; verify = required has a second node build the same files.
  • Erased requests. An erasure takes out the requests that named what it erased; their changes are listed, but cannot be checked.