You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The idea is to track the taint flow from the call to taint_src to the return value of main.
I'm having problems modelling getNumber to specify that ptr_main should be tainted after the call to getNumber returns. None of the predicates in DataFlowFunction or TaintFunction seem to be able to model this, as the argument ptr_main is passed by value. Is there anyway to model the taint flow for such cases?
(If anyone is trying to model this, do note that std::shared_ptr::operator* is const qualified, and hence Issue 5116 will also crop up until it is fixed.)
I passed the question on to our C/C++ analysis experts in @github/codeql-c-analysis. They agree that the taint analysis is being confused by the use of std::shared_pointer rather than a reference or primitive C pointer for the output parameter, and are considering what the best way to un-confuse it would be. Stay tuned.
Thanks for bringing this to our attention. This is indeed a problem that's not quite easy to solve currently. If the shared_ptr was passed by reference it should be possible to use Node.asDefiningArgument() to add a custom taint rule to the configuration.
We're currently working on increased model coverage of the standard library, and shared_ptr is coming up on our list very soon. Hopefully, this will solve the problem you're hitting!
Activity
[-]C++: Taint Modelling involving Pass-by-Value Objects[/-][+]C++: Taint tracking through std::shared_ptr[/+]hmakholm commentedon Feb 17, 2021
I passed the question on to our C/C++ analysis experts in @github/codeql-c-analysis. They agree that the taint analysis is being confused by the use of
std::shared_pointerrather than a reference or primitive C pointer for the output parameter, and are considering what the best way to un-confuse it would be. Stay tuned.MathiasVP commentedon Feb 23, 2021
Hi @creative16,
Thanks for bringing this to our attention. This is indeed a problem that's not quite easy to solve currently. If the
shared_ptrwas passed by reference it should be possible to useNode.asDefiningArgument()to add a custom taint rule to the configuration.We're currently working on increased model coverage of the standard library, and
shared_ptris coming up on our list very soon. Hopefully, this will solve the problem you're hitting!p.s.: #5116 has now been fixed in #5196.
creative16 commentedon Feb 23, 2021
Hello @MathiasVP,
thanks for the reply. Looking forward to the improvements! And yep, I noticed the fix for #5116 a few days ago. Thanks for fixing it!
C++: Add test from issue github#5190.
MathiasVP commentedon Apr 15, 2021
Hi @creative16,
We've improved our support for smart pointers and on the current main branch I now see flow in your example program with this query:
If you find other issues be sure to let us know!
creative16 commentedon Apr 20, 2021
Hello @MathiasVP,
thanks so much for the fixes. Appreciate it. I'll be sure to let you guys know if I hit other issues. Thanks again!
jbj commentedon May 3, 2021
The improvement should be live on LGTM and Code Scanning. I'll close this ticket, expecting that things are working.