[Python-checkins] os.startfile(): add a C comment on security (#3877)

Victor Stinner webhook-mailer at python.org
Fri Oct 13 16:46:59 EDT 2017


https://github.com/python/cpython/commit/a99121526a14e7710843aa5dd6ac82a779542dfb
commit: a99121526a14e7710843aa5dd6ac82a779542dfb
branch: master
author: Victor Stinner <victor.stinner at gmail.com>
committer: GitHub <noreply at github.com>
date: 2017-10-13T13:46:57-07:00
summary:

os.startfile(): add a C comment on security (#3877)

LoadLibrary("SHELL32") is not vulnerable to DLL hijacking.

files:
M Modules/posixmodule.c

diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 5f30b202ec6..639e45021f2 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -10556,6 +10556,10 @@ check_ShellExecute()
     /* only recheck */
     if (-1 == has_ShellExecute) {
         Py_BEGIN_ALLOW_THREADS
+        /* Security note: this call is not vulnerable to "DLL hijacking".
+           SHELL32 is part of "KnownDLLs" and so Windows always load
+           the system SHELL32.DLL, even if there is another SHELL32.DLL
+           in the DLL search path. */
         hShell32 = LoadLibraryW(L"SHELL32");
         Py_END_ALLOW_THREADS
         if (hShell32) {



More information about the Python-checkins mailing list