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

Antitaint variable names #5

Open
two-heart opened this issue May 26, 2020 · 2 comments
Open

Antitaint variable names #5

two-heart opened this issue May 26, 2020 · 2 comments

Comments

@two-heart
Copy link

The transformation performed in anti-taint.py will create invalid c code in some cases. This is due to a missing check for the existence of variables named newvar_X.
A minimal example of where this will be a problem is:

int newvar_1 = 1;
char str1[20];
strcpy(str1, "hello");
if(strcmp(str1, "hello")) {
    printf("True");
} else {
    printf("False");
}

which will be transformed to:

int newvar_1 = 1;
char str1[20];
strcpy(str1, "hello");
//////////////// ANTI-TAINT-STR //////////////////
char newvar_1[strlen(str1)];
if (strlen(str1) < 30){    
    for (int i=0;i<strlen(str1);i++){
        int ch=0;
        int temp = 0;
        int temp2 = 0;
        for (int j=0; j<8;j++){
            temp = str1[i];
            temp2 = temp & (1<<j);
            if (temp2 !=0){
                ch |= 1<<j;
            }
        }
        newvar_1[i] = ch;
    }
}
else{    
    strncpy(newvar_1, str1, strlen(str1));
}
//////////////////////////////////////////////////
   if(strcmp(newvar_1, "hello")) {
      printf("True");
   } else {
      printf("False");
   }

where newvar_1 is already in use.

Further i would like to ask you where you apply the crc checksum replacements of the form:

// original code: if (value == 12345)
if (CRC_LOOP(value) == OUTPUT_CRC) { ... }

that you write about in your paper.

@two-heart
Copy link
Author

In some rare cases fuzzification will even produce valid C code that has a different meaning:

strcpy(str1, "if(strcmp(str2,str1))");

@jinhojun
Copy link
Contributor

Thanks for the report.

We confirmed the problem. We will fix shortly.

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