mirror of
https://github.com/github/codeql.git
synced 2025-12-22 11:46:32 +01:00
Python: Handle find_library assignment to temp variable
This commit is contained in:
@@ -14,12 +14,11 @@ import experimental.semmle.python.Concepts
|
||||
import semmle.python.dataflow.new.TaintTracking
|
||||
|
||||
API::Node libPam() {
|
||||
exists(API::CallNode findLibCall, API::CallNode cdllCall, StrConst str |
|
||||
exists(API::CallNode findLibCall, API::CallNode cdllCall |
|
||||
findLibCall = API::moduleImport("ctypes.util").getMember("find_library").getACall() and
|
||||
findLibCall.getParameter(0).getAValueReachingRhs().asExpr().(StrConst).getText() = "pam" and
|
||||
cdllCall = API::moduleImport("ctypes").getMember("CDLL").getACall() and
|
||||
DataFlow::localFlow(DataFlow::exprNode(str), findLibCall.getArg(0)) and
|
||||
str.getText() = "pam" and
|
||||
cdllCall.getArg(0) = findLibCall
|
||||
cdllCall.getParameter(0).getAValueReachingRhs() = findLibCall
|
||||
|
|
||||
result = cdllCall.getReturn()
|
||||
)
|
||||
|
||||
@@ -1 +1 @@
|
||||
| pam_test.py:44:18:44:44 | ControlFlowNode for pam_authenticate() | This PAM authentication call may be lead to an authorization bypass. |
|
||||
| pam_test.py:48:18:48:44 | ControlFlowNode for pam_authenticate() | This PAM authentication call may be lead to an authorization bypass. |
|
||||
|
||||
@@ -18,9 +18,13 @@ class PamResponse(Structure):
|
||||
class PamConv(Structure):
|
||||
pass
|
||||
|
||||
|
||||
# this is normal way to do things
|
||||
libpam = CDLL(find_library("pam"))
|
||||
|
||||
# but we also handle assignment to temp variable
|
||||
temp = find_library("pam")
|
||||
libpam = CDLL(temp)
|
||||
|
||||
pam_start = libpam.pam_start
|
||||
pam_start.restype = c_int
|
||||
pam_start.argtypes = [c_char_p, c_char_p, POINTER(PamConv), POINTER(PamHandle)]
|
||||
|
||||
Reference in New Issue
Block a user