There was a bug in alpha.security.taint.TaintPropagation checker in Clang Static Analyzer.
Taint filtering could only sanitize const arguments.
After this patch, taint filtering is effective also on non-const parameters.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp | ||
---|---|---|
970 | Is it only a formatting hunk? | |
996 | "a a" -> "a" | |
1001 | Why do we need this extra condition? | |
clang/test/Analysis/taint-generic.c | ||
1014 | Can you add a case where the parameter points to const? | |
1057 | Wouldn't it make more sense if depending on the return value of this filter we early return like in the previous examples? |
@steakhal thanks for the review. I addressed/answered your comments.
clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp | ||
---|---|---|
970 | yeap. formatting only. | |
970 | Yes. Only formatting. | |
1001 | That's the heart of the fix. In case we are processing a filter rule, tthe PropDstArgs is empty. Then this part this part without the extra condition put the taintedness back to every pointed to non-const parameter. This is clearly an unwanted behaviour. See also the extra comment. | |
clang/test/Analysis/taint-generic.c | ||
1014 | The previous isOutOfRange(const int*) case is testing the sanitizing when we have a pointer to const. | |
1057 | This test case simulates the case when the buffer is passed by reference and the sanitize command actually changes the contents of the buffer. For example removes shell escapes etc. |
Approved, modulo formatting hunks.
Unless you have really good reasons for having them as well.
clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp | ||
---|---|---|
970 | I would suggest not mixing formatting changes with semantic changes in a single revision. Consider not doing the formatting, or at least format in a different revision. Adding and updating comments are fine. | |
1001 | Makes sense. It actually closely follows how we deal with sinks. | |
clang/test/Analysis/taint-generic.c | ||
1014 | Thanks. Good. | |
1057 | Then have a void return type for it please. |
-formatting issues fixed
-sanitizecCmd changed to void
clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp | ||
---|---|---|
970 | Yes. I realized. I reverted the formatting change. |
Is it only a formatting hunk?
I cannot really tell from my phone xd