Skip to content

Commit 4ae02c8

Browse files
security: fix reverse shell vulnerability in function library.
1 parent 3557ea5 commit 4ae02c8

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

apps/common/util/function_code.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def _exec_sandbox(self, _code, _id):
8888
os.system(f"chown {self.user}:{self.user} {exec_python_file}")
8989
kwargs = {'cwd': BASE_DIR}
9090
subprocess_result = subprocess.run(
91-
['su', '-c', python_directory + ' ' + exec_python_file, self.user],
91+
['su', '-s', python_directory, '-c', "exec(open('" + exec_python_file + "').read())", self.user],
9292
text=True,
9393
capture_output=True, **kwargs)
9494
os.remove(exec_python_file)

installer/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ RUN chmod 755 /opt/maxkb/app/installer/run-maxkb.sh && \
7070
useradd --no-create-home --home /opt/maxkb/app/sandbox sandbox -g root && \
7171
chown -R sandbox:root /opt/maxkb/app/sandbox && \
7272
chmod g-x /usr/local/bin/* /usr/bin/* /bin/* /usr/sbin/* /sbin/* /usr/lib/postgresql/15/bin/* && \
73-
chmod g+x /usr/local/bin/python* /bin/sh
73+
chmod g+x /usr/local/bin/python*
7474

7575
EXPOSE 8080
7676

0 commit comments

Comments
 (0)