Skip to content

Validate the paste id in cmdv:// deep links - #7

Merged
oklar merged 1 commit into
mainfrom
validate-paste-deep-link
Oct 31, 2026
Merged

oklar merged 1 commit into
mainfrom
validate-paste-deep-link

Conversation

@oklar

@oklar oklar commented Oct 31, 2026

Copy link
Copy Markdown
Owner

Why

parse_paste_deep_link percent-decoded the id parameter, and fetch_ciphertext put it straight into DELETE {api}/clipboard/{id}. A crafted cmdv://paste?id=..%2F..%2F… link therefore sent a request, with a fresh X-XSRF-TOKEN, to any path on the API. The impact is small, because the desktop client sends no auth on this call, but the id should never be able to leave /clipboard/.

What changes

reveal.rs: a link is accepted only if

  • the id is a 22-character base64url ShortGuid (the format the API issues), and
  • the key is base64url. decrypt_paste already enforces the 16-byte key length.

Anything else falls through to the existing "Ignoring unrecognized deep link" path.

Testing

  • New tests:
    • rejects ..%2F…, abc%3Fx%3D1, a short id and a 23-character id;
    • rejects a key containing / or +;
    • the valid-link test now uses a realistic id and key.
  • cargo test --locked: 52/52 pass.
  • Not tried with a real cmdv:// link in a built app.

🤖 Generated with Claude Code

The id was percent-decoded and interpolated into
DELETE {api}/clipboard/{id}, so a crafted link like
cmdv://paste?id=..%2F..%2Fsomething&key=x sent a CSRF-tokened DELETE to
any path on the API. Accept only 22-char base64url ShortGuids (what the
API issues) and a base64url key; decrypt_paste already enforces the
16-byte key length.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@oklar
oklar merged commit 0a9d2df into main Oct 31, 2026
1 check 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.

1 participant