Skip to content

Commit aed23c0

Browse files
anandgupta42claude
andcommitted
fix: avoid empty PATH segment when PATH is unset
When `basePath` is empty, `${binDir}${sep}${basePath}` produces a trailing separator that makes cwd searchable on POSIX — a subtle security risk. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
1 parent 5163c82 commit aed23c0

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎packages/opencode/src/tool/bash.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ export const BashTool = Tool.define("bash", async () => {
174174
const basePath = mergedEnv.PATH ?? mergedEnv.Path ?? ""
175175
const pathEntries = basePath.split(sep).filter(Boolean)
176176
if (!pathEntries.some((entry) => entry === binDir)) {
177-
mergedEnv.PATH = `${binDir}${sep}${basePath}`
177+
mergedEnv.PATH = basePath ? `${binDir}${sep}${basePath}` : binDir
178178
}
179179
}
180180

0 commit comments

Comments
 (0)