Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,27 @@ uses [Semantic Versioning](https://semver.org/).

## [Unreleased]

### Breaking

- Unconfined agents are refused by default (#158, lockkit#133): lockkit
v0.20.0 (from v0.19.2). Every client reports in its `hello` whether it
runs confined (in a container, no host runtime socket, no Lock Family
state, a read-only `.lockfamily/`); the console refuses one that does
not, holds a group owning a runtime socket, or sends no report (an older
client), with `CodeUnconfined` (-32009). The launcher's `mcp`, lea's
agents and the own-container recipe run confined. Client and console
must be of the same version: an older console refuses the new `hello`,
and an older client is refused by the new console.

### Added

- The profile key `unconfined = true` serves agents that do not run
confined on a non-production profile: a loosening approved at the
console (it changes the policy fingerprint), a red banner, and
`"unconfined":true` on every audit record and `flags.unconfined` on
every hub ticket of the connection. It is refused on a production
profile; a managed `require_confined_agent = true` overrides it.

## [0.3.1] - 2026-11-14

A masking fix: lockkit v0.19.2.
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ account, where it could still read the logs directly):
`lox add` wires Claude Code; for Codex, Cursor or Gemini CLI, also run
`locklog init codex` (or `cursor`, `gemini`). On production, run the agent
in [lea](https://github.com/DavidGodefroid/lea) or in its own container
([docs/setup.md](docs/setup.md#the-own-container-recipe)).
([docs/setup.md](docs/setup.md#the-own-container-recipe)). The console
serves only agents that run confined, unless a non-production profile sets
`unconfined = true`
([docs/security-model.md](docs/security-model.md#confined-agents)).

## Highlights

Expand Down
21 changes: 21 additions & 0 deletions docs/security-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,27 @@ as the image's `agent` account, launched from your own account. Your agent
there can still read whatever your account can, so the trial is for
non-production data. The launcher's `mcp` refuses production profiles.

### Confined agents

Every locklog client reports in its `hello` whether it runs confined
(lockkit's `confine` check): in a container, with no host container
runtime socket it can reach, the Lock Family's state unreadable and the
project's `.lockfamily/` read-only. The console also refuses a client that
holds a group owning a runtime socket (`runtime_group`), and one too old to
send the report (`old_client`). Such an agent is refused (`-32009`,
`CodeUnconfined`), with the failed checks in the message, before any
method is served; the decision is taken again at every request.

The launcher's `mcp`, lea's agents and the
[own-container recipe](setup.md#the-own-container-recipe) run confined.
To serve an agent that does not, set `unconfined = true` on a
non-production profile: a loosening you approve at the console, which then
prints a red banner and marks every audit record (`"unconfined":true`) and
hub ticket (`flags.unconfined`) of the connection. A production profile
with `unconfined = true` is refused at load, and a managed
`require_confined_agent = true` refuses unconfined agents whatever the
profile says.

## The masking pipeline

Order, fixed, per record and per field:
Expand Down
5 changes: 4 additions & 1 deletion docs/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,10 @@ and every check; the exit status is 0 exactly when no check fails.
A host agent is the non-production trial: its MCP server refuses production
profiles (`E_PRODUCTION_HOST_AGENT`). For a production profile, run the
agent with lea, or in an image of its own, as a non-root user without sudo
that reaches the console only through its socket. Add this to the agent's
that reaches the console only through its socket. The console serves it
only when it runs confined: no container runtime socket mounted, no Lock
Family state, the project's `.lockfamily/` read-only
([security-model.md](security-model.md#confined-agents)). Add this to the agent's
Dockerfile, after its packages are installed, with the locklog image
pinned by digest (`docker buildx imagetools inspect
ghcr.io/davidgodefroid/locklog:<version>`):
Expand Down
1 change: 1 addition & 0 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ credentials = "ask" # typed at the console, never written to disk
| `strict` | `false` | Accepted and reviewed, but not applied yet (planned: every search and count becomes a ticket) |
| `prefilter` | `false` | Opt-in speed-up for non-production; reveals through latency how many records hold a clear substring, and turns off the `masked_failures` count of text searches (see The agent's tools) |
| `user_journals` | `false` | Also serve `user-*.journal` files |
| `unconfined` | `false` | Also serve an agent that does not run confined (see [security-model.md](security-model.md#confined-agents)): a loosening you approve at the console, shown by a red banner and recorded on every audit record and hub ticket of its connections; refused on production |
| `pseudonym_rotation` | `7d` | Epoch length (`session` or a duration; `never` is refused on production) |
| `pseudonym_max_age` | `30d` | How long a replaced epoch key is kept; older ones are deleted when the console opens the profile |
| `limits` | see Budgets | Per-call and rolling budgets |
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/DavidGodefroid/locklog
go 1.26.0

require (
github.com/DavidGodefroid/lockkit v0.19.2
github.com/DavidGodefroid/lockkit v0.20.0
github.com/klauspost/compress v1.20.3
github.com/pierrec/lz4/v4 v4.1.33
github.com/ulikunitz/xz v0.5.17
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk=
github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
github.com/DavidGodefroid/lockkit v0.19.2 h1:wKxHoV07NAzmclXnWEyba9nUMLod/jsyr2ifM1pV/5c=
github.com/DavidGodefroid/lockkit v0.19.2/go.mod h1:E4k9vDNBj9yEE3a9AQarl3PI8J6V4NtKxt28TZ/vB/A=
github.com/DavidGodefroid/lockkit v0.20.0 h1:xzrVnv2MtciWFbAtbtDJENQ67LGSDpv7q+NUWnzU7UA=
github.com/DavidGodefroid/lockkit v0.20.0/go.mod h1:E4k9vDNBj9yEE3a9AQarl3PI8J6V4NtKxt28TZ/vB/A=
github.com/danieljoos/wincred v1.2.3 h1:v7dZC2x32Ut3nEfRH+vhoZGvN72+dQ/snVXo/vMFLdQ=
github.com/danieljoos/wincred v1.2.3/go.mod h1:6qqX0WNrS4RzPZ1tnroDzq9kY3fu1KwE7MRLQK4X0bs=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand Down
2 changes: 2 additions & 0 deletions internal/config/policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ func TestDiffLoosens(t *testing.T) {
{name: "lookup free", approved: "[profiles.pp]\nlookup = \"approved\"\n", field: "lookup", loosens: true},
{name: "strict off", approved: "[profiles.pp]\nstrict = true\n", field: "strict", loosens: true},
{name: "prefilter on", cur: "[profiles.pp]\nprefilter = true\n", field: "prefilter", loosens: true},
{name: "unconfined on", cur: "[profiles.pp]\nunconfined = true\n", field: "unconfined", loosens: true},
{name: "unconfined off", approved: "[profiles.pp]\nunconfined = true\n", field: "unconfined", loosens: false},
{name: "user journals on", cur: "[profiles.pp]\nuser_journals = true\n", field: "user_journals", loosens: true},
{name: "rotation longer", cur: "[profiles.pp]\npseudonym_rotation = \"14d\"\n", field: "pseudonym_rotation", loosens: true},
{name: "rotation never", cur: "[profiles.pp]\npseudonym_rotation = \"never\"\n", field: "pseudonym_rotation", loosens: true},
Expand Down
6 changes: 5 additions & 1 deletion internal/config/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ type rawLimits struct {

type rawProfile struct {
Production bool `toml:"production"`
Unconfined bool `toml:"unconfined"`
Structured string `toml:"structured"`
Text string `toml:"text"`
Detectors []string `toml:"detectors"`
Expand Down Expand Up @@ -268,7 +269,7 @@ func buildProfile(name string, r rawProfile, detectorsSet bool) (Profile, error)
}
prod := r.Production
p := Profile{
Name: name, Base: kconfig.Base{Production: prod},
Name: name, Base: kconfig.Base{Production: prod, Unconfined: r.Unconfined},
Structured: r.Structured, Text: r.Text, Detectors: r.Detectors, Unmask: r.Unmask, Lookup: r.Lookup,
Strict: r.Strict, Prefilter: r.Prefilter, UserJournals: r.UserJournals,
}
Expand Down Expand Up @@ -310,6 +311,9 @@ func buildProfile(name string, r rawProfile, detectorsSet bool) (Profile, error)
}
p.Auto = rules.sparse()
}
if prod && p.Unconfined {
return Profile{}, errf("unconfined = true is refused on a production profile: an agent that does not run confined is never served on production")
}
if prod && p.Prefilter {
return Profile{}, errf("prefilter = true is refused on a production profile: with it, latency reveals how many records hold a clear substring")
}
Expand Down
24 changes: 22 additions & 2 deletions internal/config/profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,29 @@ func TestProductionRefusals(t *testing.T) {
prod := strings.ReplaceAll(fileSrc, "staging", "prod") + "[profiles.prod]\nproduction = true\n"
wantErr(t, prod+"prefilter = true\n", "prefilter = true is refused on a production profile")
wantErr(t, prod+`pseudonym_rotation = "never"`+"\n", `"never" is refused on a production profile`)
wantErr(t, prod+"unconfined = true\n", "unconfined = true is refused on a production profile")
wantErr(t, strings.ReplaceAll(fileSrc, "staging", "y")+"[profiles.y]\nproduction = true\n", "production profile needs a name")
// Non-production accepts both.
mustParse(t, fileSrc+"[profiles.staging]\nprefilter = true\npseudonym_rotation = \"never\"\n")
// Non-production accepts them.
mustParse(t, fileSrc+"[profiles.staging]\nprefilter = true\npseudonym_rotation = \"never\"\nunconfined = true\n")
}

// TestUnconfined (#158): unconfined = true is read into the profile's
// base and changes the policy fingerprint; unset, the fingerprint is the
// one before the key existed.
func TestUnconfined(t *testing.T) {
if p := mustParse(t, fileSrc)["staging"]; p.Unconfined {
t.Error("unconfined by default")
}
if p := mustParse(t, fileSrc+"[profiles.staging]\nunconfined = true\n")["staging"]; !p.Unconfined {
t.Error("unconfined = true not read")
}
none, off := policyOf(t, "", ""), policyOf(t, "[profiles.pp]\nunconfined = false\n", "")
if none.Fingerprint() != off.Fingerprint() {
t.Error("unconfined = false changes the fingerprint")
}
if on := policyOf(t, "[profiles.pp]\nunconfined = true\n", ""); on.Fingerprint() == none.Fingerprint() {
t.Error("unconfined = true keeps the fingerprint")
}
}

func TestProfileValues(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion internal/logconsole/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ func (p Policy) remote() (config.Source, bool) {
func (p Policy) Profile() console.Profile {
pr := p.Policy.Profile
cp := console.Profile{
Name: pr.Name, Production: pr.Production, Where: where(pr),
Name: pr.Name, Production: pr.Production, Unconfined: pr.Unconfined, Where: where(pr),
Credentials: console.CredentialsNone, IdleTimeout: pr.IdleTimeout, MaxSession: pr.MaxSession,
}
if s, ok := p.remote(); ok {
Expand Down
61 changes: 61 additions & 0 deletions test/hub/confined_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//go:build unix

package hub

import (
"context"
"errors"
"strings"
"testing"

"github.com/DavidGodefroid/lockkit/confine"
"github.com/DavidGodefroid/lockkit/console"
"github.com/DavidGodefroid/lockkit/ipc"
)

// TestConfinedAgent (#158, lockkit#133): over the console's socket, an
// agent that does not run confined is refused with CodeUnconfined, as is
// one whose hello carries no report (an older client); a confined one is
// served. No method is served before an accepted hello.
func TestConfinedAgent(t *testing.T) {
r := newRig(t, rigOpts{})
path := r.serveSocket()

early := dialRaw(t, path)
if err := early.Call(context.Background(), ipc.MethodStatus, nil, nil); err == nil ||
!strings.Contains(err.Error(), "hello first") {
t.Errorf("status before hello: %v, want refused (hello first)", err)
}

for name, conf := range map[string]*ipc.Confinement{
"unconfined": {Reasons: []string{confine.InContainer}},
"old client": nil,
} {
err := dialRaw(t, path).hello(conf)
var re *ipc.RPCError
if !errors.As(err, &re) || re.Code != ipc.CodeUnconfined {
t.Errorf("%s: hello = %v, want CodeUnconfined", name, err)
}
}

s := dialSock(t, path)
if err := s.Call(context.Background(), ipc.MethodStatus, nil, nil); err != nil {
t.Errorf("confined agent: status = %v", err)
}
}

// TestUnconfinedProfile: with unconfined = true on a non-production
// profile, an unconfined agent is served and the console says so.
func TestUnconfinedProfile(t *testing.T) {
r := newRig(t, rigOpts{extra: "unconfined = true"})
s := dialRaw(t, r.serveSocket())
if err := s.hello(&ipc.Confinement{Reasons: []string{confine.InContainer}}); err != nil {
t.Fatalf("hello: %v", err)
}
if err := s.Call(context.Background(), ipc.MethodStatus, nil, nil); err != nil {
t.Errorf("status: %v", err)
}
if !strings.Contains(r.io.output(), console.UnconfinedBanner) {
t.Errorf("no unconfined banner: %q", r.io.output())
}
}
19 changes: 19 additions & 0 deletions test/hub/leak_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,20 @@ type sockConn struct {
next int64
}

// dialSock dials the socket and says hello as a confined agent: the console
// serves a connection once its hello is accepted, and the test dials from
// the host (lockkit#133).
func dialSock(t *testing.T, path string) *sockConn {
t.Helper()
s := dialRaw(t, path)
if err := s.hello(&ipc.Confinement{Confined: true}); err != nil {
t.Fatal(err)
}
return s
}

// dialRaw dials the socket without a hello.
func dialRaw(t *testing.T, path string) *sockConn {
t.Helper()
c, err := net.Dial("unix", path)
if err != nil {
Expand All @@ -90,6 +103,12 @@ func dialSock(t *testing.T, path string) *sockConn {
return s
}

// hello opens the session with the confinement report conf.
func (s *sockConn) hello(conf *ipc.Confinement) error {
hp := ipc.HelloParams{ProtocolMajor: ipc.ProtocolMajor, Client: "locklog-test", Confinement: conf}
return s.Call(context.Background(), ipc.MethodHello, hp, nil)
}

func (s *sockConn) Call(ctx context.Context, method string, params, result any) error {
s.mu.Lock()
defer s.mu.Unlock()
Expand Down
Loading