News for hackers. Stuff that matters.
Re:Another flaw in Signal desktop app leaks chats in plaintext by tormeh on Thursday May 17, 2018 @06:17PM (#17096554)
Maybe secure chat clients shouldn't be written in JavaScript or other languages that have excessive dynamicness? Signal seems to be written mostly in languages that are bad for security (significantly worse than the best alternatives). Maybe I'm just a language nerd without any clue about the trade-offs, but I trust the Wire software more. Note that this just applies to mobile clients and server - Wire, like Signal, chose to build their desktop+webapp in JavaScript :(
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...

Re:Another flaw in Signal desktop app leaks chats in plaintext by symlinkk on Thursday May 17, 2018 @06:30PM (#17096681)
None of this is caused because of them using a dynamic language. It's caused because the developers used a function literally called "dangerouslySetInnerHTML" that doesn't escape HTML. That's it. It's just lazy programming.
Re:Another flaw in Signal desktop app leaks chats in plaintext by vjeux on Thursday May 17, 2018 @10:33PM (#17098226)
We called it that way in React in order to call out attention to the fact that it was actually dangerous. React also properly escapes everything else it prints.

The app isn't using React but jQuery, which doesn't have those protections.

Re:Another flaw in Signal desktop app leaks chats in plaintext by archgoon on Thursday May 17, 2018 @11:21PM (#17098432)
This doesn't seem to be true, here's the v1.10.0 code:

https://github.com/signalapp/Signal-Desktop/blob/f6eb745632c...

They do seem to be using react, and using dangerouslySetInnerHTML. Now that said, I haven't confirmed that this is the code that caused the issue, but it is in the Quotes component, which is referenced in the article.

They seem to have fixed this specific issue a few days ago (v.11.0):

https://github.com/signalapp/Signal-Desktop/blob/0d00fbfb7a2...

They do seem to be using jQuery elsewhere in the code base, but I'm not familiar enough to determine how it all fits together.

Re:Another flaw in Signal desktop app leaks chats in plaintext by vjeux on Friday May 18, 2018 @12:43AM (#17098761)
Oh sorry you are right! I was reading the comment ( https://news.ycombinator.com/item?id=17097501 ) which said that the issue was caused with $.html
Re:Another flaw in Signal desktop app leaks chats in plaintext by ddtaylor on Thursday May 17, 2018 @11:28PM (#17098461)
They are using many frameworks mixed together like jQuery, React, and underscore.
Re:Another flaw in Signal desktop app leaks chats in plaintext by mtgx on Friday May 18, 2018 @12:14AM (#17098646)
I may be wrong, but I think the Signal desktop app was written by like interns or new developers working for Signal.

The Android app was written by Moxie, and I think it's the one about which Matthew Green said:

After reading the code, I literally discovered a line of drool running down my face. It’s really nice.

https://signal.org/

Re:Another flaw in Signal desktop app leaks chats in plaintext by fjsolwmv on Friday May 18, 2018 @12:35AM (#17098726)
I hope Moxie learned that programming his people/team is as programming his software. This tarnishes Signal, regardless of how good the Android app is.
Re:Another flaw in Signal desktop app leaks chats in plaintext by kbwt on Friday May 18, 2018 @07:14AM (#17100458)
The native code (RedPhone remnants?) did not inspire confidence last I looked at it.
Re:Another flaw in Signal desktop app leaks chats in plaintext by lnrdgmz on Friday May 18, 2018 @12:02AM (#17098598)
Naive question: Are there functions analogous to `dangerouslySetInnerHTML` in non-JS GUI libraries (e.g. Qt) that will allow a similar attack?
Re:Another flaw in Signal desktop app leaks chats in plaintext by jrockway on Friday May 18, 2018 @07:23AM (#17100504)
I mean, in C++ "=" could be called "dangerouslySetAribtraryMemoryLocation" and it would be just as accurate. In native code, even trivial operations like concatenating two strings or setting a variable can cause arbitrary code to execute.
Re:Another flaw in Signal desktop app leaks chats in plaintext by jhasse on Friday May 18, 2018 @08:41AM (#17100939)
Care to give an example?
Re:Another flaw in Signal desktop app leaks chats in plaintext by moefh on Friday May 18, 2018 @01:22PM (#17103198)
Assuming OP was talking about overloading the '=' operator:

  struct A {
    int *p = nullptr;
  
    A& operator=(int i) {
      *p = i;
      return *this;
    }
  };

  int main(void)
  {
    A a;
    a = 1;  /* boom! */
    return 0;
  }
Re:Another flaw in Signal desktop app leaks chats in plaintext by camgunz on Friday May 18, 2018 @01:21PM (#17103191)
strcat (or, honestly, anything in string.h). strcat assumes its first argument has enough allocated space for the contents of the 2nd argument, and that the 2nd argument is NULL terminated. If either of those assumptions is wrong, strcat will overwrite memory, corrupting either your heap or your stack, both of which can lead to arbitrary code execution. It's laughably easy to do, so easy that even typing the letters `strcat` into your program is forbidden in basically every C/C++ shop.
Re:Another flaw in Signal desktop app leaks chats in plaintext by jhasse on Saturday May 19, 2018 @01:37PM (#17108841)
strcat is C and not C++ though.
Re:Another flaw in Signal desktop app leaks chats in plaintext by camgunz on Sunday May 20, 2018 @11:13AM (#17113062)
Nah it's both. C++ was deliberately designed to be a superset of C. It's diverged a little bit, but it's mostly still the case. Or, call it `std::strcat` if you like.
Re:Another flaw in Signal desktop app leaks chats in plaintext by bigiain on Thursday May 17, 2018 @09:56PM (#17098050)
Maybe, and I know this sounds crazy, secure chat clients shouldn't execute user/potential-attacker supplied code at all???
Re:Another flaw in Signal desktop app leaks chats in plaintext by jrochkind1 on Thursday May 17, 2018 @10:06PM (#17098103)
Of course they shouldn't, that is the bug, I think? The authors thought they were displaying user-supplied HTML, not executing user-supplied code.

You can say secure chat clients should not display HTML messages, but that's a pretty different thing.

Re:Another flaw in Signal desktop app leaks chats in plaintext by fjsolwmv on Friday May 18, 2018 @12:25AM (#17098681)
Yes the only problem is that the text markup language happens to include by default a Turing complete network-enabled live-interpreted programming language because 25 years ago someone wanted to write a funny message in the Netscape status bar.
Re:Another flaw in Signal desktop app leaks chats in plaintext by connorelsea on Thursday May 17, 2018 @06:31PM (#17096685)
there is plenty of secure software written in javascript. poor engineering can occur in any language
Re:Another flaw in Signal desktop app leaks chats in plaintext by 0x0 on Thursday May 17, 2018 @07:52PM (#17097320)
If a presentation layer API (=HTML) provides developers with the convenience of composing UI elements by concatenating markup with remotely sourced input, and at the same time allows inline scripts to be eval'ed when merely present in particular markup attributes, and additionally sometimes hooks up un-sandboxed native APIs with full access to $HOME, it has really laid down the groundwork for a client-side can of worms that makes sql injection and php evals a run for its money.

With the prevalence of XSS and CSRF vulns on the regular sandboxed web, it's pretty brave to take that model into unsandboxed fat clients..?!

Re:Another flaw in Signal desktop app leaks chats in plaintext by archgoon on Thursday May 17, 2018 @10:48PM (#17098293)
It'd probably be useful to distinguish between runtime environments that Javascript is typically encountered (Browsers + Electron) as opposed to the language itself. If it were a language issue, a developer might believe that they could simply switch to a different language, say rust, and compile to WebAssembly and be safe.

However, as you point out, the issue lies in the presentation layer unexpectedly executing code (or receiving inputs from unexpected and untrusted sources). This issue wouldn't be solved by switching to a different language. The core issue here isn't Javascript per se, but the dangerous runtime environments that are browsers and browser approximations (electron) that are designed to execute code from 3rd parties.

Re:Another flaw in Signal desktop app leaks chats in plaintext by mercurial on Friday May 18, 2018 @12:09AM (#17098622)
A database provides developers with the convenience of composing queries by concatenating strings. You still need to be really incompetent to do so in 2018.
Re:Another flaw in Signal desktop app leaks chats in plaintext by 4ad on Thursday May 17, 2018 @06:46PM (#17096805)
Can you provide some examples?
Re:Another flaw in Signal desktop app leaks chats in plaintext by connorelsea on Thursday May 17, 2018 @06:50PM (#17096839)
Implying in any way that all JS programs are insecure and all other languages are secure is ridiculous and probably harmful, leading people to insecure choices in other languages. I've seen plenty of security vulnerabilities in strongly typed languages in my days as a software dev
Re:Another flaw in Signal desktop app leaks chats in plaintext by kenforthewin on Thursday May 17, 2018 @06:49PM (#17096829)
openpgp.js, professionally audited several times over https://openpgpjs.org/
Re:Another flaw in Signal desktop app leaks chats in plaintext by na85 on Thursday May 17, 2018 @09:47PM (#17098009)
Audited by whom? Where are their findings?
Re:Another flaw in Signal desktop app leaks chats in plaintext by connorelsea on Thursday May 17, 2018 @09:59PM (#17098070)
Googled it for you. From their github repo... "To date the OpenPGP.js code base has undergone two complete security audits from Cure53. The first audit's report has been published here." https://github.com/openpgpjs/openpgpjs
Re:Another flaw in Signal desktop app leaks chats in plaintext by colejohnson66 on Thursday May 17, 2018 @07:05PM (#17096956)
OpenSSL? Remember Heartbleed?
Re:Another flaw in Signal desktop app leaks chats in plaintext by 08-15 on Thursday May 17, 2018 @07:23PM (#17097083)
I believe parent was asking for secure software written in JS. I'm curious, too. (And examples of insecure software written in C suprise no one, do they?)
Re:Another flaw in Signal desktop app leaks chats in plaintext by saagarjha on Thursday May 17, 2018 @08:01PM (#17097390)
JavaScript may have many problems, but I don't really think security is one of them. In a properly isolated sandbox, such as a web browser, it's much more difficult to gain arbitrary code execution privileges than a native desktop app.
Re:Another flaw in Signal desktop app leaks chats in plaintext by fjsolwmv on Friday May 18, 2018 @12:27AM (#17098685)
Then JavaScript is a huge problem, only made safe when wrapped in a professionally built and battle tested bubble.

OpenBSD is a famously secure unix(alike) distro. That doesn't mean that every piece of software in OpenBSD is safe to use in any other context.

Re:Another flaw in Signal desktop app leaks chats in plaintext by dcow on Friday May 18, 2018 @05:16AM (#17099886)
So all code is a huge problem? Makes sense to me.