Commit a9c9167
SparkLabScout
fix: path traversal in listDirectory
Fixes security vulnerability #463
The original check using startsWith(projectPath) could be bypassed
with sibling directories that share a prefix with the project path.
Example: projectPath=/home/user/project, directoryPath=../project-evil
resolves to /home/user/project-evil which passes startsWith('/home/user/project')
because 'project-evil' starts with 'project'.
This fix adds path.sep to ensure we're checking for proper directory
boundary, and also checks for exact match to allow listing the project
root itself. This matches the pattern already used in code-search.ts.1 parent 822a299 commit a9c9167
1 file changed
+4
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
17 | 20 | | |
18 | 21 | | |
19 | 22 | | |
| |||
0 commit comments