Move safe_search to globals and add LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR to the list of safe flags
This commit is contained in:
parent
bd3787e2bc
commit
49fd4b2ec9
33
flawfinder
33
flawfinder
|
@ -846,24 +846,27 @@ def cpp_unsafe_stl(hit):
|
||||||
if len(hit.parameters) <= 4:
|
if len(hit.parameters) <= 4:
|
||||||
add_warning(hit)
|
add_warning(hit)
|
||||||
|
|
||||||
|
safe_load_library_flags = [
|
||||||
|
# Load only from the folder where the .exe file is located
|
||||||
|
'LOAD_LIBRARY_SEARCH_APPLICATION_DIR',
|
||||||
|
# Combination of application, System32 and user directories
|
||||||
|
'LOAD_LIBRARY_SEARCH_DEFAULT_DIRS',
|
||||||
|
# This flag requires an absolute path to the DLL to be passed
|
||||||
|
'LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR',
|
||||||
|
# Load only from System32
|
||||||
|
'LOAD_LIBRARY_SEARCH_SYSTEM32',
|
||||||
|
# Load only from directories specified with AddDllDirectory
|
||||||
|
# or SetDllDirectory
|
||||||
|
'LOAD_LIBRARY_SEARCH_USER_DIRS',
|
||||||
|
# Loading from the current directory will only proceed if
|
||||||
|
# the current directory is part of the safe load list
|
||||||
|
'LOAD_LIBRARY_SAFE_CURRENT_DIRS'
|
||||||
|
]
|
||||||
|
|
||||||
def load_library_ex(hit):
|
def load_library_ex(hit):
|
||||||
# If parameter 3 has one of the flags below, it's safe.
|
# If parameter 3 has one of the flags below, it's safe.
|
||||||
safe_search = [
|
|
||||||
# Load only from the folder where the .exe file is located
|
|
||||||
'LOAD_LIBRARY_SEARCH_APPLICATION_DIR',
|
|
||||||
# Combination of application, System32 and user directories
|
|
||||||
'LOAD_LIBRARY_SEARCH_DEFAULT_DIRS',
|
|
||||||
# Load only from System32
|
|
||||||
'LOAD_LIBRARY_SEARCH_SYSTEM32',
|
|
||||||
# Load only from directories specified with AddDllDirectory
|
|
||||||
# or SetDllDirectory
|
|
||||||
'LOAD_LIBRARY_SEARCH_USER_DIRS',
|
|
||||||
# Loading from the current directory will only proceed if
|
|
||||||
# the current directory is part of the safe load list
|
|
||||||
'LOAD_LIBRARY_SAFE_CURRENT_DIRS'
|
|
||||||
]
|
|
||||||
if (len(hit.parameters) >= 4 and
|
if (len(hit.parameters) >= 4 and
|
||||||
any(flag in hit.parameters[3] for flag in safe_search)):
|
any(flag in hit.parameters[3] for flag in safe_load_library_flags)):
|
||||||
return
|
return
|
||||||
normal(hit)
|
normal(hit)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue