Merged 3 Oct 2026  Fix moved into the shared Pimalaya crate

Himalaya: terminal escape injection and BiDi spoofing defense in Rust email tables

BudgetScan flagged that Himalaya, a popular CLI email client written in Rust, printed unescaped message metadata — subjects, sender names, attachment filenames, and IDs — directly into terminal tables. An external email sender could inject ANSI escape sequences (such as OSC 52 clipboard hijacking, screen clearing, and line overwrites) or Unicode BiDi overrides to disguise executable attachment extensions. Project maintainer Clément Douin (soywod) affirmed the problem and extracted our proposed sanitization into the central pimalaya-cli library, credited Martin Vlach as co-author, and made it available to the sister CLI tools cardamum and calendula, which share the same tables.

What was wrong

When an email user lists envelopes (himalaya envelope list) or inspects attachments, Himalaya formats the message metadata into clean CLI tables. Because this metadata comes directly from external untrusted sources — anyone who sends an email can set arbitrary Subject headers, sender display names, and attachment filenames — printing it raw to a terminal emulator creates severe security risks:

Himalaya table rendering flow Incoming email metadata passes through table rendering. Before the fix, raw control characters were printed to the terminal. Now, pimalaya_cli::table::sanitize replaces control characters (which defuses escape sequences) and BiDi overrides with U+FFFD. Untrusted email metadataSubject, Sender, Filename, Mailbox Single-line table formatterIMAP, JMAP, Gmail, Graph, pimdir pimalaya_cli::table::sanitizeC0/C1, DEL and BiDi → U+FFFD Safe terminal table outputclean text without injection hazard User terminal emulatorclipboard & display protected before: raw terminal escape
Table rendering pipeline. Before the fix, raw string data went directly to standard output (red dashed line). Now, single-line fields are sanitized by the shared Pimalaya library.
Illustration: Himalaya terminal table output with exploit scenario and sanitized fix, pimalaya-cli 0.2.6 shared crate, and maintainer Clément Douin's review.
Terminal injection demonstration and shared fix. Demonstrating OSC 52 and BiDi override spoofing, the centralized sanitization in pimalaya-cli 0.2.6, and maintainer Clément Douin's review.

How it was fixed

We submitted pull request #771 proposing a sanitization routine and automated test coverage. Project maintainer Clément Douin (soywod) recognized that sister applications across the Pimalaya suite (cardamum for contacts and calendula for calendar) share the same table rendering logic:

“Thanks for the report and the clear write-up, the problem is real. Since cardamum and calendula share the same tables, I moved the function into pimalaya-cli and credited you as co-author. It's released in 0.2.6 as pimalaya_cli::table::sanitize. It's your printable(), with one addition: it also replaces bidi controls (U+202A–202E, U+2066–2069). Without that, a filename like invoice\u{202e}fdp.exe displays as invoiceexe.pdf.”

Following the maintainer's guidance, we completed the PR implementation:

Maintainer Clément Douin verified the changes and merged the pull request into master on 3 October 2026:

“Thanks, all good. The Windows-1252 side effect is fine for now; we'll revisit if it turns out to bite. Merging.”

Related later work in Himalaya

After our fix, contributor SORALNV sent two more hardening patches to Himalaya. They are separate work and do not refer to PR #771, but they cover neighbouring ground. Clément Douin merged both:

Timeline

How to read this

Automated scanning found an unescaped control sequence flaw in CLI tables, and thoughtful maintainer collaboration turned a single-repo bug fix into a shared function for the broader Pimalaya suite. This is open-source security at its best: automated detection generating clear leads, followed by thoughtful human review, robust test cases, and collaborative architectural hardening. Special thanks to Clément Douin for outstanding open-source leadership and swift action.

Sources

← Back to Success Stories