News for hackers. Stuff that matters.
Re:Be careful what you copy: Invisibly inserting usernames i... by irrational on Wednesday April 04, 2018 @01:59AM (#16752348)
How difficult would it be to write a browser extension to either remove all zero-width characters or somehow make it super obvious that they are being used on the page?

I just searched for "zero-width" and "zero width" in Chrome and Firefox's extensions stores, but didn't come up with anything.

Re:Be careful what you copy: Invisibly inserting usernames i... by roymckenzie on Wednesday April 04, 2018 @11:02AM (#16755362)
I just made a very basic one: https://chrome.google.com/webstore/detail/icibkhaehdofmcbfjf...

Code here: https://github.com/roymckenzie/detect-zero-width-characters-...

Submit a PR! I know it could be better!

Needed features:

* right-click selected text and "Sanitize and Copy" * toggle off and on ...

Re:Be careful what you copy: Invisibly inserting usernames i... by dbg31415 on Wednesday April 04, 2018 @04:05PM (#16758491)
Re:Be careful what you copy: Invisibly inserting usernames i... by tim333 on Wednesday April 04, 2018 @05:44AM (#16753302)
Probably not too hard. I've made a jsfiddle to identify and remove such stuff. Feel free to copy any of it to an extension. https://jsfiddle.net/tim333/np874wae/13/
Re:Be careful what you copy: Invisibly inserting usernames i... by flanbiscuit on Wednesday April 04, 2018 @11:11AM (#16755472)
I took your code and added to it. Removed jQuery and it now searches through ALL text nodes on a page and replaces the text in it with the hidden characters plus the original visible text. There's still lots of room for improvement but it's a start. For now I'm running it in the console to make it work but someone can build upon this and turn it into an extension (maybe I will if I have time)

I put it in a gist:

https://gist.github.com/FranciscoG/01732b606a35615891103ae8e...

Re:Be careful what you copy: Invisibly inserting usernames i... by jessriedel on Wednesday April 04, 2018 @08:22AM (#16754018)
Would probably be better to do this at the OS level, no? Just ensure that shift-cmd-V/shift-ctrl-V strips zero-width characters in addition to formatting. I can't think of a situation where I'd want to keep one but not the other, and you could always do that manually if it came up.
Re:Be careful what you copy: Invisibly inserting usernames i... by yuubi on Wednesday April 04, 2018 @10:19AM (#16754899)
Arabic? I think the are cases where letters are joined or not by default, but sometimes need to be forced to the other state, depending on meaning that the text layout engine isn't expected to be able to figure out.
Re:Be careful what you copy: Invisibly inserting usernames i... by inetknght on Wednesday April 04, 2018 @09:14AM (#16754338)
If it'd also optionally (default=true) strip text formatting from copy/paste that'd be epic. No more copy-from-browser-then-paste-into-notepad-then-copy-from-notepad-then-paste-into-email-or-chat
Re:Be careful what you copy: Invisibly inserting usernames i... by jessriedel on Wednesday April 04, 2018 @02:06PM (#16757307)
What matthberg said. I'm on a Mac and I use shift-cmd-V frequently (more often than cmd-V).

Unfortunately, there are a few apps that use cmd-opt-shift-V instead of cmd-shift-V. You can fix most of them using this:

https://apple.stackexchange.com/questions/182970/paste-to-ma...

After that, almost everything will use cmd-shift-V. However, Microsoft Word is still broken, apparently because it uses a slightly different command that does a similar thing, "Paste and Match Formatting". Haven't found a way to fix that yet.

Re:Be careful what you copy: Invisibly inserting usernames i... by inetknght on Thursday April 05, 2018 @10:01AM (#16764954)
Linux.
Re:Be careful what you copy: Invisibly inserting usernames i... by matthberg on Wednesday April 04, 2018 @01:10PM (#16756748)
In a good few applications that is exactly what Ctrl+Shift+V does. Try it in Chrome or Firefox, it pastes without formatting.
Re:Be careful what you copy: Invisibly inserting usernames i... by kccqzy on Wednesday April 04, 2018 @09:58AM (#16754715)
Zero width characters have legitimate uses such as family emojis and certain Indic scripts. You don't want to break these.
Re:Be careful what you copy: Invisibly inserting usernames i... by irrational on Wednesday April 04, 2018 @01:58PM (#16757232)
I'd rather be protected from tracking than worry about some emojis breaking or text in script I can't read formatting incorrectly. Of course, this should be an individual decision since some people do read those scripts and some people do care about emojis.
Re:Be careful what you copy: Invisibly inserting usernames i... by vbezhenar on Wednesday April 04, 2018 @02:39AM (#16752521)
I don't think that it's too difficult. Just check every tag's text for forbidden characters and replace them with something. I'm not sure about performance.
Re:Be careful what you copy: Invisibly inserting usernames i... by scottmf on Wednesday April 04, 2018 @09:02AM (#16754269)
Besides performance concerns, if you did it on each page load it would miss any content added to the page after the initial load. It would be useless for SPAs.

The best way I can think to implement it would be listening for a copy event and replacing the text in the clipboard.

Something like:

  document.addEventListener('copy', sanitizeClipboardContent);
Re:Be careful what you copy: Invisibly inserting usernames i... by Too on Saturday April 07, 2018 @02:58AM (#16779713)
No need to replace text. Patch all the fonts in your OS to display something instead of zero width. That will work outside the browser also.

There really is no valid use case in Latin script so why is zwsp allowed next to Latin characters?! (Emojis is not a valid use case, and why do they depend on zwsp anyway?)

Re:Be careful what you copy: Invisibly inserting usernames i... by koheripbal on Wednesday April 04, 2018 @10:51AM (#16755233)
Whenever I paste, I use ctrl-shift-v. It solves this problem and a multitude of other pasting problems.
Re:Be careful what you copy: Invisibly inserting usernames i... by djsumdog on Wednesday April 04, 2018 @11:07AM (#16755424)
That just removes formatting, reducing the copied text to plain-text. If I paste the strings from the blog post into atom and then arrow right from the beginning, there are locations where the col number will increase and the cursor not move.

I don't think ctrl-shift-v will do what you think here because we're not talking about formatting at all. We're talking about regular unicode UTF-8 encoded text.

Re:Be careful what you copy: Invisibly inserting usernames i... by itakedrugs on Wednesday April 04, 2018 @11:15AM (#16755516)
that doesn't work on my computer (Fedora), but what I usually do is paste it in a box that doesn't allow formatting and then copy it again... but I don't know if it would remove fingerprinting in this case