fix: allow dot-dot-prefixed pty session paths

This commit is contained in:
Neil
2026-05-30 06:44:55 -07:00
parent 74a47962da
commit 22ddcf8178
2 changed files with 5 additions and 1 deletions
+4
View File
@@ -75,6 +75,10 @@ describe('isSafePtySessionId', () => {
// validator must allow that as long as the result stays inside userData.
expect(isSafePtySessionId('sub/path/ok@@12345678', USER_DATA)).toBe(true)
})
it('accepts ids with path segments that merely start with dot-dot', () => {
expect(isSafePtySessionId('..sessions/ok@@12345678', USER_DATA)).toBe(true)
})
})
describe('parsePtySessionId', () => {
+1 -1
View File
@@ -61,7 +61,7 @@ export function isSafePtySessionId(id: string, userDataPath: string): boolean {
// from C:\userdata to D:\evil yields "D:\evil", which does NOT start with
// ".."). Reject any absolute result — a legitimate subpath under
// userData always produces a relative result on every platform.
if (rel === '' || isAbsolute(rel) || rel.startsWith('..') || rel.includes(`..${sep}`)) {
if (rel === '' || isAbsolute(rel) || rel === '..' || rel.startsWith(`..${sep}`)) {
return false
}
return true