Skip to content

Commit 5cfeea3

Browse files
authored
Merge pull request #94 from ClayPulse/hotfix
Apply codeql suggestion
2 parents ef086f5 + d265ac7 commit 5cfeea3

File tree

1 file changed

+3
-1
lines changed
  • remote-workspace/src/servers/api-server/platform-api

1 file changed

+3
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ function safeResolve(uri: string): string {
2121
const candidate = path.resolve(SAFE_ROOT, uri);
2222

2323
// Check that candidate is strictly under rootPath (or equal to rootPath)
24-
if (candidate === rootPath || candidate.startsWith(rootPath + path.sep)) {
24+
const rel = path.relative(rootPath, candidate);
25+
// Allow if candidate is rootPath itself, or a subpath (not escaping via '..', not absolute)
26+
if (rel === "" || (!rel.startsWith("..") && !path.isAbsolute(rel))) {
2527
return candidate;
2628
}
2729

0 commit comments

Comments
 (0)