Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YAML loader can run DESTROY method of object created with perl/* tag #176

Closed
dod38fr opened this issue May 10, 2017 · 4 comments
Closed

YAML loader can run DESTROY method of object created with perl/* tag #176

dod38fr opened this issue May 10, 2017 · 4 comments

Comments

@dod38fr
Copy link

@dod38fr dod38fr commented May 10, 2017

Hi

YAML tags in the form perl/Foo::Bar enable an attacker to create an object with arbitrary data from an existing class. An attacker can't invoke a method from this object, except DESTROY method which is run when the object is destroyed or when the process exits.

And here's a example of using DESTROY:

use strict;
use warnings;
use 5.10.1;

package Foo::Bar;

sub DESTROY {
    say "Destroyed with ",$_[0]->{bar};
}

package main;

use YAML;
use Data::Dumper;

my $yaml = << "EOY";
---
obj: !perl/Foo::Bar
  bar: kaboom
EOY

say $yaml;

my $d = Load($yaml);
say Dumper $d;

Here's an example of abuse possibility using File::Temp::Dir: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=861958

At the very least, could you add an option to disable object creation from YAML tag ?

A better solution would be to disable this feature by default and let user enable it when needed.

All the best

@dod38fr dod38fr changed the title YAML loader can DESTROY method of object created with perl/* tag YAML loader can run DESTROY method of object created with perl/* tag May 10, 2017
@dod38fr
Copy link
Author

@dod38fr dod38fr commented May 11, 2017

Note that this issue is similar to this one for YAML::XS except that Perl object are created with tag Foo::Bar instead of tag perl/Foo::Bar

@perlpunk
Copy link
Collaborator

@perlpunk perlpunk commented Mar 18, 2018

Thanks; I suggested implementing $LoadBlessed like in YAML::Syck and YAML::XS

@perlpunk
Copy link
Collaborator

@perlpunk perlpunk commented Apr 29, 2018

I have begun working on this at the Perl Toolchain Summit, adding the new option $YAML::LoadBlessed.
Work is almost done, I think.

@perlpunk
Copy link
Collaborator

@perlpunk perlpunk commented May 6, 2018

Released YAML 1.24_001

@perlpunk perlpunk closed this as completed May 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants