fix(security): add nil checks for envSet and extraEnv
This commit is contained in:
parent
7cc6ed435b
commit
ceac1e7671
1 changed files with 10 additions and 6 deletions
|
|
@ -115,18 +115,22 @@ func BuildSanitizedEnv(baseEnv []string, extraAllowlist []string, envSet, extraE
|
|||
}
|
||||
}
|
||||
|
||||
if envSet != nil {
|
||||
for k, v := range envSet {
|
||||
vars[envKey(k)] = v
|
||||
}
|
||||
}
|
||||
|
||||
// Merge extraEnv (tool call) - highest priority
|
||||
// Filter against LLM blocklist to prevent override of sensitive vars
|
||||
if extraEnv != nil {
|
||||
for k, v := range extraEnv {
|
||||
if LLMBlocklist[envKey(k)] {
|
||||
continue // Skip blocked vars
|
||||
}
|
||||
vars[envKey(k)] = v
|
||||
}
|
||||
}
|
||||
|
||||
// Convert to []string for exec.Cmd.Env
|
||||
result := make([]string, 0, len(vars))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue