mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-08-20 22:13:45 +00:00
fix: tighten character whitelist for cloud_headless_env values (#2890)
The env value whitelist allowed @, %, +, =, :, and , characters that are unnecessary for cloud resource names (server names, regions, sizes) and could be used as shell metacharacters in certain contexts. Restrict to only [A-Za-z0-9._/-] which matches all legitimate cloud resource identifiers. Fixes #2883 Agent: code-health Co-authored-by: B <6723574+louisgv@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
fa79d34a47
commit
d046a9bfdf
1 changed files with 5 additions and 2 deletions
|
|
@ -102,8 +102,11 @@ provision_agent() {
|
|||
continue
|
||||
;;
|
||||
esac
|
||||
# Validate value against a safe character whitelist BEFORE export
|
||||
if printf '%s' "${_env_val}" | grep -qE '[^A-Za-z0-9@%+=:,./_-]'; then
|
||||
# Validate value: only allow characters that appear in cloud resource names
|
||||
# (server names, regions, sizes). This strict whitelist rejects all shell
|
||||
# metacharacters ($, `, ', ", ;, |, &, etc.) preventing command injection
|
||||
# even if the cloud_headless_env function is compromised.
|
||||
if printf '%s' "${_env_val}" | grep -qE '[^A-Za-z0-9._/-]'; then
|
||||
log_err "Invalid characters in env value for ${_env_name}"
|
||||
continue
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue