Menu

Your agent doesn't need a shell. It needs an allowlist that can't become a launcher.
📰

Your agent doesn't need a shell. It needs an allowlist that can't become a launcher.

DEV Community: go·Marcus Beauregard·15 days ago
#w5fjO6Pq
#devtogo#devto#dev#shell#string
Long article (866 words) — no AI summary yet.
Reading 0:00
15s threshold

Last week I deleted the JavaScript implementation of agent-runner and rewrote it in Go. The agent loop ported cleanly. The interesting part was the tool layer, because that is where an agent stops being a demo.

In the JS version, run_command called exec() and let the shell sort it out. That is fine when the only thing running it is you, on your own machine, watching the output. It is not fine the moment the loop runs unattended against a repo you care about. A model that can reach a shell can do anything your user can do, and it will get there by accident long before it gets there on purpose.

So the Go port puts the whole safety story in three boring places.

1. There is no shell to reach

The command string is split into argv by hand. When the tokenizer meets a character a shell would interpret, it refuses instead of quoting it:

const shellChars = ";&|<>$`*?()[]{}~!\\"

// inside tokenize() case strings . ContainsRune ( shellChars , ch ) : return nil , fmt .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.