Multiple security vulnerabilities in Rails(groups.google.com) |
Multiple security vulnerabilities in Rails(groups.google.com) |
[CVE-2015-7581] Object leak vulnerability for wildcard controller routes in Action Pack: Look for routes that contain ":controller" and change it to something else. Hopefully you didn't have this weird name in your routes.
[CVE-2015-7578/79] Possible XSS vulnerability in rails-html-sanitizer: You're safe if you use a single page application that properly encode for you. Stripping tags isn't the best way anyway to filter XSS, so if you're encoding, you're good.
[CVE-2016-0753] Possible Input Validation Circumvention in Active Model: params.permit! is negligence, you should not be doing that anyway
[CVE-2016-0752] Possible Information Leak Vulnerability in Action View: render params[:id] is not defensive programming, so you should not be doing that too
[CVE-2015-7577] Nested attributes rejection proc bypass in Active Record: Only if using nested_attributes and rejection proc. Wasn't my case. Just patch.
[CVE-2016-0751] Possible Object Leak and Denial of Service attack in Action Pack: DoS is bad, just patch.
[CVE-2015-7576] Timing attack vulnerability in basic authentication in Action Controller: Just patch.
-- Doesn't look THAT bad, but need to be patched fast.
Your opinions about rails-html-sanitizer are particularly troubling as even if you use the sanitizer as suggested in the docs you're vulnerable and your retort is "well you should encode AND sanitise, not just rely on the sanitiser doing what the documentation says it should do!" Why?
I have no issue with the wording in the official CVEs. But this attempt at whitewashing the, frankly, pretty serious issues is deplorable.
But hey, you won't do any good complaining in face of this situation. Time to help people fix it. Peace.
And, more concretely, I have no problem with his pointing out that some of--not all, but some--these issues are ones mitigated by decent, security-aware software development practices, like, oh, "don't spit something into a template out of your input parameters". Because tools break. Your libraries break. They will always break. Program defensively in all situations where hostile input is possible and never take for granted any attempts to defuse attacks; always favor braces-and-belt wherever possible and you'll generally do okay. It's entirely unnecessary to be a jerk towards him for saying this.
Fixing security vulnerabilities and writing docs that actually reflect best security practices do not make developers smile.
And accusing to have a terrible attitude does not make a developer smile either, so this is obviously your fault!
/s
So uh, what if your application is taking an input that's then parsed by another application with poor output encoding? Granted, the application that's properly encoding for the correct context is good, but any applications which don't do that but also use that same dataset are screwed because your application didn't perform proper input validation.
Defense in depth strategies exist for a reason. Input validation, output encoding for every single context (this includes using angular properly, for instance), anti-xss headers, CSP, the list goes on. These aren't all prescribed just to protect that one application. They're prescribed so that when applied correctly across all apps, they're all protected from negligence in one app harming the data.
- A timing attack if you're using HTTP basic auth
- A couple of GC related DoS attacks
- An issue with `accepts_nested_attributes_for` if you're using both the `allow_destroy` and `reject_if` options
- A validation bypass exploit if you're calling `SomeModel.new(params[:some_model])` instead of using StrongParams
- An information leak exploit if you're calling `render params[:something]` with raw user input
- A bunch of potential XSS exploits
The `render` issue looks like it could cause the most harm, but hopefully shouldn't be too prevalent. The XSS issues should be a quick fix as you only have to update `rails-html-sanitizer`, not Rails itself.
I'd say that qualifies as pretty bad.
How the hell does that even happen? Using time constant string comparison is authentication 101. That's really not something you can mess up by mistake, it's something you mess up by not understanding what you're doing. And that's is all ignoring the fact that there's no reason to not use hashing here.
I presume this can also be mitigated by implementing rate limiting on your authentication endpoints, although that should also be implemented for other reasons.
[1] https://golang.org/pkg/crypto/subtle/#ConstantTimeCompare
[2] http://php.net/manual/en/function.hash-equals.php
[3] http://www.levigross.com/2014/02/07/constant-time-comparison...
https://github.com/rails/rails/commit/859ca4474e1608b83d6194...
return false unless a.bytesize == b.bytesize
instead of if a.bytesize != b.bytesize
return false
disclaimer: never programmed in rubyThank you Aaron.
…
Installing rails-html-sanitizer 1.0.3 (was 1.0.2)
Installing actionmailer 4.2.5.1 (was 4.2.5)
Installing activemodel 4.2.5.1 (was 4.2.5)
Installing activerecord 4.2.5.1 (was 4.2.5)
Installing railties 4.2.5.1 (was 4.2.5)
Installing rails 4.2.5.1 (was 4.2.5)
…
Bundle updated!random quote: 'I used to consume cannabis on a daily basis, I suffer no short term memory loss, as far as I can remember....'
In any case, nice chat. I like productive exchanges.
First as the conditional only has one statment it's preferred to write it in its shorthand way, so instead of
if a.bytesize != b.bytesize
return false
We start by writing return false if a.bytesize != b.bytesize
And then unless is the negated conditional, so we rewrite it as return false unless a.bytesize == b.bytesize
Which some peolpe (myself included) consider easier to read, the 'unless' is easier to note (more chars) than the '!='.And it's not that it wasn't caught until now, it's that it wasn't caught before the commit was accepted.
That said, there still shouldn't be security holes in the framework.
Performing a timing attack requires control of the bytes being compared. If you can control the bytes of the output of a SHA256 then there are some Bitcoin miners who will pay you a lot of money.
If you want to be over-the-top about it you can get some secure randomness and add it to the values being compared before hashing, and then attacker would have even less control over the bytes being compared.
You don't need that much of the hash to perform wordlist attacks and find likely candidates.
I mean, it's funny to be far enough down the rabbit hole to be doing hash-compare. Then to say we wanted randomly keyed hash-compare is the final step. The nice thing is adding some random bytes imposes a fairly miniscule performance hit and it's purely computation, no additional storage. Probably still too slow to use for every comparison, but for constant-time critical comparison, it literally can't hurt.
Hash collision implies attacker has control of both the inputs, in this case we'd be talking about a preimage attack.
If your attacker can perform preimage attacks on SHA256 they can also most likely hack you via your package manager.
"Hopefully you didn't have this weird name in your routes."
"Stripping tags isn't the best way anyway to filter XSS, so if you're encoding, you're good."
"is negligence, you should not be doing that anyway"
"is not defensive programming, so you should not be doing that too"
It isn't "reflecting" it is blame shifting. And there's a huge difference between defensive programming and being psychic, in this case it is more the latter, as even features like the sanitiser we should have known better than to use as the docs tell us to.
Especially considering that he makes pretty obvious factual errors, e.g:
>[CVE-2015-7578/79] Possible XSS vulnerability in rails-html-sanitizer: You're safe if you use a single page application that properly encode for you. Stripping tags isn't the best way anyway to filter XSS, so if you're encoding, you're good.
If you don't want any HTML you aren't supposed to be using rails-html-sanitizer, it's specifically for scenarios where you can't do that.
from CVE-2015-7580:
Carefully crafted strings can cause user input to bypass the sanitization in the white list sanitizer
So people are using a whitelist, and this bug is in that whitelist. In other words, people are "doing the right thing" and are still vulnerable.
Also, I'm pretty sure you're specifically supposed to use rails-html-sanitizer with a whitelist. (See: Rails::Html::WhiteListSanitizer)
I called him out for his specific replies in this specific thread. I didn't call out his reputation or character.
Maybe you should stick to what they and I actually posted here today, and not try to draw the conversation off track into reputation wars.
> It's entirely unnecessary to be a jerk towards him for saying this.
I don't appreciate being called a "jerk."
I stand by what I said, and what I said was that I felt (and feel) that they have a bad attitude to security. They're trying to shift blame from the rails developers to every rails user, and their excuses are weak.
If you think that is "jerky," that's fine, but I feel like name calling and playing the reputation card for no reason is only going to take a conversation down a bad and unconstructive path.
Eh, I'm not sure about that. When I see "Wow you have a terrible attitude about security" I'm inclined to think that's exactly what you're doing. I don't have a horse in this race but you seem to be unnecessarily aggressive/antagonistic and you could have discussed the individual merits of his comment without doing that.
Then try not to sound like one? The OP went out of his way to compile and document the important bugs and post them here. You, on the other hand, completely ignored the value of his contribution and instead rudely called him out on a very minor (and frankly, subjective) tonal issue, and went so far as to call it "whitewashing," which implies that he has an agenda.
He does make multiple valid points though.
If the users of your framework are consistently causing major security problems and the framework is built in a way that it can't be fixed without compromise.. I dunno.. document it? Maybe? Your documentation is basically the API to learning your framework, so if the API is broken to the extent of causing security problems, then it's not god damn production ready!
Remember, if every student is failing your class, the student probably isn't the one to blame.
Except not every student is failing the class. Only those not following best practices are.
For example, if you're using params.permit!, you're simply being lazy. This is clearly documented[1]:
"Extreme care should be taken when using permit! as it will allow all current and future model attributes to be mass-assigned."
[1]https://github.com/rails/strong_parameters#permitted-scalar-...