Skip to content

Confirm policy and assurance level: close completion, history recall and forged confinement - #2

Merged
edimarlnx merged 5 commits into
mainfrom
fix/confirm-policy-and-assurance
Nov 13, 2026
Merged

edimarlnx merged 5 commits into
mainfrom
fix/confirm-policy-and-assurance

Conversation

@edimarlnx

Copy link
Copy Markdown
Contributor

Title: Confirm policy and assurance level: close completion, history recall and forged confinement

Fixes from an outside review of cotty (findings COT-1 to COT-5), one commit per area.

Confirm policy (COT-1, COT-3)

  • Under --policy confirm agents can no longer press Tab or BTab: shell completion runs project files (bash-completion runs ./configure --help and make -npq), so an agent that wrote such a file got code execution in your shell before any approval.
  • Up, Down, PgUp and PgDn are refused too: they recalled commands typed in private mode.
  • Agent text may not hold tabs, history expansion (! and ^, which magic-space expands without an Enter) or, outside a UTF-8 locale, bytes above 0x7f (readline reads them as Meta keys; M-C-e runs command substitutions).
  • Private mode cannot keep a line out of every shell's history, and under the auto policy an agent can always run history. README and docs/broker.md now say so where private mode is described, with the shells the confirm refusals cover (bash and zsh, default bindings).

Assurance level (COT-2)

  • An agent was reported confined for being in its own user namespace or in a cgroup named cotty-agent*, and strong once the guard had tagged it. Any process can give itself all three.
  • The broker now checks what a process cannot give itself: pid 1 of the agent's pid namespace is the broker's own root-owned cotty binary running cotty agent's init stage, and the agent is in that namespace's user namespace and mount view, with no_new_privs and a seccomp filter. Anything it cannot verify is weak. A guard tag only lifts a verified agent to strong; a self-tag never raises the level.
  • Docs state what the level still cannot tell: it describes the MCP server that connects, and a program that already has all your rights can start a confined MCP server for itself.

No Landlock (COT-4)

  • cotty agent refuses a kernel without Landlock unless given --allow-no-landlock, and sessions report such agents weak. Before, the agent started without Landlock and was reported confined.

Build (COT-5)

  • go.mod names Go 1.27.4; CI actions pinned by commit SHA; Dependabot for Go modules and actions. No BPF object reproducibility check: CI has no clang toolchain today.

Behaviour changes

  • Under --policy confirm, agents get policy_denied for Tab, Up, Down, PgUp, PgDn and for text with tabs, ! history references or ^.
  • Agents under the guard without cotty agent, peers whose pid the broker cannot see, and every agent while the cotty binary is writable by the user now read weak (and are refused by --require-confined).
  • cotty agent needs --allow-no-landlock on kernels without Landlock.

Tests

  • make check, make build, the cgo refusal check and govulncheck pass on Go 1.27.4.
  • New unit tests: confirm keys and text, locale detection, launch verification against a fake /proc tree (verified run and 15 forgeries), Landlock gate, doctor summary.
  • New lab rows in tests/attacks/broker.sh (unshare and tag-self forgeries against a --require-confined session). The lab matrix has not been run yet for this branch.

🤖 Generated with Claude Code

edimarlnx and others added 5 commits November 13, 2026 14:44
Under --policy confirm only the first Enter an agent types is held; every
byte before it reached the shell at once. Tab therefore ran shell
completion in the person's unconfined shell, and bash-completion runs
project files to complete (./configure --help, make -npq evaluating
$(shell ...)), so an agent that wrote such a file got code execution
with no approval (review COT-1). Up and Down recalled commands typed in
private mode onto the screen, where the agent could read them (COT-3).

The allowed keys are now decided per key from the default readline and
zle bindings (emacs and vi mode), with the reasoning in keys.go: Tab,
BTab, Up, Down, PgUp and PgDn are refused; text may no longer hold tabs,
history expansion (! and ^, which magic-space expands without an Enter
and which change the line that runs after approval) or, outside a UTF-8
locale, bytes above 0x7f (readline's convert-meta reads them as Meta
keys, and M-C-e runs command substitutions).

Private mode cannot keep a line out of every shell's history, and under
the auto policy an agent can always run `history`; README and
docs/broker.md now state that where private mode is described, with the
shells the confirm refusals cover.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
agentAssurance reported an agent `confined` for being in another user or
pid namespace, or in a cgroup named cotty-agent*, and `strong` once the
guard also had a tag for it. Any process can give itself all three
(`unshare -U`, a cgroup in its delegated subtree, the guard's tag-self),
so an unconfined agent could pass --require-confined and hide the
person's red warning (review COT-2).

The broker now checks what a process cannot give itself: pid 1 of the
peer's pid namespace must be the broker's own root-owned cotty binary
running cotty agent's init stage, and the peer must be in that
namespace's user namespace and mount view (a process that entered the
namespaces from outside is not), with no_new_privs and, where cotty has
a seccomp filter, one in place. Everything that cannot be verified is
weak: an invisible pid, unreadable /proc entries, a user-writable cotty
binary. A guard tag only lifts a verified agent to strong; a self-tag
never raises the level, so tag-self can stay open to everyone.

The docs say what the level still cannot tell: it describes the MCP
server process that connects, and a program that already has all of the
person's rights can start a confined MCP server for itself. The broker
matrix gains rows for unshare and tag-self forgeries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With Landlock absent from the kernel (ABI 0), ApplyLandlock returned an
error the exec stage ignored, and on a host without a display or bus the
launcher accepted ABI < 6 with no flag, so the agent ran with only the
mount view, seccomp and its cgroup while the session reported it
`confined` (review COT-4).

The launcher now refuses ABI 0 unless the person passes
--allow-no-landlock, and records that decision in the spec; the exec
stage goes on without Landlock only with it and stops on any other
Landlock failure. The broker treats a kernel without Landlock as no
confinement, so --require-confined refuses such agents, and cotty doctor
reports sessions as weak there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CI installs exactly the go line of go.mod, which said 1.26.0, so the
binaries were built with an old standard library; it now names 1.27.4,
the current release. The workflow's actions were pinned by tag and are
now pinned by commit SHA (checkout v7.0.1, setup-go v7.0.0) with
persist-credentials off, and a Dependabot config keeps Go modules and
actions current, matching the sibling repos (review COT-5).

No CI check that the committed BPF object matches bpf/guard.bpf.c is
added: CI has no clang/llvm toolchain today and the object is
regenerated by hand in a lab VM (make bpf).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TestShortHelperDoesNotStickLock and TestLateExecPromptDetected copied
the system's sleep to pinentry-tty to stand for a listed prompt program.
GitHub's ubuntu-latest moved to Ubuntu 26.04, where sleep is the uutils
multicall binary: it picks the utility from its own name, so the copy
exits at once as "pinentry-tty" and the lock never lights (CI run
43477142151; the last green run on main used ubuntu-24.04).

The copy is now of the test binary, which TestMain turns into sleep(1)
when started under that name. The assertions are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@edimarlnx
edimarlnx merged commit fcc990b into main Nov 13, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant