mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
fix(security): potential command injection on windows due to `she (#439)
The process is spawned with `shell: process.platform === 'win32'` while including dynamic values (e.g., `opts.sessionId`) in `args`. On Windows, shell invocation can introduce command parsing/injection risks if arguments are not strictly validated/escaped. Affected files: opencodeLocal.ts Signed-off-by: tuanaiseo <221258316+tuanaiseo@users.noreply.github.com>
This commit is contained in:
@@ -9,6 +9,9 @@ export async function opencodeLocal(opts: {
|
||||
}): Promise<void> {
|
||||
const args: string[] = [];
|
||||
if (opts.sessionId) {
|
||||
if (process.platform === 'win32' && /[&|<>^()%!"\r\n]/u.test(opts.sessionId)) {
|
||||
throw new Error('Invalid sessionId');
|
||||
}
|
||||
args.push('--session', opts.sessionId);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user