Repository navigation
feat(confine): refuse unconfined agents by default (#133) - #205
Merged
Merged
Conversation
Every lock client reports in hello whether it runs confined (new package confine: in a container, no host runtime socket, no Lock Family state, a read-only .lockfamily). The console adds the kernel's record of the peer's groups (Cred.Groups, SO_PEERGROUPS / cr_groups) against the gids owning a runtime socket (--runtime-gids plus its own machine's) and decides: unconfined agents are refused with CodeUnconfined unless the profile sets unconfined = true (a loosening; never on production, never under managed require_confined_agent). Served unconfined connections get a red banner, unconfined:true on every audit record and flags.unconfined on their hub tickets. Safe-side choices: no method before an accepted hello on a socket connection; the decision is re-taken at every request; only runtime sockets whose group may write them give a runtime gid; unconfined is omitempty in Base and ticket.Flags. E2E: go test -tags e2e ./confine/... runs a real console and the client on the host and in docker run (CI step added). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 14, 2026
Closed
Bump lockkit to v0.20.0: refuse unconfined agents by default (lockkit#133)
DavidGodefroid/lockssh#35
Closed
A CI runner is in the docker group: Run added its gid to RuntimeGIDs and refused the tests' own clients as runtime_group. hostRuntimeGIDs is now a package variable the tests replace; TestRunRuntimeGIDs covers the union with --runtime-gids and the refusal of an invalid value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #133.
What
Unconfined agents are refused by default, with lea as the reference containment.
confine(new):confine.Check(env) Reportwith the four checks of the issue (in_container,no_host_runtime,no_family_state,lockfamily_read_only), an injectableEnvandRealEnv(). Fixed reason codes plusconfine.Text.confine.RuntimeGIDs()for a host console.HelloParams.Confinement,CodeUnconfined(-32009),Cred.Groups(LinuxSO_PEERGROUPS, macOScr_groups) andCred.HasGroup.confine.Check(confine.RealEnv()), computed once per process.hello(table in GUIDE §10, Confined agents),ServerConfig.RuntimeGIDs(=--runtime-gids∪ this machine's),Profile.Unconfined, refused at start on production (ErrConfig), refused under managedrequire_confined_agent, red banner at start and per unconfined connection,audit.Base.Unconfined/UnconfinedReasonsstamped on every record of the connection (viaStampPeer),ticket.Flags.Unconfinedon its hub tickets.Base.UnconfinedinDiffBase(on = loosening, off = tightening).Safe-side choices (agreed with the lead)
hello first). Test:TestMethodBeforeHelloRefused.unconfined, or a managed file that comes to require confinement, cuts an open unconfined connection. Test:TestPolicyFlipCutsUnconfined.root:root 0600gives none), plus--runtime-gids.--runtime-gidsis registered with the hub flags (HubOptions.RuntimeGIDs, a string soHubOptionsstays comparable), not counted byEnabled()so a policy-only console takes it; an invalid value refuses the start.no_host_runtimealso counts a runtime socket that is mounted but refuses for want of permission (EACCES): the socket being there is the misconfiguration, and it makes E2E (c) hold without--group-add.unconfinedisomitemptyinconfig.Baseandticket.Flags: existing policy fingerprints hold; an old hub (strict decoding) refuses only tickets that carry it (fail closed). Test:TestFlagsUnconfinedOldHub.Client-sent reason codes are filtered to known ones (never the console's own
runtime_group/old_client), at most eight.Tests
confine(each reason alone, all four → confined, nested rootless Podman allowed,/procdetection),ipc(TestPeerCredGroups, socketpair vsos.Getgroups()),console(decision table, start refusal on production, managed, runtime group, old client, hub ticket flag),config(fingerprint, loosening/tightening),ticket,auditfield set.go test -tags e2e ./confine/...(new CI step, Linux): real console on a unix socket, the client run (a) on the host → refused, (b) indocker runwith only the socket dir and a read-only.lockfamily→ served, writable.lockfamily→ refused, (c) with/var/run/docker.sock→ refusedno_host_runtime, and with--group-add <docker gid>→ plusruntime_group. Locally (nested rootless Podman,LOCKKIT_E2E_RUNTIME=podman LOCKKIT_E2E_RUN_ARGS=--userns=keep-id) (b) passes; (a) and (c) skip there and run in CI.Breaking
A lock bumping lockkit must ship its client and console of the same version: an older console refuses the new hello member, an older client is refused as
old_client. Lock tests that dial a console from the host need a confined report orunconfined = true.Follow-ups
Filed separately (lockhub
--runtime-gids/banner/e2e, one lockkit bump per lock), linked from #133.🤖 Generated with Claude Code