mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-16 09:22:51 +00:00
fix(security): securely handle root CWD in isTrustedSystemPath
This commit is contained in:
@@ -521,7 +521,8 @@ export function isTrustedSystemPath(filePath: string): boolean {
|
||||
|
||||
// 1. Explicitly reject paths in current working directory to prevent RCE
|
||||
const normCwd = normalizePath(process.cwd());
|
||||
if (normPath === normCwd || normPath.startsWith(normCwd + '/')) {
|
||||
const relative = path.relative(normCwd, normPath);
|
||||
if (!relative.startsWith('..') && !path.isAbsolute(relative)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user