From aa0425591a6a17e686de00b15d20def33379cfdb Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 30 Jun 2026 14:38:34 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Sentinel:=20[HIGH]=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=96=87=E4=BB=B6=E4=B8=8B=E8=BD=BD=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E8=B7=AF=E5=BE=84=E7=A9=BF=E8=B6=8A=E6=BC=8F=E6=B4=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在 `src/simulation/mujocoUtils.js` 中,`downloadExampleScenesFolder` 会将外部文件直接写入 MuJoCo 虚拟文件系统。如果 `relativePath` 包含恶意路径(如 `../` 或 `/`),可能导致跨目录写入。增加正则匹配 `/(^|\/)\.\.(\/|$)/` 以及绝对路径校验,以安全阻断目录穿越行为,同时允许文件名内合法包含 `..`。 Co-authored-by: ImChong <74563097+ImChong@users.noreply.github.com> --- .jules/sentinel.md | 5 +++++ src/simulation/mujocoUtils.js | 3 +++ 2 files changed, 8 insertions(+) diff --git a/.jules/sentinel.md b/.jules/sentinel.md index 3739f7e..e6d54a8 100644 --- a/.jules/sentinel.md +++ b/.jules/sentinel.md @@ -70,3 +70,8 @@ **Vulnerability:** Weak random number generation using `Math.random()`. **Learning:** `Math.random()` is not cryptographically secure, which could lead to predictable outcomes in simulation generation or terrain seeding. **Prevention:** Use `window.crypto.getRandomValues()` instead of `Math.random()` to ensure strong random number generation for security or unpredictability. + +## 2026-06-29 - [Zip Slip Path Traversal] +**Vulnerability:** Path traversal (Zip Slip) vulnerability in file download handling. +**Learning:** Writing files directly to the MuJoCo WASM virtual filesystem (`mujoco.FS.writeFile`) using paths sourced from external/downloaded files (like `files.json`) without validation allows malicious paths (e.g., `../` or `/`) to write outside the intended working directory. +**Prevention:** Always validate relative paths to prevent directory traversal by checking against regex like `/(^|\/)\.\.(\/|$)/` and checking for absolute paths (`startsWith('/')`) before performing file system operations. diff --git a/src/simulation/mujocoUtils.js b/src/simulation/mujocoUtils.js index 8df70ac..583536c 100644 --- a/src/simulation/mujocoUtils.js +++ b/src/simulation/mujocoUtils.js @@ -753,6 +753,9 @@ export async function downloadExampleScenesFolder(mujoco, onProgress, options = }); const writeToFs = (relativePath, data) => { + if (/(^|\/)\.\.(\/|$)/.test(relativePath) || relativePath.startsWith('/')) { + throw new Error(`Path traversal detected: ${relativePath}`); + } const split = relativePath.split('/'); let working = '/working/'; for (let f = 0; f < split.length - 1; f++) {