Skip to content

GUACAMOLE-2343: Add guacclip tool for extracting clipboard contents from session recordings - #724

Open
ciroiriarte wants to merge 2 commits into
apache:mainfrom
ciroiriarte:feature/guacclip
Open

ciroiriarte wants to merge 2 commits into
apache:mainfrom
ciroiriarte:feature/guacclip

Conversation

@ciroiriarte

Copy link
Copy Markdown
Contributor

Adds guacclip, a command-line tool next to guacenc and guaclog that extracts clipboard contents (text and images) from session recordings made with recording-include-clipboard. Neither existing tool surfaces this data today.

guacclip [-f] [-o OUTDIR] [--direction guest-to-client|client-to-guest]
         [--include image|text|all] [--max-item-bytes N] [--dedup none|skip] FILE...

Output is OUTDIR/manifest.json plus one file per item in OUTDIR/items/, recording each item's timestamp, mimetype, size, SHA-256 and direction (where the recording annotates it; otherwise unknown).

  • Purely additive: no changes to the recording format, libguac or guacd. Links only libguac; built by default, --disable-guacclip to opt out.
  • Clipboard streams are reassembled only from stream indices opened by a clipboard instruction, so image/file/pipe blobs are never picked up.
  • Recordings are treated as untrusted input (sanitized filenames, size and item-count caps, O_EXCL|O_NOFOLLOW + atomic rename for output files).
  • CUnit suite under src/guacclip/tests, wired into make check (14 tests).

Split out from the SPICE PR #688 as suggested there, since it is protocol-independent.

…ion recordings.

New `guacclip` CLI (peer to guaclog/guacenc) that recovers clipboard
artifacts - text and images - from a `.guac` session recording, filling the
gap those tools leave (guacenc renders video, guaclog interprets keystrokes,
neither touches clipboard). No recording-format change; purely additive
tooling on top of the existing recording-include-clipboard support.

`guacclip [-f] [-o OUTDIR] [--direction guest-to-client|client-to-guest]
[--include image|text|all] [--max-item-bytes N] FILE...` writes
`OUTDIR/manifest.json` + `OUTDIR/items/` with per-item direction, timing,
mimetype, byte count, and SHA-256.

Design mirrors guaclog (guac_parser/guac_socket loop). Clipboard streams are
reassembled strictly by the stream index opened by a `clipboard` instruction,
so graphical `img`/file/pipe blob streams are never misread as clipboard
data. Direction comes from a recording-only `log stream=N direction=...`
annotation where a protocol emits one, buffered per stream index and
consumed at stream open; recordings without it get direction "unknown". A
self-contained FIPS 180-4 SHA-256 (sha256.c) keeps the tool dependency-free -
it links only libguac.

Hardened against hostile recordings: mimetype is slugged to [A-Za-z0-9_] for
filenames (no path traversal) and \u-escaped in JSON (valid manifest even
with non-ASCII bytes); per-item size is capped (64 MiB default, `0` opts
out) and the manifest item count is bounded to prevent OOM; item files are
written via O_EXCL|O_NOFOLLOW temp + atomic rename; stream indices are parsed
with strtol validation. Gated by --disable-guacclip.
--dedup none|skip (default none): duplicates are detected by SHA-256 of the
reassembled item bytes. Every manifest item gains a duplicate_of field (the
sequence number of the first identical item, or null). In skip mode a
duplicate's file is not written (filename null) and a "duplicate" warning is
added; none mode writes every item. Repeated copies are legitimate audit
events, so none is the default.

tests/: a CUnit suite (test_guacclip, wired into make check) covering SHA-256
FIPS 180-4 vectors and, via the guacclip_interpret() integration path,
multi-blob reassembly, interleaved streams, direction correlation (and the
unknown-direction fallback), the non-clipboard-stream guard, truncation,
oversized capping, bad base64, non-numeric stream index, and both dedup modes.
ciroiriarte added a commit to ciroiriarte/guacamole-server that referenced this pull request Oct 17, 2026
guacclip is protocol-independent and is now proposed separately as
GUACAMOLE-2343 (apache#724).
ciroiriarte added a commit to ciroiriarte/guacamole-manual that referenced this pull request Oct 31, 2026
guacclip is protocol-independent and is now proposed separately as
GUACAMOLE-2343 (apache/guacamole-server#724). Its documentation will be
proposed together with it.
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