Skip to content

false positive:Data flow does't restrict while variable reassigned #9935

@mrlzh

Description

@mrlzh

Demo code:

#include <string>
#include <stdio.h>
#include <stdlib.h>

using namespace std;

void mysql_query(char *test1,const char *test2){ //just for test
    printf("%s %s\n",test1,test2);
}

int main(){
    char input[100];
    scanf("%s", input);

    string in(input, strlen(input));

    in="test";

    string sql="select * from test where  xxx='"+in+"'";

    mysql_query("test", sql.c_str());
}

Variable in was reassigned.But Ql in cpp/ql/src/Security/CWE/CWE-089/SqlTainted.ql still alerts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions