Skip to content

spots: check spot signatures as Spotweb does - #264

Merged
xbmc4lyfe merged 2 commits into
mainfrom
spot-signatures
Nov 7, 2026
Merged

xbmc4lyfe merged 2 commits into
mainfrom
spot-signatures

Conversation

@xbmc4lyfe

Copy link
Copy Markdown
Collaborator

What

Spots are now kept only when their signatures hold, the way Spotweb checks them (Services_Format_Parsing::parseHeader). Until now a spot only had to carry a non-empty signature field, so anyone could post a "spot" under another spotter's name.

New spotnet::sign::verify(title, from, message_id):

  • Keys 2-4 (Spotnet's own, signed by its signing server): RSA PKCS Faster backfill and smaller storage: split backfill, packed message-ids, sealed blobs, auto compact #1 v1.5 / SHA-1 over title + header-without-signature + nickname, against the three public keys Spotweb ships. They are 384-bit, below what ring accepts, so the check is a short num-bigint modpow (already in the lock file).
  • Key 7 (self-signed): the hashcash (SHA-1 of <message-id> starts 0000), as Spotweb requires; the header signature only names the spotter.
  • Key 2 with a long user key is a spotter's own DISPOSE: hashcash, flagged personal for the moderation PR that follows.
  • Any From carrying USERKEY.USERSIG must also have the message-id signed by that key. That signature is what makes the spotter id theirs, so the spotter id stored is now the verified one.

Checked in two places: on the overview (read_overview), and again on the HEAD in fetch, so the backlog of spots noted before this change is checked too. header::header_value reads a header from the HEAD with folded lines joined, replacing spotter_id_of_head.

Measured on live free.pt

Last 5,000 overview lines: every key-7 spot verifies (4,266), and 348 of 350 key-2 lines. The 2 that fail are DISPOSEs of erotica spots whose titles are Latin-1: the overview decoder makes U+FFFD of those bytes, so the signed text can't be rebuilt. They are not movie or TV spots. For 150 recent movie/TV spots, the HEAD check gives the same verdict and spotter id as the overview check.

Tests

spotnet::sign tests use real lines from free.pt: a self-signed spot, a moderator's DISPOSE and a spotter's own DISPOSE, plus tampered copies (another message-id, another title, another nickname, another key, an unknown key id). cargo test --lib spotnet:: passes (62).

No UI change.

🤖 Generated with Claude Code

xbmc4lyfe and others added 2 commits November 7, 2026 13:36
A spot's From header carries RSA signatures (PKCS #1 v1.5, SHA-1): the
header signed by Spotnet's keys 2-4, or a self-signed key-7 spot with a
hashcash, and the message-id signed by the spotter's own key. Spots are
now kept only when these hold, checked on the overview and again on the
HEAD (for spots noted before), and the spotter id stored is the one the
spotter's signature proves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Build the signed text as bytes, so a multibyte character before the '<'
can't panic the spot task; reject an empty nickname and a user key that
won't decode, as Spotweb does; take only signatures exactly as long as
the key; note which verdicts rest on decoded text; and say whether the
spotter's key signed the message-id itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@xbmc4lyfe

Copy link
Copy Markdown
Collaborator Author

Independent Claude review (fresh reviewer agent, read the diff against Spotweb's PHP parseHeader, Services_Signing_* and Services_Format_Util; Codex is out of credits).

Findings and what was done (fixed in spots: review fixes for signature checks):

  1. High: panic on a multibyte character right before < (&from[..open - 1] sliced inside a char). One such post would have killed the spots task, and every restart would panic again on the same line. Fixed: the signed text is built as bytes, as PHP does. Test odd_nicknames covers Né<...>.
  2. Low: an empty nickname wasn't rejected (PHP returns unverified). Fixed, and tested.
  3. Low: a user key that decodes to nothing skipped the message-id check. Fixed: the check is gated on the key text, and a key that won't decode fails it. Tested.
  4. Info: the signed text is rebuilt from decoded text (lossy UTF-8, mojibake undo, no RFC 2047 decode). It only decides the verdict for keys 2-4; key-7 spots rest on the hashcash and message-id signature. Documented on verify. The 2-of-350 Latin-1 DISPOSE failures in the PR body are this case.
  5. Info: a spotter id from the header signature alone can be replayed under a new message-id. Added Verdict::message_id_signed, so the moderation PR can trust a spotter's own DISPOSE only when their key signed its message-id.
  6. Nit: signatures shorter than the key were accepted. Fixed: exactly k bytes, as OpenSSL wants.
  7. Nit: the personal-key length test counts no = padding. It only differs for 48-50 character keys, and real keys are about 171. Left as is.

Checked and found correct: the PKCS#1 v1.5 encoding compare, s < n, the key-2 personal branch (the PHP filesize = 999 is an assignment, so it is always true), the hashcash, the message-id brackets, and header_value unfolding.

After the fixes: cargo test --lib spotnet:: passes (63), and the same 5,000 live free.pt lines give the same verdicts as before (all key-7 spots verify, 2 Latin-1 key-2 lines fail), with 60 HEAD re-checks matching. No open findings.

@xbmc4lyfe

Copy link
Copy Markdown
Collaborator Author

Independent re-review of the fix commit e638a1b: clean. Each fix matches the PHP behaviour and has a test, and nothing new was found. Merging.

@xbmc4lyfe
xbmc4lyfe marked this pull request as ready for review November 7, 2026 19:43
@xbmc4lyfe
xbmc4lyfe merged commit c1307b9 into main Nov 7, 2026
@xbmc4lyfe
xbmc4lyfe deleted the spot-signatures branch November 7, 2026 19:43
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@xbmc4lyfe

Copy link
Copy Markdown
Collaborator Author

Follow-up audit on current main (8462386):

Original report — VALID. The short-key compatibility boundary remains; the ordinary long-key path is unaffected.

src/spotnet/sign.rs:96 compares unprepared user_key.len() > 50; header::unprepare_base64 restores alphabet but not = padding. Keys whose padded length crosses 50 take a different personal-key branch than Spotweb.

The follow-up implementation or missing proof is still pending: Match the reference padded Base64 length rule without accepting invalid signature encodings; cover all decoded lengths around the 50-character boundary and verify both verdict.personal and verification behavior. No fix PR or validation result is claimed here.

These are conversation reports, so this reply does not mark any review thread resolved.

@xbmc4lyfe

Copy link
Copy Markdown
Collaborator Author

Follow-up to the original short-personal-key boundary report: the comparison now accounts for padding derived from prepared length before restored-length comparison, and the key-2 personal-command path uses that helper. This fixes the reported padded Base64 boundary rather than comparing unpadded restored length alone. Boundary fixture source is present; it was not executed by this audit. This standalone comment has no resolvable review-thread state.

Source-only closeout at main 1643d58 after #370; no executed tests or deployment is claimed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant