Skip to content

Commit ce99341

Browse files
Potential fix for code scanning alert no. 65: Uncontrolled data used in path expression
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 3b02eb4 commit ce99341

File tree

1 file changed

+6
-2
lines changed
  • remote-workspace/src/servers/api-server/platform-api

1 file changed

+6
-2
lines changed

remote-workspace/src/servers/api-server/platform-api/handler.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ function safeWorkspaceResolve(uri: string): string {
1919
// Resolve symlinks to their actual paths
2020
const realPath = fs.existsSync(absPath) ? fs.realpathSync(absPath) : absPath;
2121

22-
// Ensure it’s inside the workspace root
23-
if (!realPath.startsWith(workspaceRoot + path.sep)) {
22+
// Ensure it's inside the workspace root (strict, cross-platform)
23+
const rel = path.relative(workspaceRoot, realPath);
24+
if (
25+
rel.startsWith('..') ||
26+
path.isAbsolute(rel)
27+
) {
2428
throw new Error("Cannot access path outside of workspace path.");
2529
}
2630

0 commit comments

Comments
 (0)