Timeouts and denylist

A model that runs rm -rf / is a bad Tuesday. A string-match denylist is a weak tool, but it catches the infamous incantations cheaply. The hard timeout is what keeps a hung command from burning your afternoon.

agent/tools.go
go
var denylist = []string{
	"rm -rf /", "mkfs", ":(){:|:&};:", "shutdown", "reboot", "dd if=", "> /dev/sda",
}

for _, bad := range denylist {
	if strings.Contains(in.Cmd, bad) {
		return "", fmt.Errorf("run_bash: refused to run dangerous command containing %q", bad)
	}
}

Substring match is blunt. A determined model can work around it with shell tricks. That is fine for this workshop because the container boundary in the final phase is the real containment.

Matching exercise: Denylist vs allowlist

Loading practice…

Quiz: Quiz

Loading practice…