Skip to content

Commit 490dbf7

Browse files
konstantintstefano-maggiolo
authored andcommitted
Avoid using non-suid isolate executable
1 parent ec362cf commit 490dbf7

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

cms/grading/Sandbox.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -902,11 +902,13 @@ def detect_box_executable(self):
902902
'..', '..', 'isolate', self.exec_name))]
903903
paths += [self.exec_name]
904904
for path in paths:
905-
# Consider only non-directory, executable files.
905+
# Consider only non-directory, executable files with SUID flag on.
906906
if os.path.exists(path) \
907907
and not os.path.isdir(path) \
908908
and os.access(path, os.X_OK):
909-
return path
909+
st = os.stat(path)
910+
if st.st_mode & stat.S_ISUID != 0:
911+
return path
910912

911913
# As default, return self.exec_name alone, that means that
912914
# system path is used.

0 commit comments

Comments
 (0)