-
Notifications
You must be signed in to change notification settings - Fork 1.8k
CPP: Add query for CWE-552 Files Accessible to External Parties when using rename #9090
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ihsinme,
Thanks for your contribution. A first few questions from my side.
cpp/ql/src/experimental/Security/CWE/CWE-552/DangerousUseRename.ql
Outdated
Show resolved
Hide resolved
cpp/ql/src/experimental/Security/CWE/CWE-552/DangerousUseRename.ql
Outdated
Show resolved
Hide resolved
cpp/ql/src/experimental/Security/CWE/CWE-552/DangerousUseRename.ql
Outdated
Show resolved
Hide resolved
cpp/ql/test/experimental/query-tests/Security/CWE/CWE-552/semmle/tests/test.cpp
Outdated
Show resolved
Hide resolved
cpp/ql/test/experimental/query-tests/Security/CWE/CWE-552/semmle/tests/test.cpp
Outdated
Show resolved
Hide resolved
cpp/ql/test/experimental/query-tests/Security/CWE/CWE-552/semmle/tests/test.cpp
Outdated
Show resolved
Hide resolved
cpp/ql/src/experimental/Security/CWE/CWE-552/DangerousUseRename.cpp
Outdated
Show resolved
Hide resolved
cpp/ql/src/experimental/Security/CWE/CWE-552/DangerousUseRename.qhelp
Outdated
Show resolved
Hide resolved
cpp/ql/src/experimental/Security/CWE/CWE-552/DangerousUseRename.ql
Outdated
Show resolved
Hide resolved
cpp/ql/src/experimental/Security/CWE/CWE-552/DangerousUseRename.ql
Outdated
Show resolved
Hide resolved
…e.ql Co-authored-by: Jeroen Ketema <93738568+jketema@users.noreply.github.com>
cpp/ql/src/experimental/Security/CWE/CWE-552/DangerousUseRename.ql
Outdated
Show resolved
Hide resolved
cpp/ql/src/experimental/Security/CWE/CWE-552/DangerousUseRename.ql
Outdated
Show resolved
Hide resolved
cpp/ql/src/experimental/Security/CWE/CWE-552/DangerousUseRename.ql
Outdated
Show resolved
Hide resolved
cpp/ql/src/experimental/Security/CWE/CWE-552/DangerousUseRename.ql
Outdated
Show resolved
Hide resolved
cpp/ql/src/experimental/Security/CWE/CWE-552/DangerousUseRename.ql
Outdated
Show resolved
Hide resolved
cpp/ql/src/experimental/Security/CWE/CWE-552/DangerousUseRename.ql
Outdated
Show resolved
Hide resolved
…e.ql Co-authored-by: Jeroen Ketema <93738568+jketema@users.noreply.github.com>
Co-authored-by: Jeroen Ketema <93738568+jketema@users.noreply.github.com>
ec.getValue() = "0" and | ||
ecd.(EQExpr).hasOperands(_, ec) and | ||
forall(Expr st | st = ifst.getThen().getASuccessor*() | st != readCall) and | ||
forall(Expr st | st = ifst.getThen().getASuccessor*() | st != writeCall) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which of your test cases covers this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test5
test6
test7
test8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see this. If we look at test5
for example:
if (rename(from,to)==0) // BAD
return;
f1 = fopen(from, "r");
count = fread(data, 1, 1000, f1);
fclose(f1);
remove(to);
f2 = fopen(to, "w");
fwrite(data, count, 1, f2);
fclose(f2);
Then, ifst.getThen().getASuccessor*()
gives you all the statements and expressions textually below if (rename(from,to)==0)
, including fopen(from, "r")
and fopen(to, "w")
, so the forall
does not hold.
Two general comments, which also apply to most of your other queries:
|
To add to the above: this would allow us to give faster and better feedback, which is important, especially when there's a large number of PRs open. |
You are absolutely right, I will try to follow the rules in the future. |
Note by the way that |
I apologize for the wasted time. I am very serious about de-duplicates in my PRs, but in this case my review system failed and I didn't notice this request. Sorry again, I'll try to be more careful in the future. |
this query is looking for a mishandling situation rename. when a file is torn off from the program name and overwritten, this situation can lead to various actions, such as using links.
CVE-2012-0787