News for hackers. Stuff that matters.
Re:Another flaw in Signal desktop app leaks chats in plaintext by pfg on Thursday May 17, 2018 @06:33PM (#17096700)
As much as I'm not a fan of JavaScript, the problem is not so much the language but rather the choice of Electron and all that comes with it. Heck, even a web version or Chrome app would've successfully mitigated these attacks. Electron means you're one XSS away from remote code execution, and even worse, it makes it way harder to mitigate XSS through CSP (which Signal did utilize, but script-src 'self' can easily be bypassed in Electron).

FWIW, Signal's native mobile apps are written in Java and Objective-C respectively, so there's not really much of a difference compared to Wire (which is a good choice as well). Still, even a hypothetical React Native app written in JavaScript wouldn't be much worse; after all, React Native isn't just a Web View made to look like a native app, but uses actual native components.

Re:Another flaw in Signal desktop app leaks chats in plaintext by rndgermandude on Thursday May 17, 2018 @08:14PM (#17097501)
While I agree that Electon offers a massive amount of footguns, neither Javascript nor Electon was the issue in this case. The issue was using innerHTML (or rather $.html()) with strings concatenated together from user input. Something you should never do. Could as well just call eval() directly on it, or pass the input to gcc, compile it and run the resulting binary.

The Signal devs thought $.html() does some kind of escaping: https://github.com/signalapp/Signal-Desktop/commit/9d41b8616... (this commit made something that was easy to exploit into something that was even easier to exploit).

To be honest, I'd lay more blame on the authors of the DOM spec making innerHTML a setter than on Electron, and jQuery exposing this misfeature even more with $.html(), teaching an army of web developers to do the wrong thing. We've all seen numerous (XSS) vulnerabilities in all kinds of websites, browser extensions, Electron apps, etc resulting from this API, tho in Electron apps it gets particularly devastating as often you'd get code execution not just in a sandboxed website but full code execution under the current user credentials in the system.

Re:Another flaw in Signal desktop app leaks chats in plaintext by grrowl on Thursday May 17, 2018 @11:59PM (#17098585)
> The Signal devs thought $.html() does some kind of escaping: https://github.com/signalapp/Signal-Desktop/commit/9d41b8616.... (this commit made something that was easy to exploit into something that was even easier to exploit).

This is an absolutely egregious rookie error. I wouldn't touch the Signal desktop app with a 10 foot pole after seeing that commit.

Re:Another flaw in Signal desktop app leaks chats in plaintext by cyphar on Friday May 18, 2018 @04:08AM (#17099521)
What's incredible is that the author actually had to modify an XSS test so that it read:

> const expected: string = "Hello<br><script>alert('evil');</script>World!";

(Meaning they actually changed a line that had "<script>alert('evil')</script>" and didn't notice.)

I have seen this before though, with some folks removing path sanitisation code I added several years prior to fix a CVE. So it's not uncommon (it also got merged, so when I found out and fixed it I added a very large and scary comment to stop people from doing it again).

Re:Another flaw in Signal desktop app leaks chats in plaintext by mercer on Saturday May 19, 2018 @10:12AM (#17107964)
Why is this a 404 now?
Re:Another flaw in Signal desktop app leaks chats in plaintext by Stephen304 on Saturday May 19, 2018 @10:49AM (#17108092)
Looks like grrowl copied and repasted the truncated display text of the link. The full link is 2 comments up: https://github.com/signalapp/Signal-Desktop/commit/9d41b8616...
Re:Another flaw in Signal desktop app leaks chats in plaintext by seba_dos1 on Thursday May 17, 2018 @09:02PM (#17097760)
>The Signal devs thought $.html() does some kind of escaping:

Uhm... that's a really rookie mistake to make. Like, one of the very basics of jQuery usage. I'm not exactly sure what to think about it after seeing this commit you linked...

Re:Another flaw in Signal desktop app leaks chats in plaintext by ddtaylor on Thursday May 17, 2018 @11:12PM (#17098395)
The worst part is that someone assumed something then removed the code that did the escaping without even doing the most basic of tests, like even in the browser just doing a quick foo.html('<script>alert("oh snap this is bad")</script>')
Re:Another flaw in Signal desktop app leaks chats in plaintext by Cakez0r on Friday May 18, 2018 @07:59AM (#17100690)
Even worse than that, it looks like there _were_ unit tests to check that input was correctly sanitized, but the patch that introduced the bug also explicitly changed the unit tests to ensure that input was _not_ being escaped!

A mistake that seems like it could've been caught in a code review!

Re:Another flaw in Signal desktop app leaks chats in plaintext by ddtaylor on Friday May 18, 2018 @08:59AM (#17101064)
These are the kinds of things that make tinfoil hats wonder if any agencies interested in subverting encryption "plant" employees. It's difficult to differentiate stupidity from malice. We know they use shell companies and subvert device manufacturers and standards, so it's not unfathomable.
Re:Another flaw in Signal desktop app leaks chats in plaintext by icebraining on Friday May 18, 2018 @02:29AM (#17099149)
Maybe he did and it didn't work for some reason and he thought it was good. Shit happens. I think the most worrying part is not having been caught in code review. Signal does code review, right?
Re:Another flaw in Signal desktop app leaks chats in plaintext by twr on Thursday May 17, 2018 @09:33PM (#17097956)
I don't know if this is correct, but, I once got the impression that Signal Desktop was under the sole purview of a new hire at OWS. In other words, Moxie doesn't review the commits. I hope I'm wrong, but even if I'm not, I suppose it makes no difference, as he's arguably responsible either way.
Re:Another flaw in Signal desktop app leaks chats in plaintext by debacle on Thursday May 17, 2018 @10:12PM (#17098127)
Isn't this supposed to be an app for secure communication? Theo would have a conniption.
Re:Another flaw in Signal desktop app leaks chats in plaintext by fjsolwmv on Friday May 18, 2018 @12:21AM (#17098669)
Has Theo de Raadt ever endorsed the security of anything except the default install of OpenBSD?
Re:Another flaw in Signal desktop app leaks chats in plaintext by pfg on Thursday May 17, 2018 @08:36PM (#17097638)
So to be clear, a lot of the blame definitely belongs in the "all that comes with it" bucket here, which is one of the reasons why you should think twice about developing desktop apps using a platform that forces you to deal with not only the usual desktop app security concerns, but also all the things that make web apps vulnerable.

Still, when you ship an app with a relatively strict Content Security Policy as Signal did (including using script-src 'self'), you don't really expect a simple XSS vulnerability to lead to RCE, but it turns out that policy doesn't really do much in an Electron app.

Re:Another flaw in Signal desktop app leaks chats in plaintext by thaumasiotes on Thursday May 17, 2018 @09:35PM (#17097967)
> The issue was using innerHTML (or rather $.html()) with strings concatenated together from user input.

> The Signal devs thought $.html() does some kind of escaping

I mean, it does do a kind of escaping. If you assign javascript to innerHTML directly, it won't execute. jQuery specifically checks whether you're adding a script tag, and if so, it takes the extra step to execute it for you.

Re:Another flaw in Signal desktop app leaks chats in plaintext by derefr on Friday May 18, 2018 @12:27AM (#17098687)
You mean, the innerHTML of a <script> element. Which isn’t really a thing, because the inside of a <script> tag is a document boundary—assigning raw Javascript to innerText or innerHTML directly would make no sense in either case. You need to wrap your Javascript in a CDATA node ;)
Re:Another flaw in Signal desktop app leaks chats in plaintext by thaumasiotes on Friday May 18, 2018 @04:24AM (#17099603)
No, analogously to adding a script tag with jQuery, I meant adding a script tag, with javascript inside, to the innerHTML of some other element.
Re:Another flaw in Signal desktop app leaks chats in plaintext by caf on Thursday May 17, 2018 @08:47PM (#17097687)
Surely the collective noun for footguns is a cache :)
Re:Another flaw in Signal desktop app leaks chats in plaintext by charleslmunger on Friday May 18, 2018 @08:40PM (#17105996)
> The issue was using innerHTML (or rather $.html()) with strings concatenated together from user input. Something you should never do. Could as well just call eval() directly on it, or pass the input to gcc, compile it and run the resulting binary.

Yes, but most engineers would look at that last element and say "what on earth is going on here", where $.html() being dangerous is something that engineers who don't usually work on web might not know about. You're right about blaming the DOM spec, but there's no actual reason for signal desktop to interact with that poorly designed spec except that they chose electron as a framework.

Re:Another flaw in Signal desktop app leaks chats in plaintext by komuW on Friday May 18, 2018 @07:58AM (#17100685)
Is there a linter that can catch this kind of mistakes?
Re:Another flaw in Signal desktop app leaks chats in plaintext by Rjevski on Friday May 18, 2018 @03:53AM (#17099460)
I disagree; the issue is Electron.

Sure, you can write secure apps in Electron, just like you can do risky stuff in real-life and be fine most of the time. But why take the risk?

Had the app been written with a native language and SDK, they wouldn’t need to worry about escaping or anything. I have yet to hear about getting remote code execution for dumping text into an UILabel or similar, while XSS happens almost every day.

Re:Another flaw in Signal desktop app leaks chats in plaintext by mintplant on Thursday May 17, 2018 @07:01PM (#17096918)
Signal Desktop actually used to be a Chrome app. Then Google announced the deprecation of that feature and they ported it over to Electron.
Re:Another flaw in Signal desktop app leaks chats in plaintext by ehPReth on Thursday May 17, 2018 @08:30PM (#17097600)
Sad day for Chrome OS users. No more Signal updates! :(
Re:Another flaw in Signal desktop app leaks chats in plaintext by burtonator on Friday May 18, 2018 @01:40AM (#17098982)
One thing I'd like to see is more use of containers and permissions locally.

For example, my IntelliJ runs as my user account, but it doesn't need access to all my files.

I should be able to select which directories it has access to and it's within a container by default.

I mean I can set this stuff up manually, but in the future I'd like to see this as the default.

Similar to the way Android apps ask for permissions.

Re:Another flaw in Signal desktop app leaks chats in plaintext by kilburn on Friday May 18, 2018 @02:31AM (#17099156)
It seems you are calling for Qubes OS [1], which does that but using VMs (which should be more secure than containers).

It will take a looong time for "standard" OSes to get there, if they ever do. The required changes in UX are very significant...

[1] https://www.qubes-os.org/

Re:Another flaw in Signal desktop app leaks chats in plaintext by pjmlp on Friday May 18, 2018 @02:37AM (#17099173)
That is the whole idea of the UWP model on Windows, and the ongoing work to put Win32 apps inside of the same containers.

Or the sandbox models on Android, iOS and macOS.

Re:Another flaw in Signal desktop app leaks chats in plaintext by danieldk on Friday May 18, 2018 @03:44AM (#17099419)
And Flatpak on Linux. IIRC the Signal Flatpak is sandboxed.
Re:Another flaw in Signal desktop app leaks chats in plaintext by ams6110 on Thursday May 17, 2018 @07:39PM (#17097216)
> Electron means you're one XSS away from remote code execution

So, electron is the new flash. I'll be avoiding that, then.

Re:Another flaw in Signal desktop app leaks chats in plaintext by AgentME on Friday May 18, 2018 @12:11AM (#17098631)
>Electron means you're one XSS away from remote code execution, and even worse, it makes it way harder to mitigate XSS through CSP (which Signal did utilize, but script-src 'self' can easily be bypassed in Electron).

Can you explain that last part? I can't think of how an XSS attack could get around that, and Electron's documentation specifically recommends it: https://github.com/electron/electron/blob/master/docs/tutori...

Re:Another flaw in Signal desktop app leaks chats in plaintext by pfg on Friday May 18, 2018 @12:35AM (#17098723)
There's a bit of an explanation of this in the article describing the other XSS that's recently been found in Signal[1]. Basically, since the Electron app itself runs under the file:// origin, 'self' can be bypassed with varying degrees of difficulty depending on the platform. On Windows, it's trivial because you can use UNC paths to a SMB share containing a malicious JavaScript file (i.e. file://1.2.3.4/payload.js). On other platforms, you'd need to find a way to place the file on a path accessible via file:// first, for example by sending the file via Signal itself and hoping the user accepts the download.

There are ways to lock down the CSP further to mitigate this, but no one really expects script-src 'self' to be unsafe, especially when it's what their documentation recommends.

[1]: https://ivan.barreraoro.com.ar/signal-desktop-html-tag-injec...