mirror of
https://github.com/garrytan/gstack.git
synced 2026-08-27 16:40:26 +02:00
security: fix path validation bypass, CORS restriction, cookie-import path check
- startsWith('/tmp') matched '/tmpevil' — now requires trailing slash
- CORS Access-Control-Allow-Origin changed from * to http://127.0.0.1:<port>
- cookie-import now validates file paths (was missing validateReadPath)
- 3 new tests for prefix collision and cookie-import path traversal
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
da7ec213e2
commit
47a8277567
@@ -1495,4 +1495,32 @@ describe('Path traversal prevention', () => {
|
||||
try { fs.unlinkSync(tmpFile); } catch {}
|
||||
}
|
||||
});
|
||||
|
||||
test('screenshot rejects /tmpevil prefix collision', async () => {
|
||||
await handleWriteCommand('goto', [baseUrl + '/basic.html'], bm);
|
||||
try {
|
||||
await handleMetaCommand('screenshot', ['/tmpevil/steal.png'], bm, () => {});
|
||||
expect(true).toBe(false);
|
||||
} catch (err: any) {
|
||||
expect(err.message).toContain('Path must be within');
|
||||
}
|
||||
});
|
||||
|
||||
test('cookie-import rejects path traversal', async () => {
|
||||
try {
|
||||
await handleWriteCommand('cookie-import', ['../../etc/shadow'], bm);
|
||||
expect(true).toBe(false);
|
||||
} catch (err: any) {
|
||||
expect(err.message).toContain('Path traversal');
|
||||
}
|
||||
});
|
||||
|
||||
test('cookie-import rejects absolute path outside safe dirs', async () => {
|
||||
try {
|
||||
await handleWriteCommand('cookie-import', ['/etc/passwd'], bm);
|
||||
expect(true).toBe(false);
|
||||
} catch (err: any) {
|
||||
expect(err.message).toContain('Path must be within');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user