Skip to content

C++: Data flow and member templates #19236

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

Open
fbesler opened this issue Apr 7, 2025 · 1 comment
Open

C++: Data flow and member templates #19236

fbesler opened this issue Apr 7, 2025 · 1 comment
Labels
question Further information is requested

Comments

@fbesler
Copy link

fbesler commented Apr 7, 2025

Given this example I'm not able to find a data flow in the function process1, while the flow in the others are found.

class Data {
    public:
    template <typename U>
    int process1() {
        return data_ + 10;
    }

    template <typename U>
    int process2(int data) {
        return data + 20;
    }

    int process3() {
        return data_ + 30;
    }

    int data_;
};

int taint_source() {return 1;}

void df() {
    int i;
    Data data;

    data.data_ = taint_source();
    i = data.process1<void>();
    i = data.process2<void>(data.data_);
    i = data.process3();
}

int main(int argc, char* argv[]) {
    df();
    return 0;
}
/**
 * @kind path-problem
 */

import cpp
import semmle.code.cpp.dataflow.new.TaintTracking
import MyFlow::PathGraph

module MyFlowConf implements DataFlow::ConfigSig {
  predicate isSource(DataFlow::Node source) {
    source.asExpr() = any(Call c | c.getTarget().hasName("taint_source))
  }

  predicate isSink(DataFlow::Node sink) {
    sink.asExpr() = any(BinaryArithmeticOperation b).getAnOperand()
  }
}

module MyFlow = TaintTracking::Global<MyFlowConf>;

from MyFlow::PathNode source, MyFlow::PathNode sink
where MyFlow::flowPath(source, sink)
select sink, source, sink, "Flow"

Is this related to the issue 18122 ? Is there a way to find the missing data flow?

@fbesler fbesler added the question Further information is requested label Apr 7, 2025
@jketema
Copy link
Contributor

jketema commented Apr 8, 2025

Hi @fbesler,

This is a different issue, as you are instantiating the templates. This is bug though, so thank you for reporting. We have identified what the issue is, and have a potential fix. We'll keep posted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants