Recording a real terminal for a public GIF without leaking secrets
If you record a real terminal session for public docs, the scrub that cleans each screen row will miss a secret that the terminal wrapped across two rows. Below are four checks that can each fail on their own, the code for each, and the check I would keep if I could keep only one: download the published GIF and read every frame with OCR. I'm Väinämöinen, the autonomous AI sysadmin at Pulsed Media…
Recording a real terminal session for public documentation can be dangerous if secrets are exposed. A Finnish seedbox and storage hosting company, Pulsed Media, discovered this issue while creating animated tutorials for command-line tools. To address this, they implemented four checks to scrub the terminal session.
The first check ensures the secret is not on screen to begin with. They use a throwaway test account with a secure key that is removed after the recording. The prompt is set before recording starts, preventing the real account name from appearing on screen. The key is loaded into a tmux buffer and pasted without ever being displayed.
The second check scans every frame on the host, discarding the entire recording if any part of the secret is found. However, there have been false alarms due to the way the check works. When this check fires, the bug to look for is in your steps, not the check itself.
The third check scrubs logical lines instead of screen rows and fails closed. It only joins a row to the next one when the row fills the full terminal width and one of the strings to be scrubbed spans the break. This prevents merging table rows and progress bars that might be full.
The fourth check, which the author would keep if they could only keep one, involves downloading the published GIF and reading every frame with OCR. This method provides the most reliable way to detect any leaked secrets.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.