From 302b9fb5c5342fca01df7add03aa343c55f08df4 Mon Sep 17 00:00:00 2001 From: usul <419201+fdussert@users.noreply.github.com> Date: Mon, 19 Oct 2026 18:39:24 +0200 Subject: [PATCH 1/2] Honour the private pasteboard markers other apps set The clipboard provider already skipped a pasteboard carrying the nspasteboard.org Concealed, Transient or AutoGenerated types. Some applications mark what they copy with their own type instead of, or as well as, those: 1Password, KeeWeb, Butler, Typeit4me and Keyboard Maestro's generator. Other clipboard managers honour these markers too, so a copy carrying one is now never recorded either. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 8 ++++++++ server/src/providers/clipboard.ts | 9 ++++++++- server/test/clipboard.test.ts | 3 ++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d1f0073..017e7ece 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,14 @@ Anything that changes what the dashboard, the admin or a widget can do gets a li (`package.json`, `server/package.json`, `ui/package.json`, `server/src/version.ts`) and is tagged `vX.Y.Z`. +## Unreleased + +### Fixed + +- **The clipboard widget leaves alone what more password managers copy.** Besides the standard + "concealed" and "transient" markers, a copy from 1Password, KeeWeb, Butler, Typeit4me or a + Keyboard Maestro generator is no longer recorded at all. + ## 0.5.0 — 2026-10-19 ### Added diff --git a/server/src/providers/clipboard.ts b/server/src/providers/clipboard.ts index 40dc5472..28b402b6 100644 --- a/server/src/providers/clipboard.ts +++ b/server/src/providers/clipboard.ts @@ -42,12 +42,19 @@ const SECRET_MARKERS = ['password', 'mot de passe', 'secret', 'bearer', 'private * value the same way. `pbpaste` reports neither — it hands over the text and says nothing — so * the types have to be read separately. Honoured by not recording the entry at all. * - * https://github.com/sindresorhus/Pasteboard-Viewer documents the convention. + * https://github.com/sindresorhus/Pasteboard-Viewer documents the convention. The last group are + * the private markers some applications set instead of (or as well as) it — 1Password, KeeWeb, + * Butler, Typeit4me, Keyboard Maestro — which other clipboard managers honour too. */ export const PRIVATE_PASTEBOARD_TYPES = [ 'org.nspasteboard.ConcealedType', 'org.nspasteboard.TransientType', 'org.nspasteboard.AutoGeneratedType', + 'com.agilebits.onepassword', + 'net.antelle.keeweb', + 'de.petermaurer.TransientPasteboardType', + 'com.typeit4me.clipping', + 'Pasteboard generator type', ] /** diff --git a/server/test/clipboard.test.ts b/server/test/clipboard.test.ts index 8dabb874..81d25105 100644 --- a/server/test/clipboard.test.ts +++ b/server/test/clipboard.test.ts @@ -229,7 +229,8 @@ describe('a pasteboard that asks not to be remembered', () => { it('records nothing at all for a concealed pasteboard', async () => { for (const type of ['org.nspasteboard.ConcealedType', 'org.nspasteboard.TransientType', - 'org.nspasteboard.AutoGeneratedType']) { + 'org.nspasteboard.AutoGeneratedType', 'com.agilebits.onepassword', 'net.antelle.keeweb', + 'de.petermaurer.TransientPasteboardType', 'com.typeit4me.clipping', 'Pasteboard generator type']) { const p = createClipboardProvider(board('the password itself', ['public.utf8-plain-text', type])) const snapshot = await p.poll!() as { entries: unknown[] } // Not masked — absent. A password manager's copy is not ours to hold. From 544344ccd195e001bccd1fca0b5712906c8e67b5 Mon Sep 17 00:00:00 2001 From: usul <419201+fdussert@users.noreply.github.com> Date: Mon, 19 Oct 2026 18:40:07 +0200 Subject: [PATCH 2/2] Mask one-time codes in the clipboard history Every rule in isSecret started at eight characters, so a six-digit OTP copied from an SMS or an authenticator was recorded unmasked: shown on the Edge, kept in the 20-entry history, and sent to a paired iPad whose screen holds the clipboard widget. A text that is only four to eight digits, or two groups of three or four split by one space or dash, is now masked. It is tested before the whitespace rule so "482 913" counts. The rule is anchored on the whole text: digits inside prose, phone numbers (more digits, more groups) and lopsided splits are left alone. A bare year or postcode copied on its own is masked too, which costs a preview and nothing else. Found while reviewing PR #49. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 4 ++++ server/src/providers/clipboard.ts | 23 ++++++++++++++++++++--- server/test/clipboard.test.ts | 20 ++++++++++++++++++++ 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 017e7ece..45ec051c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,10 @@ tagged `vX.Y.Z`. ### Fixed +- **The clipboard widget masks one-time codes.** A six-digit code copied from a text message or + an authenticator (`482913`, `482 913`, `4829-1375`) showed in full on the Edge and on a paired + iPad; any run of four to eight digits copied on its own is now shown as a secret, and still + copies back with a tap. Numbers inside a sentence and phone numbers are shown as before. - **The clipboard widget leaves alone what more password managers copy.** Besides the standard "concealed" and "transient" markers, a copy from 1Password, KeeWeb, Butler, Typeit4me or a Keyboard Maestro generator is no longer recorded at all. diff --git a/server/src/providers/clipboard.ts b/server/src/providers/clipboard.ts index 28b402b6..40d8db12 100644 --- a/server/src/providers/clipboard.ts +++ b/server/src/providers/clipboard.ts @@ -32,6 +32,20 @@ export const SECRET_MIN_LENGTH = 32 */ export const SECRET_TOKEN_MIN_LENGTH = 8 +/** + * A one-time code copied on its own: four to eight digits, or two groups of three or four split by + * one space or dash (`482913`, `482 913`, `4829-1375`), and nothing else in the text. + * + * Every other rule starts at eight characters, so a six-digit code from an SMS or an + * authenticator went up on the Edge in full, stayed in the history and reached a paired iPad. + * + * The trade-off: a bare number of that size copied alone — a year, a postcode, an extension — is + * masked too, and stays copyable. Anything around the digits (`Meeting at 2026`), a phone number + * (more digits, more groups) and a lopsided split (`4 82913`) are left alone: masking every number + * in a clipboard would hide much more than it protects. + */ +const ONE_TIME_CODE = /^(\d{4,8}|\d{3,4}[ -]\d{3,4})$/ + /** Substrings that mark a text as a secret whatever its shape. Matched case-insensitively. */ const SECRET_MARKERS = ['password', 'mot de passe', 'secret', 'bearer', 'private key', 'sk-', 'ghp_', 'github_pat_', 'xoxb-', 'api key', 'apikey'] @@ -149,9 +163,10 @@ export function capText(text: string): string { /** * Whether a text is treated as a secret. * - * Three ways in: it names one outright, it is a long unbroken run (an API key), or it is a - * shorter unbroken run mixing character classes — which is what an ordinary password looks like, - * and what the length rule alone used to publish in full onto a screen on a desk. + * Four ways in: it names one outright, it is a one-time code (`ONE_TIME_CODE`), it is a long + * unbroken run (an API key), or it is a shorter unbroken run mixing character classes — which is + * what an ordinary password looks like, and what the length rule alone used to publish in full + * onto a screen on a desk. * * Deliberately generous: a false positive costs the user a preview they can still copy, a false * negative puts their password on the wall. Anything with whitespace in it is prose and is left @@ -161,6 +176,8 @@ export function isSecret(text: string): boolean { const trimmed = text.trim() const lower = trimmed.toLowerCase() if (SECRET_MARKERS.some((marker) => lower.includes(marker))) return true + // Before the whitespace rule: `482 913` is a code, not prose. + if (ONE_TIME_CODE.test(trimmed)) return true if (/\s/.test(trimmed)) return false if (trimmed.length >= SECRET_MIN_LENGTH) return true if (trimmed.length < SECRET_TOKEN_MIN_LENGTH) return false diff --git a/server/test/clipboard.test.ts b/server/test/clipboard.test.ts index 81d25105..d6e29afa 100644 --- a/server/test/clipboard.test.ts +++ b/server/test/clipboard.test.ts @@ -64,6 +64,13 @@ describe('clipboard history', () => { const snap = await p.poll!() as ClipboardSnapshot expect(snap.entries).toHaveLength(1) }) + it('records a one-time code masked, never in full', async () => { + const { pasteboard } = fake('482913') + const p = createClipboardProvider(pasteboard, now) + const snap = await p.poll!() as ClipboardSnapshot + expect(snap.entries.map((e) => [e.preview, e.masked])).toEqual([[MASKED_PREVIEW, true]]) + expect(JSON.stringify(snap)).not.toContain('482913') + }) it('moves an entry copied again back to the front instead of duplicating it', async () => { const { pasteboard, set } = fake('one') const p = createClipboardProvider(pasteboard, now) @@ -211,6 +218,19 @@ describe('what counts as a secret', () => { it('still masks a destination long enough to be carrying a token', () => { expect(isSecret('https://example.com/reset?token=' + 'a'.repeat(40))).toBe(true) }) + it('masks a one-time code: a short run of digits copied on its own', () => { + // Eight characters was the floor of every other rule, so a six-digit code went up on the + // Edge in full, stayed in the history and reached a paired iPad. + for (const text of ['482913', '4829', '48291375', '482 913', '482-913', '4829-1375', ' 482913\n']) { + expect(isSecret(text), text).toBe(true) + } + }) + it('leaves numbers in prose, and longer or oddly split numbers, alone', () => { + for (const text of ['Meeting at 2026', 'Room 4829 at 10:30', '123', '482913750', + '06 12 34 56 78', '+33 6 12 34 56 78', '4 82913', '48 2913']) { + expect(isSecret(text), text).toBe(false) + } + }) it('counts the character classes a text draws on', () => { expect(characterClasses('abcdef')).toBe(1) expect(characterClasses('abcDEF')).toBe(2)