7 ms·
On Python security amidst recent Rails/YAML vulnerabilities
- zobzu 14y agoand don't forget to sign your packages, because vulnerabilities will always happen anyway, and if those compromise a distribution point, its hard to authenticate those said packages.
- __alexs 14y agoIf PyPi was compromised like RubyGems I'm not sure they'd be more able to reliably recover from it quickly either. PyPi does support package signing (with GPG) but pip doesn't support signature verification and hardly any packages are actually signed anyway. It's actually probably more secure to load your python packages off of specific commits on a public git repo over HTTPS right now. (Except that pip also doesn't validate HTTPS certificates either...) And if you are lucky enough to be using a package that is signed, establishing a WOT with the author to validate their cert might not be easy. It's not like people aren't working on this stuff though. https://www.updateframework.com/ https://www.updateframework.com/ have a 'secure' (the upstream ins't obviously) PyPi mirror and the PEP427 Wheel http://wheel.readthedocs.org/en/latest/ http://wheel.readthedocs.org/en/latest/ format seems to be giving security more consideration than previous attempts at Python packaging have.
- wyuenho 14y agoPlease +1 this pip ticket if you feel that supporting TLS cert and GPG verification should be given the highest priority. https://github.com/pypa/pip/issues/425 https://github.com/pypa/pip/issues/425 I think it's paramount that pip gets this done right now. Installing code directly from PyPI is extremely scary now and has been for years...
- zobzu 14y agoThat's exactly why I posted this comment. I'm fully aware of the state of the things :) I'm hoping this starts to raise enough attention for people to actually fix these things up. The patches for supports are around, and btw, pip now also supports HTTPS properly. (yeah, the experimental branch this is actually merged in) But, people in general have to understand the benefit AND figure out it actually serves a purpose (because as always with security, nobody gives a crap 'til someone gets compromised in a terrible way). That's also because all the library makers (which is virtually everyone and their dog nowadays) have to actually get a proper gpg key, understand how it works, and actually sign their stuff. That's a major effort.
- grey-area 14y agoThe comments on this post are really interesting ( save the first, which unfortunately stoops to much the sort of tribal content-free attacks we've seen on rails vuln news on HN recently). I particularly liked the long one from Nick Coghlan, and though it does seem there are still some worrying vulnerabilities in python, they are ahead of ruby in their packaging system at least in relying on signatures. keen to see ruby gems step up and take security equally seriously.
- PommeDeTerre 14y agoYes, Ruby and Ruby on Rails have received a lot of flak lately, but it is well-deserved and I don't think it is "tribal" in nature. To many of us, these are just yet another set of tools in our very large toolbox. It's obvious that some tools are inherently better than others, however. When I point out that Ruby on Rails or JavaScript have some serious inherent problems, it's not because I think that I belong to some Python "tribe" or the Perl "camp", for instance. It's because I'm doing rational, emotionally-detached analysis of certain pieces of software, and this analysis shows there to be serious problems with said software. I think the same goes for the other people out there who have the courage to point out flaws with JavaScript, Ruby and related technologies. If anyone is acting "tribal", it's those who are so emotionally tied to a particular language or web development framework that they can't stand to hear legitimate concerns regarding important factors like security, performance, maintainability and reliability.
- JshWright 14y agoIn my opinion, the first comment on the post isn't 'tribal' simply because it blindly attacks Ruby, but because it also blindly disregards the vulnerabilities in Python (which the author carefully and reasonably outlined).
- mpyne 14y agoHave you ever looked at the pickle docs though? There is like, literally a 'red alert' banner saying how dangerous it is in combination with arbitrary untrusted input. PyYAML's warning is not quite so blatant (http://pyyaml.org/wiki/PyYAMLDocumentation http://pyyaml.org/wiki/PyYAMLDocumentation) but when you get past installation blah blah blah onto actually loading YAML, the first thing it says (in bold) is that using .load is as dangerous as pickle.load, and it references looking as .safe_load instead. However, it would be better for the tutorial that immediately follows to use safe_load() everywhere that it can reasonably be used and to only mention .load as an advanced topic (except to mention at first that it exists but shouldn't be used)
- reidrac 14y agoI'm not sure if we're talking about a language problem here. The tools are there for you to use them in the proper way and there's always a chance that someone misunderstands how things work. Perl Data::Dumper can be used with eval for serialization, but it is a bad idea. Just like using pickle in Python (most of the time, at least). No matter what you do, there's always room for someone doing something stupid. So I rather have the tools.
- Argorak 14y agoSaying that it is a language problem might be true for that specific case. YAML#load and #dump do Object marshaling, which is always dangerous when the marshaled objects come from untrusted sources and parsed without a template. Similar techniques exist in almost all other languages and object instantiation attacks are nothing unheard of. So most of the bile is unwarranted, unless you are asking for bile back if something like this happens in your language. Everyone who is ranting about the security bugs of other projects clearly lacks the humility that Nick Coghlan is asking for in the comments. But the reason why this specific one is very widespread is actually a cultural one: YAML was propagated as a very convenient serialization format despite the described property, especially as it was in stdlib very early. It turned into one of Rubys beloved conventions. E.g. some static website generators like Jekyll use YAML for meta data, called "front matter" (they use safe_yaml now, don't try), Rubygems used it to dump their specs, etc. Combine that with the fact that Rails activated certain parameter parsers without the users knowledge (by convention, again) and made everyone vulnerable and you have a recipe for desaster. This is hard to fix, but thats the pain of suddenly being under attack. But instead of all the hate, members of other communities should take away these learnings and educate everyone they know that uses Ruby about these topics. In clear words, but without hate.
- patio11 14y agoI think load and dangerous_load is a wonderful paradigm for API design. It bakes security into the core use of your framework for non-security devs. It also makes the framework more productive for security professionals, since for an assessment you can grep for dangerous_load and focus your efforts on making sure those (rare) calls are hermetically sealed from user input rather than having to audit every possible use of the 100x more common load command. (That is where the Rails community is right now, and it sucks.) This is similar to requiring a whitelist for mass assignment (rather than making a blacklist optional): it calls out in the code "These are our weak points! Check them carefully!"
- thibaut_barrere 14y agoI suggest Rails people have a look at safe_yaml which (now) replaces YAML.load by a safe (safer?) version: https://github.com/dtao/safe_yaml https://github.com/dtao/safe_yaml (nb: I've enable it on apps without issues)
- patio11 14y agoI like that project but have been trying to avoid saying "Use this!" because I haven't personally audited it and am scared that Rails devs might adopt it and think it means it definitively resolves all of their issues for February, which it might not.
- thibaut_barrere 14y agoSo far, people I've seen using it are "security-aware" developers who know there is always a remaining risk and who are just trying to reduce the surface attack a bit. For the others, well, we'll have to educate them, or push a safe yaml default quickly into Ruby [1]. This is no holy grail for sure, and there are plenty of other topics to be addressed (eg: secret tokens stored in SCM, pushed to third-party CI services and shared with freelancers and remote employees using non-encrypted disk, shared as well between production and non-regularly updated staging servers etc!) [1] https://github.com/tenderlove/psych/issues/119 https://github.com/tenderlove/psych/issues/119
- vog 14y agoFrom the article: > PyYAML has a .load() method and a .safe_load() method. Why do serialization implementers do this? If you must extend the format with dangerous features, provide them in the non-obvious method. Provide a .load() method and a .dangerous_load() method instead. I think this is a very good advice that holds in general: The default should never be the most feature-rich version, but the most safe version. This is also why you should generally prefer a whitelist approach over a blacklist approach. And this is why templating systems should perform escaping by default, forcing you to explicitly disable it, at concrete places, when including raw HTML.
- gingerlime 14y ago+1 for `dangerous_load`. If it was implemented this way, rather than `load` and `safe_load`, I doubt we would have seen vulnerabilities like the one in both tastypie and piston, the two leading API libraries for Django. See https://www.djangoproject.com/weblog/2011/nov/01/piston-and-tastypie-security-releases/ https://www.djangoproject.com/weblog/2011/nov/01/piston-and-... Whilst python might seem safer than the state in Ruby/Rails, it also has its history of vulnerabilities.
- moneypenny 14y agoIf the original author is reading, those are George Orwell's "pithy maxims", not Allen Short's, but entertaining usage on getting a Big Brother reference into a security/trust context.
- devinj 14y agoGeorge Orwell wrote them, but Allen Short was the person who applied them in that way to a security context. Much of the post is apparently greatly due to Allen Short, so he deserves some mention.
- abecedarius 14y agoFor what it's worth, I applied "freedom is slavery" and "ignorance is strength" to programming back in the 90s in a rambly post on my website. I don't know if Allen ever saw it, and security wasn't much on my mind back then. (We're acquaintances, I admire him, and I'm glad to hear of this talk.)
- maxerickson 14y agoI think you are aggressively misunderstanding the attribution here. The maxims being referenced are the ones about code ('input is an attack', 'small interfaces'). The pithy is writing them in terms of Orwell.