-
Notifications
You must be signed in to change notification settings - Fork 6
Closed
Labels
in-progressIssue is being actively worked onIssue is being actively worked onsafe-to-workSecurity triage: safe for automated processingSecurity triage: safe for automated processing
Description
Summary
The sanitizeTermValue() function in packages/cli/src/shared/ui.ts uses a regex pattern to validate TERM values, but the pattern may allow terminal escape sequences that could be weaponized when interpolated into shell commands on remote servers.
Location
packages/cli/src/shared/ui.ts:276-283
Current Implementation
export function sanitizeTermValue(term: string): string {
if (/^[a-zA-Z0-9._-]+$/.test(term)) {
return term;
}
return "xterm-256color";
}Vulnerability
While the function validates against a restricted character set, TERM values that pass this validation could still contain terminal escape sequences embedded within valid characters. When these values are interpolated into shell commands executed on remote servers, they could potentially execute arbitrary commands or manipulate terminal behavior.
Risk Assessment
- Severity: HIGH
- Likelihood: MEDIUM (requires attacker to control TERM environment variable)
- Impact: Command injection on remote servers
Recommendation
Replace pattern matching with an explicit whitelist of known-safe TERM values:
export function sanitizeTermValue(term: string): string {
const safeTerm = [
'xterm-256color',
'xterm',
'screen-256color',
'screen',
'tmux-256color',
'tmux',
'linux',
'vt100',
'vt220'
];
if (safeTerm.includes(term)) {
return term;
}
return 'xterm-256color';
}-- security/code-scanner
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
in-progressIssue is being actively worked onIssue is being actively worked onsafe-to-workSecurity triage: safe for automated processingSecurity triage: safe for automated processing