volcano-sh / volcano-sh/agentcube
[Security] Sanitize environment variables passed to user commands in ExecuteHandler
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 167
- Forks
- 88
- Avg merge
- 44m
- Merged PRs (30d)
- 1
Description
Description
Currently, the ExecuteHandler in pkg/picod/execute.go inherits the full host environment (os.Environ()) and passes it to the executed command.
Security Concern
This behavior poses a security risk as it may expose sensitive host or container environment variables (e.g., KUBERNETES_SERVICE_HOST, PICOD_AUTH_PUBLIC_KEY, or other secrets) to the arbitrary code being executed by the agent.
Constraint
We cannot simply remove the environment inheritance entirely. The child process requires essential variables like PATH (to locate binaries), HOME (for config files), and LANG/LC_ALL (for character encoding). Removing these results in functional breakages (e.g., subprocess.run failing to find system tools in Python).
Proposed Solution
Implement an allowlist (whitelist) mechanism for environment variables in ExecuteHandler.
- By default, ignore host environment variables.
- Explicitly allow a minimal set of safe, essential variables from the host:
PATHHOMELANG,LC_ALLTERM
- Continue to merge user-provided
req.Envon top of this sanitized list.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in pkg/picod/execute.go at ExecuteHandler and inspect how os.Environ() and req.Env are combined. Replace the full host environment with the specified allowlist while retaining user-provided variables, then verify that PATH, HOME, LANG, LC_ALL, and TERM remain available and other host variables do not.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- security
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100