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

Comments

Projects
None yet
2 participants
@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 from YAML loader can DESTROY method of object created with perl/* tag to YAML loader can run DESTROY method of object created with perl/* tag May 10, 2017

@dod38fr

This comment has been minimized.

Show comment
Hide comment
@dod38fr

dod38fr 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

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

This comment has been minimized.

Show comment
Hide comment
@perlpunk

perlpunk Mar 18, 2018

Collaborator

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

Collaborator

perlpunk commented Mar 18, 2018

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

@perlpunk

This comment has been minimized.

Show comment
Hide comment
@perlpunk

perlpunk Apr 29, 2018

Collaborator

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

Collaborator

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

This comment has been minimized.

Show comment
Hide comment
@perlpunk

perlpunk May 6, 2018

Collaborator

Released YAML 1.24_001

Collaborator

perlpunk commented May 6, 2018

Released YAML 1.24_001

@perlpunk perlpunk closed this May 6, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment