Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ Newest first. Each version is a [release](https://github.com/rahulranjan-dev-py/
program; PCs that run PrintVect offer the newest one by themselves (Settings, Updates). **Tested** says how far the
version was tried on the office's PCs (Windows 10 and 11).

## 0.5.9

Three more security fixes. Before a job leaves, the PC at the printer's saved address must prove it is the PC the
printer was added from (with its identity key, checked again every 5 minutes): before, that was checked only when the
address changed, so another PC that was given the old address could receive documents. New sharing PINs need at least
8 characters; a shorter PIN set before keeps working, and Settings shows a note ("Short") next to it. The PC with the
printer refuses a request whose one-time PIN proof it has already accepted, so a recorded request cannot be sent
again. The PIN window shows again why a PIN is not taken: in 0.5.8 its longer explanation left the message no room,
so Save PIN seemed to do nothing. **Tested:** awaiting test.

## 0.5.8

Security fixes from a review of the design.
Expand Down
6 changes: 3 additions & 3 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ polling, re-checks within 0.5 s; taken when exclusively openable and size stable
(XpsFormatSniffer looks inside: namespace openxps.org = oxps; it also reads the docProps title; the v4 writer stores
none, so the document name comes from EnumJobs on the virtual printer while the port writes) -> ClientService sends
(3 tries, each IP then PC name; after the first failure one 3 s discovery search follows a host that moved (0.5.0); a new address or the name's
address is used only once it signs a challenge with the host key remembered for the printer (0.5.8, HostIdentity, MovedHostCheck); then pending\
address is used only once it signs a challenge with the host key remembered for the printer (0.5.8, HostIdentity, MovedHostCheck; 0.5.9: the saved address too, before each job, passed checks kept 5 min in TcpJobSender); then pending\
and Retry resends under the same job id; sent\ kept 1 h, failed\ last 20) and polls status.
Host: receive into spool\incoming\ -> verify size, sniff the real format -> HostPrintEngine -> reply JSON -> watch the
job (up to 60 s before replying). One job at a time per printer, arrival order, on that printer's worker thread (never
Expand All @@ -68,14 +68,14 @@ unit-tested with fakes over loopback TCP (tests never load System.Printing, whic
printers} every 5 min to each host used -> its "PCs that use this PC". Refusals: drained, ok=false; "retry":true =
keep for Retry (lost job, PIN). A job id already printed or still queued gets its state back, never printed twice.
- Sharing PIN (0.5.8, PinProof): job and hello carry nonce, time, pinProof = PBKDF2-SHA256(PIN, salt nonce/time/printer/jobId/size, 20000);
time within 24 h; the old plain hash "pin" is refused; 5 wrong per address -> wait 15 min, doubling to 4 h (PinAttemptLimiter).
time within 24 h; the old plain hash "pin" is refused; 5 wrong per address -> wait 15 min, doubling to 4 h (PinAttemptLimiter); a nonce seen before is refused (NonceMemory, 0.5.9). New PINs 8-12 characters (0.5.9).
Empty PIN = open on the LAN. Limits: file 200 MB, connect 5 s, header 15 s, transfer 5 min, discovery 2 s; host (0.5.8, ConnectionLimiter): 32 connections, 8 per address, 120/min per address; incoming <= 1 GB and 256 MB disk free (unused files evicted first, else retry), non-XPS deleted, unused files gone after 24 h (hourly). Manual IP/name entry always exists.

## Workflow
- One milestone at a time (M0..M6 in the brief, section 9). Finish, build, hand over test steps,
then wait for the owner's result before starting the next one. M4 (Windows 7 pass) is skipped:
the office has no Windows 7 PC (owner, 2026-10-06); keep Windows 7 paths only where they cost nothing. M6: M6a
updates, M6b-1 new look, M6b-2 hardening; then 0.4.1 (jobs menu), 0.5.0 (redesign, colours, hotspot), 0.5.1-0.5.3 (look fixes), 0.5.4, 0.5.5 (no office words: homes too), 0.5.6 (menu fits), 0.5.7 (copies window), 0.5.8 (security review: PIN proof, host identity, Elevate link guard, host flood limits, strict updates, test releases).
updates, M6b-1 new look, M6b-2 hardening; then 0.4.1 (jobs menu), 0.5.0 (redesign, colours, hotspot), 0.5.1-0.5.3 (look fixes), 0.5.4, 0.5.5 (no office words: homes too), 0.5.6 (menu fits), 0.5.7 (copies window), 0.5.8 (security review: PIN proof, host identity, Elevate link guard, host flood limits, strict updates, test releases), 0.5.9 (host key before each job, 8-character PINs, nonce memory).
- Build: `msbuild PrintVect.sln /p:Configuration=Release` (VS 2022 Build Tools + .NET Framework 4.8 targeting pack); `dotnet build PrintVect.sln -c Release` (.NET 8 SDK) too.
- Tests: `dotnet test tests/PrintVect.Tests/PrintVect.Tests.csproj -c Release`. CI: .github/workflows/build.yml (windows-latest) builds, tests, makes the setup program;
release.yml publishes a TEST version (pre-release, never "latest", so PCs skip it; text = CHANGELOG section via tools/release_notes.py); promote.yml makes it the latest release for every PC (0.5.8).
Expand Down
6 changes: 3 additions & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>

<!-- Raise all three together before publishing a release (README, "Publishing a new version"). -->
<Version>0.5.8</Version>
<AssemblyVersion>0.5.8.0</AssemblyVersion>
<FileVersion>0.5.8.0</FileVersion>
<Version>0.5.9</Version>
<AssemblyVersion>0.5.9.0</AssemblyVersion>
<FileVersion>0.5.9.0</FileVersion>
<Product>PrintVect</Product>
<Company>PrintVect</Company>
<Authors>PrintVect contributors</Authors>
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ report to copy.
ports in Windows Firewall for PrintVect only, on private and domain networks only, never on public ones.
- Without a sharing PIN, any PC on the same network can print to the shared printers; set the same PIN on every
PC to limit that (Settings, Security). The PIN itself never crosses the network: each job carries a one-time
proof of it, and a PC that sends 5 wrong PINs has to wait. Longer PINs (8 or more characters) are harder to guess.
proof of it, and a PC that sends 5 wrong PINs has to wait. New PINs have at least 8 characters (0.5.9); a shorter
one set before keeps working, with a note in Settings.
Print jobs are not encrypted on the network.
- PrintVect runs as a normal user. Only its small helper, `PrintVect.Elevate.exe`, asks for administrator rights,
for the few tasks that need them: adding or removing a printer, starting with Windows, making a network private.
Expand Down
6 changes: 4 additions & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ These are known limits of the design, not vulnerabilities:
- Without a sharing PIN, any PC on the same network can print to the shared printers. With a PIN (0.5.8), every job and
hello carries a one-time proof of it (PBKDF2-SHA256 salted with that request), never the PIN or a plain hash of it,
and a PC that sends 5 wrong PINs must wait 15 minutes, twice as long each further time. Someone who records the
network traffic can still try to guess a short PIN offline, so use 8 or more characters where that matters. Print
network traffic can still try to guess a short PIN offline, so new PINs have at least 8 characters (0.5.9). Each proof
is accepted once: the host remembers the one-time values it accepted until they expire and refuses a copy. Print
jobs are not encrypted on the network.
- config.json keeps the PIN and the PC's identity key protected with Windows DPAPI for that PC (0.5.8), so they do not
show in the file or in a copy taken elsewhere. Any program running on that PC can still read them back, so the PIN
protects against other PCs, not against other people who use the same PC.
- A PC name and printer ids can be claimed by any PC on the network. Since 0.5.8 a printer follows its host to a new
address only when the PC there proves, by signing a random challenge with the host's identity key, that it is the
PC the printer was added from. Someone who can intercept the network traffic itself (not just answer on it) is
PC the printer was added from. Since 0.5.9 the PC at the saved address must prove it too before a job goes there
(checked again every 5 minutes), in case another PC was given the host's old address. Someone who can intercept the network traffic itself (not just answer on it) is
outside what PrintVect can stop.
- Every user may write in `C:\ProgramData\PrintVect`. The administrator helper (`PrintVect.Elevate.exe`) checks that no
folder it creates, gives rights on, deletes or writes its log and result in is a junction or symbolic link, and
Expand Down
7 changes: 7 additions & 0 deletions docs/protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ address with the remembered key; one that claims the host's name or printers wit
says why. A printer with no key yet remembers the first one proven to it; a host before 0.5.8 (no key) is followed
as before. The signed address stops a PC from passing on the real host's answer from elsewhere.

Since 0.5.9 the client also checks the PC at the printer's saved address before it sends a job there: the same list
request with a challenge, trusted for 5 minutes once passed. When it fails, nothing is sent; the client treats the
host as not reachable at that address (it searches for it, then keeps the job for Retry with the reason).

## Job header

```json
Expand Down Expand Up @@ -91,6 +95,9 @@ without a proof with `retry:true`; a request with only the `pin` field of earlie
refused with a message to update the sender. After 5 wrong proofs from one address the host refuses that address for
15 minutes without checking, twice as long after each further 5 (at most 4 hours); a right PIN or a day without a
wrong one starts afresh. A hello proves the PIN the same way (with `printerId`, `jobId` and `size` empty and 0).
Since 0.5.9 the host remembers every `nonce` it accepted until its proof expires (`time` plus 24 hours) and refuses a
request that brings one again (a copy of a recorded request); that also counts as a wrong try. Every real send,
Retry included, makes a new nonce.

`copies` (optional, default 1, at most 99) asks the host to print the document that many times; the client
fills it from the XPS print ticket inside the file (`JobCopiesAllDocuments`), which Word and Excel set when the
Expand Down
14 changes: 14 additions & 0 deletions docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,20 @@ was committed although the README plays the copy uploaded to GitHub.
| 1 | On a PC that had a PIN before the update, open `C:\ProgramData\PrintVect\config.json` in Notepad. | No `"Pin": "…"` line; a long `"PinProtected"` value instead. The log of the first start: "the sharing PIN was kept in plain text; config.json now keeps it protected for this PC." Printing with the PIN works as before. |
| 2 | Settings, Security, Change PIN; then look at config.json again. | Still no PIN in plain text; the other PCs need the new PIN as before. |

## 0.5.9: host key before every job, 8-character PINs, one-time proofs

Three more fixes the owner asked for after 0.5.8 (2026-10-30). Use HOST (shares the printer) and CLIENT (prints), both
on 0.5.9.

| # | Do this | Expect this |
|---|---------|-------------|
| 0 | Install the 0.5.9 test version on HOST and CLIENT (docs/releasing.md: download the setup from the release page). | "Version 0.5.9" under the menu. |
| 1 | Print a page from CLIENT, and another within 5 minutes. | Both print. CLIENT's log, first job only: "The PC at 192.168.… proved it is HOST (identity key checked; checked again after 5 minutes)." |
| 2 | (Optional, needs a spare PC) switch HOST off, give the spare PC HOST's old address (on the router, or as a fixed address), share a printer on it, wait 5 minutes and print from CLIENT. | Nothing prints on the spare PC. The job waits: "… is not HOST, the PC this printer was added from … Nothing was sent there." |
| 3 | On a PC whose PIN has fewer than 8 characters: Settings. | Sharing PIN shows an orange "Short" and the note "This PIN has 4 characters; new PINs need at least 8 …". Printing still works. Diagnostics: "Sharing PIN is short". |
| 4 | Change PIN…, type 1234 twice. | "The PIN needs 8 to 12 characters." Type an 8-character PIN: saved, "Short" gone. Set the same PIN on the other PCs. |
| 5 | Nothing to do for the one-time proofs: printing and Retry work as before. (A copied request would be refused with "its one-time PIN proof was already used"; the unit tests check that.) | |

## Later

Phase 2 items (brief section 9): raw port-9100 relay, Hindi UI, optional service host, job counter per user.
4 changes: 2 additions & 2 deletions installer/PrintVect.iss
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
; PrintVect installer (Inno Setup 6, milestone M5; silent in-app updates since M6a).
; CI builds it with: ISCC.exe /DAppVersion=0.5.8 /DSourceDir=<folder with the built program files> installer\PrintVect.iss
; CI builds it with: ISCC.exe /DAppVersion=0.5.9 /DSourceDir=<folder with the built program files> installer\PrintVect.iss
; The source folder is what the build workflow collects: PrintVect.App.exe, PrintVect.Core.dll,
; Newtonsoft.Json.dll, PrintVect.Elevate.exe, pvct-send.exe, Fonts\, the sample .xps files, README.md, LICENSE.
; An update from inside PrintVect runs this same program as PrintVect-Setup-<version>.exe /SILENT /NORESTART /LOG=...
; started by the app like a double-click: Setup asks Windows for administrator rights itself, ends the running
; PrintVect (PrepareToInstall below), installs over the old files and starts PrintVect again as the signed-in user.

#ifndef AppVersion
#define AppVersion "0.5.8"
#define AppVersion "0.5.9"
#endif
#ifndef SourceDir
#define SourceDir "..\artifacts\PrintVect"
Expand Down
1 change: 1 addition & 0 deletions src/PrintVect.App/Client/ClientController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public ClientController(AppPaths paths, ConfigStore store, AppConfig config, Syn
tracker.Changed += (s, record) => _history.QueueSave();

var sender = new TcpJobSender();
sender.HostKeyLearned += (s, printer) => Post(() => TrySave()); // learned before a job (0.5.9)
_service = new ClientService(paths, sender, tracker)
{
Pin = config.Pin,
Expand Down
26 changes: 22 additions & 4 deletions src/PrintVect.App/Forms/PinDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ namespace PrintVect.App.Forms
/// </summary>
internal sealed class PinDialog : Form
{
public const int MinLength = 4;
/// <summary>
/// 8 since 0.5.9 (was 4): someone who records the network can try every short PIN on their own computer. A
/// shorter PIN saved before keeps working; Settings shows a note next to it (IsShort).
/// </summary>
public const int MinLength = 8;
public const int MaxLength = 12;

private readonly InputBox _pin;
Expand All @@ -37,7 +41,7 @@ public PinDialog(bool hasPin)
var card = new Card { Dock = DockStyle.Fill, Margin = Ui.Pad(0) };
outer.Controls.Add(card);

TableLayoutPanel column = Make.Column(0, 0, 0, 0, 0, 0, 100, 0);
TableLayoutPanel column = Make.Column(0, 0, 0, 0, 0, 0, 0, 100, 0);
column.Controls.Add(Make.Label(hasPin ? Strings.PinChangeTitle : Strings.PinSetTitle, ThemeFonts.Heading, Palette.Text, Ui.Pad(0, 0, 0, 8)), 0, 0);
Label explain = Make.Muted(Strings.PinExplain);
explain.Margin = Ui.Pad(0, 0, 0, 14);
Expand All @@ -56,12 +60,20 @@ public PinDialog(bool hasPin)
var cancel = new ThemedButton(Strings.CopiesCancel, ButtonKind.Secondary) { DialogResult = DialogResult.Cancel, Margin = Ui.Pad(0) };
FlowLayoutPanel buttons = Make.Row(save, cancel);
buttons.Margin = Ui.Pad(0, 12, 0, 0);
column.Controls.Add(buttons, 0, 7);
column.Controls.Add(buttons, 0, 8);
card.Controls.Add(column);
Controls.Add(outer);

AcceptButton = save;
CancelButton = cancel;

// As tall as the content with room for the longest message, which the empty row 7 gives back while there is
// none (0.5.9: with a fixed height a four-line explanation left the message no room, so a refused PIN
// showed nothing).
_problem.Text = Strings.PinMismatch;
int inner = ClientSize.Width - outer.Padding.Horizontal - card.Padding.Horizontal;
ClientSize = new Size(ClientSize.Width, outer.Padding.Vertical + card.Padding.Vertical + column.GetPreferredSize(new Size(inner, 0)).Height);
_problem.Text = "";
Ui.Solidify(this);
}

Expand Down Expand Up @@ -101,7 +113,13 @@ private void TrySave()
Close();
}

/// <summary>Why the two entries cannot be saved, or null. The rule: 4 to 12 characters, no spaces at the ends, typed twice alike.</summary>
/// <summary>Why the two entries cannot be saved, or null. The rule: 8 to 12 characters (0.5.9; was 4), no spaces at the ends, typed twice alike.</summary>
/// <summary>A saved PIN shorter than new ones may be (set before 0.5.9).</summary>
internal static bool IsShort(string pin)
{
return !string.IsNullOrEmpty(pin) && pin.Length < MinLength;
}

internal static string Check(string pin, string again)
{
pin = pin ?? "";
Expand Down
12 changes: 9 additions & 3 deletions src/PrintVect.App/Forms/SettingsPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,12 @@ private void ShowValues()
try
{
bool hasPin = !string.IsNullOrEmpty(_config.Pin);
_pinPill.Set(hasPin ? Strings.SettingsPinSetPill : Strings.SettingsPinNotSetPill, hasPin ? PillKind.Success : PillKind.Warning);
_pinText.Text = hasPin ? Strings.SettingsPinOn : Strings.SettingsPinOff;
bool shortPin = PinDialog.IsShort(_config.Pin);
_pinPill.Set(!hasPin ? Strings.SettingsPinNotSetPill : shortPin ? Strings.SettingsPinShortPill : Strings.SettingsPinSetPill,
hasPin && !shortPin ? PillKind.Success : PillKind.Warning);
_pinText.Text = !hasPin ? Strings.SettingsPinOff
: shortPin ? Strings.SettingsPinOn + " " + string.Format(CultureInfo.CurrentCulture, Strings.SettingsPinShort, _config.Pin.Length, PinDialog.MinLength)
: Strings.SettingsPinOn;
_pinSet.Text = hasPin ? Strings.SettingsPinChange : Strings.SettingsPinSet;
_pinSet.Kind = hasPin ? ButtonKind.Secondary : ButtonKind.Primary;
_pinSet.Font = hasPin ? ThemeFonts.TextMedium : ThemeFonts.TextSemi;
Expand Down Expand Up @@ -664,7 +668,9 @@ private void ShowChecks(Snapshot s)

items.Add(string.IsNullOrEmpty(_config.Pin)
? Tuple.Create(CheckLevel.Warning, Strings.CheckPinOff, sharing ? Strings.CheckPinOffSharing : Strings.CheckPinOffText)
: Tuple.Create(CheckLevel.Ok, Strings.CheckPinOn, Strings.CheckPinOnText));
: PinDialog.IsShort(_config.Pin)
? Tuple.Create(CheckLevel.Warning, Strings.CheckPinShort, string.Format(CultureInfo.CurrentCulture, Strings.SettingsPinShort, _config.Pin.Length, PinDialog.MinLength))
: Tuple.Create(CheckLevel.Ok, Strings.CheckPinOn, Strings.CheckPinOnText));

int remote = _client.Printers.Count;
items.Add(sharing
Expand Down
Loading
Loading