From faca87bbc8997f896df1a6c25d12b4f9a5bad719 Mon Sep 17 00:00:00 2001 From: Nate Sesti <33237525+sestinj@users.noreply.github.com> Date: Mon, 9 Mar 2026 12:27:47 -0700 Subject: [PATCH] fix: add security check to createNewFile tool (CWE-22) (#11238) * fix: add security check to createNewFile tool (CWE-22) The createNewFile tool was missing the throwIfFileIsSecurityConcern() check that readFile already has, allowing path traversal to write sensitive file types (e.g. .env, SSH keys) via prompt injection. Co-Authored-By: Claude Opus 4.6 * fix: upgrade tar-fs to patch CVE-2024-12905 and CVE-2025-59343 core/vendor had tar-fs@2.1.2 (via prebuild-install) and tar-fs@3.0.8, both in vulnerable ranges. npm audit fix upgraded them. Co-Authored-By: Claude Opus 4.6 --------- Co-authored-by: Claude Opus 4.6 --- core/tools/implementations/createNewFile.ts | 2 ++ core/vendor/package-lock.json | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/core/tools/implementations/createNewFile.ts b/core/tools/implementations/createNewFile.ts index dca307d99..b6c626d73 100644 --- a/core/tools/implementations/createNewFile.ts +++ b/core/tools/implementations/createNewFile.ts @@ -1,6 +1,7 @@ import { inferResolvedUriFromRelativePath } from "../../util/ideUtils"; import { ToolImpl } from "."; +import { throwIfFileIsSecurityConcern } from "../../indexing/ignore"; import { getCleanUriPath, getUriPathBasename } from "../../util/uri"; import { getStringArg } from "../parseArgs"; import { ContinueError, ContinueErrorReason } from "../../util/errors"; @@ -14,6 +15,7 @@ export const createNewFileImpl: ToolImpl = async (args, extras) => { extras.ide, ); if (resolvedFileUri) { + throwIfFileIsSecurityConcern(getCleanUriPath(resolvedFileUri)); const exists = await extras.ide.fileExists(resolvedFileUri); if (exists) { throw new ContinueError( diff --git a/core/vendor/package-lock.json b/core/vendor/package-lock.json index 2a59b297b..d16a9798a 100644 --- a/core/vendor/package-lock.json +++ b/core/vendor/package-lock.json @@ -519,9 +519,9 @@ } }, "node_modules/prebuild-install/node_modules/tar-fs": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.2.tgz", - "integrity": "sha512-EsaAXwxmx8UB7FRKqeozqEPop69DXcmYwTQwXvyAPF352HJsPdkVhvTaDPYqfNgruveJIJy3TA2l+2zj8LJIJA==", + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.4.tgz", + "integrity": "sha512-mDAjwmZdh7LTT6pNleZ05Yt65HC3E+NiQzl672vQG38jIrehtJk/J3mNwIg+vShQPcLF/LV7CMnDW6vjj6sfYQ==", "license": "MIT", "dependencies": { "chownr": "^1.1.1", @@ -742,9 +742,9 @@ } }, "node_modules/tar-fs": { - "version": "3.0.8", - "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-3.0.8.tgz", - "integrity": "sha512-ZoROL70jptorGAlgAYiLoBLItEKw/fUxg9BSYK/dF/GAGYFJOJJJMvjPAKDJraCXFwadD456FCuvLWgfhMsPwg==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-3.1.2.tgz", + "integrity": "sha512-QGxxTxxyleAdyM3kpFs14ymbYmNFrfY+pHj7Z8FgtbZ7w2//VAgLMac7sT6nRpIHjppXO2AwwEOg0bPFVRcmXw==", "license": "MIT", "dependencies": { "pump": "^3.0.0",