News for hackers. Stuff that matters.
Re:Tales of SugarCRM Security Horrors by orf on Monday April 24, 2017 @04:33AM (#14182743)
The SugarCRM administration panel has a button labeled "remove XSS". We have a picture of it up in our office.

Yes. A button that attempts to remove XSS payloads from the database that admins can click. That's the level of security competence we are talking about here.

Edit: Here is the button: http://i.imgur.com/hC9KmWh.png

Re:Tales of SugarCRM Security Horrors by blowski on Monday April 24, 2017 @04:56AM (#14182827)
Re:Tales of SugarCRM Security Horrors by ReligiousFlames on Monday April 24, 2017 @08:51AM (#14183869)
SugarCRM is an example of projects that give PHP a bad rep.

Maybe programming languages should have a minimum engineering and architectural design competence test such that required knowledge is assured before releasing craptacular poo upon the world.

(If you're write a SugarCRM sploit, obviously patch the Remove XSS to skip yourself.)

Re:Tales of SugarCRM Security Horrors by arethuza on Monday April 24, 2017 @07:23AM (#14183373)
I remember working with another CRM product that had a setting in its configuration file called "secure" that was set to false by default!

Basically this controlled whether authentication was always applied or not - by default it was kind of optional.

Re:Tales of SugarCRM Security Horrors by JumpCrisscross on Monday April 24, 2017 @05:15AM (#14182891)
I'm a numpty. Can you explain why this is bad?
Re:Tales of SugarCRM Security Horrors by lucideer on Monday April 24, 2017 @05:19AM (#14182902)
(a) It's clearly such a persistent problem that they explicitly added such a button.

(b) If* the button really performs as advertised, why on earth should it be a manual step? Do it automatically.

(c) Best practice here is to escape-on-output, negating the need to remove in-DB XSS, so the fact that this button exists strongly implies they aren't doing that

* I would guess that the button is very unlikely to perform comprehensively as advertised

Re:Tales of SugarCRM Security Horrors by drzaiusapelord on Monday April 24, 2017 @12:10PM (#14185435)
From their website:

>Select a module to remove potential XSS strings

My reading of this is SugarCRM, which ships barebones like Drupal, has a whole ecosystem of poorly coded third-party modules you need even for basic CRM functionality. The core Sugar devs wrote this little script to run through module code and its db entries to find potential XSS issues. I imagine that this would break things so its a 'admin beware' type of thing they shouldn't automate. No one wants to upgrade to Sugar 5.2 from 5.1 to find half their modules broken, so its manual. Maybe in the future it won't be and its a shot across the bow to third-party developers to take security seriously.

That's the problem with these popular bare-bones FOSS frameworks. You get a decent core product like Drupal or even Wordpress, but you need a dozen or so modules to make it do anything useful. The code quality on random modules, is of course, random as well, so the core devs try to work around it. Its ugly, but more an indictment against module authors than the core SugarCRM team. That team is just trying to fix the shit-code in the modules and protect the reputation of their product. They don't want to find themselves in the situation Microsoft often found itself in, where Flash and Java exploits were blamed on Windows as non-tech savvy people saw their Windows hacked and didn't know it was a third-party program responsible for it.

This is also why we don't often implement systems like these at work. While I may have trust in the Drupal or Sugar team, I'm ultimately left to be forced to trust sole module authors like 'webdev420hacker' and 'boutiquewebsites1997' because they're the only game in town for these modules. I think bare-bone frameworks are falling out of style a bit. Go with a manged cloud product or go with a more featureful product that isn't dependent on 3rd party modules so much, or go with a commercial solution with everything instead. There's too much variability with third-party modules and not remotely enough security conscious eyes on this code.

Re:Tales of SugarCRM Security Horrors by wyldfire on Monday April 24, 2017 @10:21AM (#14184516)
I think we could address all of your issues if only we could design it such that something clicked the button as often as possible.

cron, maybe?

Re:Tales of SugarCRM Security Horrors by redler on Monday April 24, 2017 @05:14PM (#14188354)
Perhaps SugarCRM should create a new "Secure Enterprise Edition" of the product. The fees would be substantially higher, of course, with the proceeds used to hire overseas IT shops whose 24/7 staff would remained logged in, clicking the button repeatedly. To mitigate the privacy concerns, SugarCRM could create a special version of that administrative page with nothing except the "Remove XSS" button.
Re:Tales of SugarCRM Security Horrors by pgeorgi on Monday April 24, 2017 @02:03PM (#14186486)
or process any data in that way while it is added or read. that avoids scanning the whole table, too.
Re:Tales of SugarCRM Security Horrors by geekamongus on Monday April 24, 2017 @08:09AM (#14183569)
Is the best practice in (c) not just escaping output, but also filtering input?
Re:Tales of SugarCRM Security Horrors by lucideer on Monday April 24, 2017 @08:31AM (#14183720)
Nope.

Input validation is good practice (checking that the input is what's expected), but input filtering is problematic for two reasons:

1. Since input filtering lacks context, the usual option is to filter very broadly (e.g. to attempt to filter for SQL injection and various forms of XSS simultaneously). This leads to much more complicated filtering strategies, adding maintenance overhead, risking data corruption, and generally increasing technical debt.

2. Data loss. This is less of an immediate security issue, but full data retention can be useful for debugging, for future migrations or data transformations, &c. It also ensures you don't get data corruption (e.g. where filtering for one context breaks your data in a different context).

Re:Tales of SugarCRM Security Horrors by jerf on Monday April 24, 2017 @10:38AM (#14184626)
There's another less appreciated one, I think, which is that input filtering often has the problem that the "sensitive" values that you might be trying to filter out are also very often perfectly valid values as well.

For instance, the apostrophe character is a very potent character in a number of injection scenarios and one you might be tempted to "filter", but it is also a perfectly legal character in things as common as "names". It is merely one example of a very large and constantly growing set.

You can't help but correctly encode things on the way out if you want things to work properly.

There is also the question of "filtering" vs. "rejecting". I personally recommend that one way or another anything with the first 32 ASCII characters that you don't expect not end up in your database, because they are full of magical behaviors in all kinds of places, but I also tend to recommend outright rejection on the grounds that these things don't innocently come in. Nobody accidentally types the Negative ACK character into their name. But at the very least, filter it out early. You can also outright "filter" on Unicode character classes you don't expect. But this really ought to be seen more as mere day-to-day business "data validation" than a security measure because of the aforementioned fact that some of the Characters of Interest are still valid, and you can't afford to just filter them all out.

(You basically end up with "English letters and numbers". If you're trying to "filter" away all the "bad" characters in advance, without really knowing where they're going, you can't even have things like "space" (very active shell character), and UTF8 can actually be dangerous if stuff isn't expecting it, etc. And when push really comes to shove, even strings of nothing but English letters and numbers can become dangerous if they are too long, in certain pathological contexts, i.e., "seriously, don't write network software in C". Because the safety of a string is not an intrinsic property of a string but has everything to do with interpretation by further bits of code, there isn't a way to generically "cleanse" a string.)

Re:Tales of SugarCRM Security Horrors by drspacemonkey on Monday April 24, 2017 @03:31PM (#14187316)
I've also come across scenarios where allowing the user to enter valid HTML was a requirement. Especially in cases where users will be entering HTML that renders as part of a site, it was much easier to treat all user input as potentially unsafe and escape output in all cases, with the exception of the one or two places where user-created HTML was supposed to be rendered and/or sent to an external API.
Re:Tales of SugarCRM Security Horrors by nradov on Monday April 24, 2017 @04:34PM (#14188039)
I run into web applications all the time where lazy and incompetent developers have blocked or filtered out the '<' and '>' characters in a naive attempt to prevent content injection attacks.
Re:Tales of SugarCRM Security Horrors by gregmac on Monday April 24, 2017 @02:37PM (#14186794)
And another: Fixes/Changes.

If you rely on input filtering but you miss something, there's a bug and filtering doesn't work, or there's a new type of text that needs to be filtered (eg: a new tag added that didn't exist at the time), you have no recourse -- that text is already in the database.

A software update can fix/change the output filtering, and since that runs at display time (when the vulnerability is actually activated), it can address it.

Re:Tales of SugarCRM Security Horrors by zeta0134 on Monday April 24, 2017 @03:27PM (#14187279)
I think context sensitive filtering is the logical choice at all stages of the operation. Input coming in from a web form should pass through two filters. One context sensitive filter for the form data (Were the required fields filled out, and ideally do they look like the expected data in those fields?) and then again when inserting to the SQL database, to protect against SQL injection.

Then, when the data itself is read, it should pass through context-sensitive output filters, one for the template engine, once again if it's going to be embedded in html, or javascript, or a stylesheet, or into a URL. Output filtering needs to happen, but it critically should not be attempted at the time of input, as the developer of the form should not be expected to predict any possible usage for that data once gathered.

The broad-strokes filtering you describe in step 1 is an anti-pattern through and through. :) I'd avoid personally any codebase or framework attempting this strategy, as I've seen it fail too many times.

Re:Tales of SugarCRM Security Horrors by Khoth on Monday April 24, 2017 @10:18AM (#14184485)
If hackernews filtered input, I wouldn't be able to say that the <script> tag can be used in XSS attacks.
Re:Tales of SugarCRM Security Horrors by code_duck on Monday April 24, 2017 @05:19AM (#14182901)
Can you think of a case where it would be helpful to store XSS in the database until removed by clicking this button?

What happens if we view the admin panel and trigger one of these malicious scripts, because I haven't clicked this button recently enough? Oh, maybe someone should click it very frequently!

Or... Hmm, maybe rather than storing data that may be mass deleted by a script, with no review, after possibly compromising our security, we should just reject it in the first place and log a security incident for that user.

Re:Tales of SugarCRM Security Horrors by dfox on Monday April 24, 2017 @09:24AM (#14184070)
In many cases XSS and similar vulnerabilities (SQLi and even some buffer overflows) are also and primarily functional problem as some classes of valid input cause some kind of breakage. Correctly escaping on output solves both the security and functional problem, filtering on input usually aggravates the functional issue even more.

On the other hand in context of CRMs, helpdesks and other things that have to process received emails and then show them in web interface this gets hairy because escaping on output while correctly handling variously weird or outright broken input is non-trivial. For example every helpdesk solution I've seen gets confused by some combination of nested MIME (ie. email with attachments forwarded with additional attachments) and notionally non-text email bodies (ie. bounces from Postfix).

[Edit: and in this case storing whatever was on input without any transformations and sanitisations enables you to recover the content WHEN (not if) the breakage occurs, by either manually examining the input or, in the email case, importing it into desktop MUA. I even had once to do this with message that was unreadable in otherwise surprisingly well-behaving gmail's web interface]

Re:Tales of SugarCRM Security Horrors by mgkimsal on Monday April 24, 2017 @07:21AM (#14183365)
my view would be 'escape on output' is always better, regardless. there may be reasons I'd want to keep it in there - for analysis, to prove someone was trying to be malicious, or perhaps to demonstrate there's actually a real problem getting past some input mechanisms.

However, the 'defender' in me can think of a situation where this would be good:

Input filtering mechanisms have improved to deal with new attacks/problems, but old data is not 'new input', so you'd apply the updated algorithms to existing data.

Re:Tales of SugarCRM Security Horrors by code_duck on Thursday April 27, 2017 @04:43PM (#14214520)
I guess my thinking is that should be part of the upgrade or update process - whenever antiXSS rules are changed, they are applied at that time. It's having this button there as if it's something you'd run for periodic maintenance that seems insane.

I'd definitely save input that breaks the rules when received, too - but maybe in a separate table.

Re:Tales of SugarCRM Security Horrors by koolba on Monday April 24, 2017 @07:46AM (#14183443)
XSS is a malicious version of the more general problem of not escaping user inputs. its much easier to escape on output rather than input as you can't really tell what's "acceptable". It's also more robust as out of band updates (say direct database updates of comments) get outputted correctly too.

If I have a comment forum with input filtering (rather than output escapong) I can't restrict it to just letters numbers and punctuation or the user's can't discuss HTML tags!

Re:Tales of SugarCRM Security Horrors by code_duck on Monday April 24, 2017 @11:51AM (#14185269)
That makes sense. The objection I feel here is the inconsistency - why accept the input in the first place, only to delete it with this button? An above comment suggests rules may be updated over time, which could explain their thinking.
Re:Tales of SugarCRM Security Horrors by koolba on Monday April 24, 2017 @12:19PM (#14185517)
Because they don't properly escape things everywhere (anywhere?) and the DB update button is a kludge to deal with existing messed up data breaking pages they don't know about.

It was probably less than an hours work to add that button vs. hundreds of hours to track down all the unescaped outputs.

Re:Tales of SugarCRM Security Horrors by stinky613 on Monday April 24, 2017 @09:57AM (#14184324)
The sibling comments here give good details, but here's a 50,000ft view: https://xkcd.com/463/

The comic compares running McAfee Antivirus on a voting machine to a teacher wearing a condom to work every day; "Strictly speaking, it's better than the alternative--yet someone clearing is doing their job horribly wrong."