6 ms·
I suggest you look at the myriad security problems caused by Ruby's handling of YAML and JSON. It's not necessarily the serialization format at fault, but rath
by kibibu 8y ago
I suggest you look at the myriad security problems caused by Ruby's handling of YAML and JSON.
It's not necessarily the serialization format at fault, but rather developer assumptions.
- willvarfar 8y ago(Here's a post describing some of the problems back in the day with Ruby's YAML and JSON: https://williamedwardscoder.tumblr.com/post/43394068341/rubys-principle-of-too-much-power https://williamedwardscoder.tumblr.com/post/43394068341/ruby... YAML is of course a format that is designed to instantiate objects as described in the source, rather than as checked by the destination, so I wouldn't want the world to adopt YAML instead of Java serialization.)
- imtringued 8y agoYaml is primarily used as hierarchical config format because JSON and XML are too verbose for a human editor.
- simonh 8y agoExactly. The people loading up a YAML library and using it that way may have no idea its a potential remote code execution vector into their application.
- philipov 8y agoLuckily, for those that do know what they're doing, it's simple enough to use the yaml.safe_load function that disables support for arbitrary object instantiation.
- willvarfar 8y agoI believe that the safe_load function only got added because of the spate of exploits that the blog post was talking about. Its good that its been added, although it would have been better if it'd been there from the beginning and the safe version was default and you had to invoke 'unsafe_load' if you wanted complex object instantiation, to hopefully encourage even novices to think twice before doing it with tainted input.
- the_new_guy_29 8y agoRead through it, but i wont blame language creators. Its a lot easier to point out that something is broken than to build something better.
- coldtea 8y agoAnd it's a lot easier to build a new broken thing, that to fix something broken. Which is what the creators of YAML did.
- jwilk 8y agoArchived copy that can be read without JS enabled: https://archive.is/2JGiJ https://archive.is/2JGiJ
- jwilk 8y ago> Only it then turns out that the Ruby JSON parser … yes, you’ve guessed it … the Ruby JSON parser can instantiate complex objects too. Huh. Where can I read more about this?
- jwilk 8y agoRegarding YAML, it's not just Ruby: * Python's yaml.load() hapilly executes arbitrary code. * Some Perl YAML libraries deserialize objects by default: http://blogs.perl.org/users/tinita/2018/02/safely-load-untrusted-yaml-in-perl.html http://blogs.perl.org/users/tinita/2018/02/safely-load-untru...
- philipov 8y agoPython's YAML libraries come with a safe_load function that disables !! commands, so it can be used without loading arbitrary objects.
- ArneBab 8y agoAnd they warn quite clearly about that. Though in hindsight, having load and unsafe_load would have been safer.
- jwilk 8y ago> And they warn quite clearly about that. Do they? https://github.com/yaml/pyyaml https://github.com/yaml/pyyaml doesn't even mention safe_load(). And this is the docstring for yaml.load(): Parse the first YAML document in a stream and produce the corresponding Python object. This doesn't sound very scary, and certainly doesn't imply possible code execution.