Skip to content

PrintVect 0.5.8: security fixes from the design review - #23

Merged
rahulranjan-dev-py merged 7 commits into
mainfrom
ccr-5c5bb225-3h4f6u
Oct 29, 2026
Merged

rahulranjan-dev-py merged 7 commits into
mainfrom
ccr-5c5bb225-3h4f6u

Conversation

@rahulranjan-dev-py

Copy link
Copy Markdown
Owner

This PR fixes the problems found in the owner's security review, one commit per item. Each item has its own test steps in docs/testing.md under "0.5.8", sections 1 to 7.

Changes

  1. Sharing PIN.
    • The PIN no longer crosses the network, not even as a hash. Each job and hello carries a one-time proof instead (PinProof): PBKDF2-SHA256 of the PIN, salted with the request's nonce, time, printer, job id and size.
    • A proof made more than a day from the host's clock is refused.
    • The old plain pin hash is never compared; the sender is told to update.
    • After 5 wrong PINs from one address, the host waits 15 minutes before checking that address again, doubling each time up to 4 hours (PinAttemptLimiter).
    • With a PIN set, a hello must prove it, so nobody can add made-up PCs to the list.
  2. Taking over a moved host.
    • Each host has an RSA identity key (HostIdentity), kept in config.json and protected with DPAPI.
    • Each printer remembers its host's key fingerprint, proven with a challenge at the address it was added from.
    • A printer follows its host to a new address only when the PC there signs a challenge together with that address (MovedHostCheck). This applies to discovery, to the search after a failed job, and to the PC-name fallback.
  3. Admin helper and links.
    • SafeFolders refuses any junction or symlink in the data folder.
    • Users:Modify is set on spool\<id> through a handle to the folder that was checked.
    • PrintVect.Elevate refuses to start when the data, spool or logs folder is a link, and the app checks the same before asking for permission.
  4. Host flooding.
    • Connection limits: 32 at once, 8 per address, 120 a minute per address. The request header must arrive within 15 s.
    • spool\incoming holds at most 1 GB, and a job must leave at least 256 MB free on the disk. Unused files are deleted first; if a job still doesn't fit, it is refused with retry.
    • A file that isn't XPS is deleted at once.
    • An hourly clean-up deletes files left by failed prints after 24 h.
  5. Updates.
    • A release without its .sha256 is not installed.
    • The setup program is held open (no writing, deleting or renaming of it or its folders) and its SHA-256 checked again through that handle just before it starts.
  6. Releases.
    • release.yml publishes a test version (pre-release) by default. Installed PCs ignore it, because they ask GitHub for the "latest release".
    • promote.yml makes it the latest release for every PC.
    • The release text is the version's CHANGELOG.md section (tools/release_notes.py).
  7. Smaller points.
    • config.json keeps the PIN protected with DPAPI. A plain PIN from before 0.5.8 is converted at the first start.
    • The 10.8 MB demo video and its poster are removed from the tree.

Version 0.5.8. Also updated: protocol.md, SECURITY.md, README.md (troubleshooting rows), docs/releasing.md (rewritten), CLAUDE.md and CHANGELOG.md.

Compatibility: with a sharing PIN, PCs on 0.5.7 and 0.5.8 cannot print to each other until both are updated. Without a PIN, mixed versions work.

Checked

  • Built against the .NET 4.8 reference assemblies on Mono: 182 tests pass.
  • The Windows CI build passed on every commit, and runs the Windows-only tests too: junction refusal, ACL through a handle, and the held setup file and its folder.
  • tools/release_notes.py was run on real versions, and the promote script was run against a stand-in for gh.

Generated by Claude Code

From the owner's security review: the header carried SHA-256(PIN), which
anyone who saw it could reuse as the password forever, and the host never
slowed down wrong guesses.

- PinProof (replaces PinHash): each job and hello carries nonce, time and
  pinProof = PBKDF2-HMAC-SHA256(PIN, salt = label, type, nonce, time,
  printerId, jobId, size; 20,000 rounds). JobClient makes it just before
  sending (fresh for every try). A proof made for another job, printer or
  size does not match; one more than 24 h from the host's clock is refused.
  The old "pin" hash is never compared: a host tells such a sender to update.
- PinAttemptLimiter: 5 wrong PINs from one address -> the host checks that
  address again only after 15 minutes, doubling to at most 4 hours; a right
  PIN or a quiet day starts afresh. Refusals keep the job for Retry.
- Hello: with a PIN, only PCs that prove it are listed under "PCs that use
  this PC". A client whose hello is refused stops saying hello to that host
  until its PIN changes, so a wrong PIN does not keep counting as tries.
- PIN hints advise 8 or more characters.
- Tests for the proof, replay, clock, outdated hash, the wait, and hello.
- Version 0.5.8; protocol.md, README, SECURITY.md, CLAUDE.md, CHANGELOG,
  testing.md steps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JFV1W7wPfiMU9itafQutsk
From the owner's security review: when a host stopped answering, the
client followed any PC that answered with the same PC name or printer id,
both broadcast openly, and sent documents and the PIN proof there. A
random host id alone would not help: any PC can ask the host for it.

- HostIdentity: each host makes an RSA-2048 key on first start, kept in
  config.json (HostKey) protected with DPAPI for that PC
  (MachineProtection). Discovery and list replies carry the public key;
  a list request with a challenge gets hostSig over challenge, host name
  and the address the request reached (HostKeys).
- RemotePrinter.HostKeyId: the key's fingerprint, proven with a challenge
  when the printer is added, or after the host's next answered hello for
  printers added before.
- MovedHostCheck: following a host to a new address (discovery, or the
  search after a failed job, now trying every address heard for the name)
  and the PC-name fallback of TcpJobSender need the remembered key proven
  for that address. A refused PC gets nothing and the waiting job says
  why. Printers with no key yet, and hosts before 0.5.8, work as before.
