Skip to content

Commit 7d3f92b

Browse files
fix: fix incorrect permission may introduce security vulnerabilities.
1 parent 9d4b2bf commit 7d3f92b

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

apps/common/utils/tool_code.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,10 @@ def _init_dir(self):
3636
if ToolExecutor._dir_initialized:
3737
# 只初始化一次
3838
return
39-
if self.sandbox:
40-
os.system(f"chown {self.user}:root {self.sandbox_path}")
41-
os.chmod(self.sandbox_path, 0o550)
42-
if CONFIG.get("SANDBOX_TMP_DIR_ENABLED", '0') == "1":
43-
tmp_dir_path = os.path.join(self.sandbox_path, 'tmp')
44-
os.makedirs(tmp_dir_path, 0o700, exist_ok=True)
45-
os.system(f"chown -R {self.user}:root {tmp_dir_path}")
39+
if CONFIG.get("SANDBOX_TMP_DIR_ENABLED", '0') == "1":
40+
tmp_dir_path = os.path.join(self.sandbox_path, 'tmp')
41+
os.makedirs(tmp_dir_path, 0o700, exist_ok=True)
42+
os.system(f"chown -R {self.user}:root {tmp_dir_path}")
4643
if os.path.exists(self.sandbox_so_path):
4744
os.chmod(self.sandbox_so_path, 0o440)
4845
try:

installer/Dockerfile-base

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
2626
curl -L --connect-timeout 120 -m 1800 https://resource.fit2cloud.com/maxkb/ffmpeg/get-ffmpeg-linux | sh && \
2727
mkdir -p /opt/maxkb-app/sandbox && \
2828
useradd --no-create-home --home /opt/maxkb-app/sandbox sandbox -g root && \
29-
chown -R sandbox:root /opt/maxkb-app/sandbox && \
29+
chown -R sandbox:root /opt/maxkb-app/sandbox && chmod 550 /opt/maxkb-app/sandbox && \
3030
chmod g-xr /usr/local/bin/* /usr/bin/* /bin/* /usr/sbin/* /sbin/* /usr/lib/postgresql/17/bin/* && \
3131
chmod g+xr /usr/bin/ld.so && \
3232
chmod g+x /usr/local/bin/python* && \

0 commit comments

Comments
 (0)