mirror of
https://github.com/BaaRai/ARTEX.git
synced 2026-11-22 16:10:53 +08:00
Norma's tool.Capture writes an oversized tool output to a file in ToolOutputDir, from the server process. ARTEX passed <run dir>/cmd-output: the executor can write in the run directory and could turn cmd-output into a symlink, so root wrote the spill where the link pointed. - With the privilege drop on, ToolOutputDir is <data>/spill/tasks/<id> for the worker, the main agent and the planner of a task, and <data>/spill/sessions/<id> for a chat. The server creates it when the run starts (agent.SetSpillDirMaker, same style as SetRunDirMaker): root:<exec gid> 0750 below root:root 0755 parents, each level through a descriptor opened with O_NOFOLLOW. A directory that cannot be created leaves the run without a spill directory (output is truncated), never with the run directory. Without the drop the path stays <run dir>/cmd-output. - Norma v0.4.11 writes the spill file 0600 (directory 0700), so the executor could not read it. The runs wrap their hooks (agent.SpillHooks): after a tool call whose result carries the spill marker, the server makes the files of the directory root:<exec gid> 0640. The agent reads a spill with Bash; the file tools do not reach outside the run directory. - The spill directory follows the task: stageTaskFiles moves it to the delete staging with tasks/<id>, stageTaskArchiveFiles packs it as files/spill/tasks/<id>, and installTaskArchiveFiles restores it and puts its ownership back. Deleting a conversation removes spill/sessions/conv-<id>. Tests: TestToolOutputDir (agent); TestDeleteTaskFilesRemovesSpillDir, TestRemoveConversationSpill and the archive round trip (server); root-only TestSpillDirAsRoot, and the spill directory in TestTaskArchiveRestoreRunDirOwnershipAsRoot. SECURITY.md drops the spill from the residual list.
46 lines
1.3 KiB
Go
46 lines
1.3 KiB
Go
//go:build !unix
|
|
|
|
package server
|
|
|
|
import (
|
|
"errors"
|
|
"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 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) {}
|