Terminal Escape-Sequence Injection in pickem npm Package
The pickem npm package fails to sanitize item text labels, allowing attackers to perform terminal injection via OSC 52 clipboard writes or UI spoofing.
The npm package pickem contains a vulnerability (fixed in version 1.0.7) where item text, including labels, descriptions, and meta fields, is rendered to the terminal without adequate sanitization of escape sequences. Because this library is frequently used in CLI tools to display potentially untrusted input - such as git branch names, pull request titles, or API query results - it is susceptible to terminal injection. Attackers can leverage this by crafting malicious strings containing ANSI or C0 escape sequences. These sequences can be used to perform unauthorized OSC 52 clipboard writes, effectively staging malicious commands in the user's clipboard for later execution, or by spoofing the terminal UI to deceive users into believing they are interacting with legitimate or trusted system prompts. The vulnerability arises because previous sanitization logic only targeted active rows and failed to account for bare C0 control characters, leaving the system open to various manipulation techniques across multiple prompt types.
Impact
The vulnerability allows for remote execution (via clipboard-to-shell injection), interface manipulation, and denial-of-service via terminal flooding. Any CLI tool incorporating pickem to display untrusted external data is at risk. If successful, an attacker can modify the user's local clipboard content, overwrite displayed UI text to hide malicious entries, or forge trust markers, which may lead to system compromise when a user inadvertently executes injected commands.
Recommendation
- Update the
pickempackage to version 1.0.7 or later immediately to incorporate thesanitizeDisplay()function. - For applications using
pickemwhere upgrading is not possible, implement custom sanitization to strip all C0/C1/DEL control characters and ANSI escape sequences from any untrusted strings before passing them to the library. - Review CLI tools that pipe untrusted metadata (like git refs or API response fields) into interactive terminal displays to ensure they implement input sanitization.
Immediate actions
Audit package.json files for pickem dependencies and force update to 1.0.7
Mitigations
Upgrade pickem to version 1.0.7
pickem < 1.0.7