mirror of
https://github.com/BaaRai/ARTEX.git
synced 2026-11-25 01:10:54 +08:00
An agent process inherited the server's environment minus the names that ScrubSecretEnv removes: a deny list, so a credential under any other name (one an operator or an image adds) reached the agent's shell, its custom tools and its MCP stdio servers. When a process crosses from the server's identity to the executor's, its environment is now rebuilt from a fixed allowlist: the search path and locale, the temp directory, the non-interactive defaults, the proxy and CA trust variables the agents pass to their shells, PLAYWRIGHT_BROWSERS_PATH and the shim's own variables. The Bash shim and the MCP drop shim rebuild it before the drop; a custom tool starts from it. What the caller passes on purpose still crosses: the agent's Bash env, the TOOL_* parameters, and the configured env of an MCP server, which the drop shim keeps because connectMCP names it in ARTEX_EXEC_KEEP. A nested shell is not filtered again. The startup scrub and the environment seal stay as they are; they are no longer the boundary for agent processes. With the drop disabled nothing changes.
51 lines
1.5 KiB
Go
51 lines
1.5 KiB
Go
//go:build !unix
|
|
|
|
package server
|
|
|
|
import (
|
|
"errors"
|
|
"os"
|
|
"os/exec"
|
|
)
|
|
|
|
// Without unix credentials the privilege drop cannot be applied. ResolveExecPrivilege
|
|
// never enables it here, so these stubs only keep the package compiling; the
|
|
// functions that would act on an enabled drop return an error to fail closed.
|
|
|
|
var errExecUnsupported = errors.New("agent process isolation is not supported on this platform")
|
|
|
|
func execPrivilegeSupported() bool { return false }
|
|
|
|
func serverIsRoot() bool { return false }
|
|
|
|
func applyExecCredential(c *exec.Cmd, p ExecPrivilege) {}
|
|
|
|
func agentProcessEnv(p ExecPrivilege) []string { return os.Environ() }
|
|
|
|
func withExecKeep(p ExecPrivilege, env map[string]string) map[string]string { return env }
|
|
|
|
func prepareExecScript(p ExecPrivilege, path string) error { return nil }
|
|
|
|
func shareRestoredTaskDir(p ExecPrivilege, taskDir string) error { return nil }
|
|
|
|
func shareRestoredSpillDir(p ExecPrivilege, dir string) error { return nil }
|
|
|
|
// PrepareExecPrivilege fails when a drop is enabled; a disabled one does nothing.
|
|
func PrepareExecPrivilege(p *ExecPrivilege, dataDir, keyDir, configPath string) error {
|
|
if p.Enabled {
|
|
return errExecUnsupported
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// InstallBashShim fails when a drop is enabled; a disabled one does nothing.
|
|
func InstallBashShim(p ExecPrivilege) error {
|
|
if p.Enabled {
|
|
return errExecUnsupported
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// RunExecShimIfRequested does nothing: no shim is ever installed on this platform.
|
|
func RunExecShimIfRequested(argv []string) {}
|