- Diagnostics shows whether the key is kept and how many printers know
  their host's key.
- Tests: signatures, follow/refuse decisions (impostor, copied key,
  relayed answer, no key), a real host over loopback, the stored key.
- protocol.md, SECURITY.md, README, CLAUDE.md, CHANGELOG, testing.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JFV1W7wPfiMU9itafQutsk
From the owner's security review: every user may write in
%ProgramData%\PrintVect, and PrintVect.Elevate (administrator) granted
Users:Modify on spool\<id> without checking for a junction, so a standard
user could plant one to a system folder before an admin added a printer.
The same held for the folders it creates and deletes and for its log and
result file.

- SafeFolders (Core/Elevation): FirstLink walks every folder from the
  data folder down and reports a junction or symbolic link; CreateFolder
  and RefuseLinks throw LinkFoundException with a plain message.
  GrantUsersModify opens spool\<id> without following a link, checks it
  is that very folder (GetFinalPathNameByHandle against the data folder's
  real path) and sets the rule through that handle (NativeObjectSecurity),
  so it cannot be swapped in between.
- PrintVect.Elevate: refuses to start when the data, spool or logs folder
  is a link; add-printer, folder deletion and the result file go through
  SafeFolders. The app checks the same before asking for permission, so
  the person sees the reason.
- Tests: links found on the way (junction on Windows, symlink on Mono),
  nothing created through a linked parent, rights granted on the real
  folder and refused through a junction (Windows).
- CHANGELOG, SECURITY.md, CLAUDE.md, testing.md steps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JFV1W7wPfiMU9itafQutsk
From the owner's security review: the host had no limit on connections,
kept files that were not XPS (up to 200 MB each) and failed prints, and
cleaned up old files only when sharing started.

- ConnectionLimiter: at most 32 connections at once, 8 per address and
  120 new ones a minute per address; more are closed at once and logged
  once a minute per address.
- A connection must send its request header within 15 s (HeaderTimeout);
  the transfer then has its 5 minutes as before.
- spool\incoming\ holds at most 1 GB (MaxIncomingBytes, with sizes of
  transfers in progress reserved) and a job must leave 256 MB free on the
  disk; older files no job waits for are deleted first, oldest first, and
  a job that still does not fit is refused with retry:true.
- A file that is not XPS is deleted at once; files kept after a failed
  print are deleted after 24 hours by an hourly clean-up. Files of jobs
  still waiting or printing are never touched.
- Tests: limiter rules, a silent connection closed, a third connection
  from one PC closed, the size cap with eviction, junk deleted, the sweep.
- protocol.md, README, CLAUDE.md, CHANGELOG, testing.md steps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JFV1W7wPfiMU9itafQutsk
From the owner's security review: a release without a .sha256 installed
after a size check only, and the verified setup program waited in
%ProgramData%\PrintVect\updates, where every user may write, between its
check and its start.

- UpdateChecker.DownloadAsync refuses a release without a checksum file
  (nothing is downloaded) and returns a VerifiedSetup (path, SHA-256,
  size).
- UpdateInstaller.Hold opens the setup with FileShare.Read, so nobody
  can write, delete or rename it or a folder above it, and checks size
  and SHA-256 again through that handle; Start launches the held file.
  The hold lasts until the setup ends (or this program is ended by it).
  A changed file is not started: "The update was not started: ...".
- Tests: no checksum refused, the verified file held unchangeable
  (Windows), a file swapped after the download refused.
- README, SECURITY.md, docs/releasing.md, CLAUDE.md, CHANGELOG,
  testing.md. Code signing remains the real fix (CODE_SIGNING.md).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JFV1W7wPfiMU9itafQutsk
…elog

From the owner's security review: every release reached every PC within
a day, tested or not (0.5.4 to 0.5.7 all "awaiting test"), and the
release text did not say what changed.

- release.yml publishes a TEST version by default (Run workflow, stage
  test; a pushed tag too): a GitHub pre-release, which installed PCs
  never take because they ask for the "latest release". Stage everyone
  publishes straight to every PC. A release made on the website keeps
  the owner's choice and gets the text when none was typed.
- promote.yml (Run workflow): checks the release has the setup program
  and its .sha256, makes it a full release marked latest and rewrites
  its text without the test note.
- tools/release_notes.py writes the text from the version's CHANGELOG.md
  section (paragraphs unwrapped for GitHub) and fails when there is none.
- docs/releasing.md rewritten for the test-then-promote flow; CLAUDE.md,
  CHANGELOG, testing.md steps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JFV1W7wPfiMU9itafQutsk
…s the repo

From the owner's security review (smaller points; the hello PIN check was
already done with the PIN proof):

- config.json no longer holds the sharing PIN in plain text: AppConfig.Pin
  is in memory only ([JsonIgnore]) and the file keeps PinProtected (DPAPI
  for this PC, MachineProtection, as the host key). A plain "Pin" written
  before 0.5.8 is read once and the file saved again without it. A value
  protected on another PC cannot be read: the PC then has no PIN and the
  log says to set it again.
- docs/media/printvect-demo.mp4 (10.8 MB) and its poster removed: nothing
  refers to them; the README plays the copy uploaded to GitHub. Past
  commits still hold the video until the history is rewritten.
- Tests: the PIN is not in the saved file; a plain PIN is converted.
- SECURITY.md, CLAUDE.md, CHANGELOG, testing.md steps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JFV1W7wPfiMU9itafQutsk
@rahulranjan-dev-py
rahulranjan-dev-py merged commit 21e38b3 into main Oct 29, 2026
2 checks passed
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.

2 participants