Skip to content

libdft64 is following taint not correctly #6

@vanhauser-thc

Description

@vanhauser-thc

I compiled libdft with pin-3.7 and EWAHBoolArray-0.4.0.

As the command line options to watch file descriptions etc have been removed I added just this to the code:

diff --git a/libdft64/syscall_desc.cpp b/libdft64/syscall_desc.cpp
index 22bcc7f..16949b5 100644
--- a/libdft64/syscall_desc.cpp
+++ b/libdft64/syscall_desc.cpp
@@ -951,12 +951,12 @@ post_open_hook(THREADID tid, syscall_ctx_t *ctx)
        LOG("In open\n");
        const std::string fdn = fdname(fd);
 
-       if( !in_dtracker_whitelist(fdn) && !path_isdir(fdn)){
+       if(fdn.find("/tmp/", 0) == 0 || ( !in_dtracker_whitelist(fdn) && !path_isdir(fdn))){
                fdset.insert(fd);
                flag = 1;
                LOG("Inserted " + fdn + " " + decstr(fd) + ".\n");
        }else{
-               LOG("Info ignoring fd " + decstr(fd) + "\n");
+               LOG("Info ignoring fd " + decstr(fd) + " " + fdn + "\n");
        }
 }
 

Some output excerpts of "pin -follow_execv -t ./obj-intel64/libdft-dta.so -- unrar x /tmp/test.rar ":

It taints stuff it should not:

 In open
 in_dtracker_whitelist /lib/x86_64-linux-gnu/libm-2.28.so
 Info ignoring fd 3 /lib/x86_64-linux-gnu/libm-2.28.so
 Setting taint 3 832 bytes

it specifically says "ignoring fd" but still setting taint. this happens all over the place

however it also taints correctly:

 In open
 Inserted /tmp/test.rar 3.
 Setting taint 3 7 bytes
 Setting taint 3 7 bytes
 Setting taint 3 6 bytes
 Setting taint 3 7 bytes
 Setting taint 3 35 bytes

this looks good

but then never follows the taint:

 In open
 in_dtracker_whitelist /prg/tmp/vuzzer64/libdft64/test.txt
 Info ignoring fd 4 /prg/tmp/vuzzer64/libdft64/test.txt
 In mmap -1 0 bytes
 Setting taint 3 14 bytes
 close 4
 Setting taint 3 7 bytes
 close 3
(end of pintool.log)

that fd 4 should have tainted bytes written is not reported.

same if "md5sum /tmp/test.rar" is done, it should show tainted writes to stdout.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions