Zsh is fast, flexible, and powerful. But like any shell, it can expose sensitive information—names, emails, Social Security numbers, credit card data—if configured without care. PII data in Zsh can enter logs, history files, prompts, or output when commands handle unmasked datasets. One careless echo, one unfiltered API response, and private data sticks where it should not.
The most common exposure vector is command history. By default, Zsh writes every executed command to ~/.zsh_history. If those commands contain raw PII data—query strings with IDs, curl requests with tokens—that history becomes a high-value leak target. Limit this risk by adjusting HIST_IGNORE_SPACE and HISTCONTROL, or disabling history writes for sensitive commands with set +o history. Store history files in secure, encrypted locations.
Another risk: prompts and scripts that render live data in the terminal. Dynamic prompts can call scripts or pull from APIs. Without filtering, data like customer details can print directly to the terminal or be stored in scrollback buffers. Use strict variable sanitation. Pipe output through filters that mask matches to regex patterns for email addresses, payment data, or identification numbers before displaying.