Open tgsmith61591 opened 4 years ago
Yeah, you have to use yaml.UnsafeLoader
instead of yaml.FullLoader
now, because deserializing !!python/object/apply
objects is exploitable and can run arbitrary code.
Thanks @perlpunk Is it worth putting that in the error message?
Well, the error message is currently generic.
So I would have to look at which Loader was used and if it is FullLoader, and how the tag looks like, and if it matches python/object/apply
then include a hint in the error message.
The warning that you get when not using a loader explicitly should explain things.
I am working with v5,2 shipped by pip by default, and python v3.8.1 (currently the last one) Each of the following fails with an exception:
my_yaml = yaml.load(my_file)
my_yaml = yaml.load(my_file, Loader=yaml.Loader)
my_yaml = yaml.load(my_file, Loader=yaml.FullLoader)
The following still works:
my_yaml = yaml.load(my_file, Loader=yaml.BaseLoader)
It's highly frustrating, because many forums suggest to use FullLoader in case of troubles. At least, BaseLoader which is the working one should be the default.
The release of 5.2 last night created a regression on deserializing
OrderedDicts
. Here's a copy/pastable example that works in 5.1.2:When I try it on 5.2, here's what I get:
Interestingly, the data still serializes properly, so it appears to be an issue in the deserialization only.