logoalt Hacker News

phyzome • yesterday at 4:51 PM • 2 replies • view on HN

I actually have a terminal program that needs to ask for sensitive inputs from the user sometimes, potentially after attacker data has been printed. I've been trying to figure out how I should handle that!

My plan was to encode to Unicode (lossily), strip out control characters, and add some visual framing. Anything else I should be considering? Is there a standard approach? Haven't actually done the research on this yet, but since it came up here, I figure someone might know.

(This is https://codeberg.org/timmc/breakmancer if anyone is interested.)


Replies

kccqzy • yesterday at 7:07 PM

Stripping out just the control characters isn’t enough. A lot of terminal control sequences start with a single control character followed by normal printable characters but such printable characters are part of the control sequence. And even when you strip out entire terminal control sequences there are still other Unicode characters that will play tricks. Examples include the Unicode right-to-left override, which is not an ASCII control character but a Unicode control character. There are also dozens of space characters that look like spaces but won’t be split by ASCII word splitting processing, etc.

➕ show 1 reply
dingaling911 • yesterday at 5:15 PM

I don't understand the UX you have in mind, just do it like SSH used to do, a non-echo input field?