carlos / platform Public

caps: a granted doc_engine clears the tenant syscall filter

No conversion engine has run under carlos-app@'s new syscall filter, and
Chromium and V8 reach for calls outside @system-service (pkey_*, ptrace,
seccomp). The doc_engine drop-in now resets SystemCallFilter= and
SystemCallErrorNumber=, so an engine keeps the surface it had before.
PrivateIPC, ProtectControlGroups and SystemCallArchitectures stay.
TestOnlyDocEngineResetsTheSyscallFilter pins it to doc_engine alone.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 9717f50676ef24b58223c6ead94e39449315f8ce parent 8964fb4
4 files changed, +59 −1
  • internal/caps/render.go +12 −0
  • internal/caps/render_test.go +43 −0
  • internal/caps/testdata/gotenberg.service.conf +2 −0
  • internal/host/units/carlos-app@.service +2 −1
diff --git a/internal/caps/render.go b/internal/caps/render.go
index 1e2c58b2a..a780167c3 100644
--- a/internal/caps/render.go
+++ b/internal/caps/render.go
@@ -213,6 +213,18 @@ func RenderService(app string, s *Set, g Grants) ([]byte, error) {
"TasksMax="+docEngineTasksMax,
)
+ // The template's tenant syscall filter (sec review 2026-11-16) may
+ // add only what cannot break a tenant, and no conversion engine has
+ // been run under it: Chromium and V8 reach for calls outside
+ // @system-service (pkey_*, ptrace, seccomp). An empty assignment
+ // clears the list, allow and deny halves alike, so an engine keeps
+ // exactly the syscall surface it had before the filter; the error
+ // number goes back to its default with it. PrivateIPC=,
+ // ProtectControlGroups= and SystemCallArchitectures= stay: headless
+ // Chromium and LibreOffice use neither SysV/POSIX IPC across units
+ // nor cgroupfs writes, and run native.
+ lines = append(lines, "SystemCallFilter=", "SystemCallErrorNumber=")
+
// The fence that pays for all of the above. Empty assignment first
// resets the list — same documented systemd pattern the ExecStart
// reset uses — so these bytes are self-contained and do not depend on
diff --git a/internal/caps/render_test.go b/internal/caps/render_test.go
index 2e583c8ec..dc3ef7b5d 100644
--- a/internal/caps/render_test.go
+++ b/internal/caps/render_test.go
@@ -560,3 +560,46 @@ func TestCommandIdenticalToTemplateDefaultStillEmitsReset(t *testing.T) {
t.Fatalf("got %q, want %q", got, want)
}
}
+
+// TestOnlyDocEngineResetsTheSyscallFilter: carlos-app@ carries the tenant
+// syscall filter (sec review 2026-11-16), which may only add what cannot
+// break a tenant. A conversion engine (Chromium, LibreOffice) has not been
+// run under it, so a granted doc_engine clears it and keeps the behaviour
+// it had before the filter; no other capability touches it.
+func TestOnlyDocEngineResetsTheSyscallFilter(t *testing.T) {
+ syscallLines := func(b []byte) []string {
+ var out []string
+ for _, line := range strings.Split(string(b), "\n") {
+ if strings.HasPrefix(line, "SystemCall") {
+ out = append(out, line)
+ }
+ }
+ return out
+ }
+ engine, err := RenderService("gotenberg", gotenbergSet(t), gotenbergGrants())
+ if err != nil {
+ t.Fatalf("RenderService(gotenberg): %v", err)
+ }
+ if got, want := strings.Join(syscallLines(engine), "|"), "SystemCallFilter=|SystemCallErrorNumber="; got != want {
+ t.Errorf("doc_engine drop-in syscall lines = %q, want %q:\n%s", got, want, engine)
+ }
+
+ others := map[string]func() ([]byte, error){
+ "keymail": func() ([]byte, error) { return RenderService("keymail", keymailSet(t), keymailGrants()) },
+ "console": func() ([]byte, error) { return RenderService("console", consoleSet(t), consoleGrants()) },
+ "engine ungranted": func() ([]byte, error) { return RenderService("gotenberg", gotenbergSet(t), Grants{}) },
+ "children only": func() ([]byte, error) { return RenderService("app", &Set{V: 1, Children: true}, Grants{}) },
+ "runtime_dir only": func() ([]byte, error) { return RenderService("app", &Set{V: 1, RuntimeDir: "app"}, Grants{}) },
+ "engine grant alone": func() ([]byte, error) { return RenderService("app", &Set{V: 1, Command: "serve"}, Grants{DocEngine: true}) },
+ "socket": func() ([]byte, error) { return RenderSocket(keymailSet(t), keymailGrants()) },
+ }
+ for name, render := range others {
+ b, err := render()
+ if err != nil {
+ t.Fatalf("%s: %v", name, err)
+ }
+ if l := syscallLines(b); len(l) != 0 {
+ t.Errorf("%s renders %q; only a granted doc_engine resets the syscall filter", name, l)
+ }
+ }
+}
diff --git a/internal/caps/testdata/gotenberg.service.conf b/internal/caps/testdata/gotenberg.service.conf
index 9f3d48bc6..fbbb744ab 100644
--- a/internal/caps/testdata/gotenberg.service.conf
+++ b/internal/caps/testdata/gotenberg.service.conf
@@ -7,5 +7,7 @@ MemoryDenyWriteExecute=no
MemoryMax=4G
MemoryHigh=3680M
TasksMax=2048
+SystemCallFilter=
+SystemCallErrorNumber=
IPAddressDeny=
IPAddressDeny=0.0.0.0/8 10.0.0.0/8 100.64.0.0/10 169.254.0.0/16 169.254.169.254/32 172.16.0.0/12 192.0.0.0/24 192.168.0.0/16 198.18.0.0/15 224.0.0.0/4 240.0.0.0/4 64:ff9b::/96 fc00::/7 fd00:ec2::254/128 fe80::/10 fec0::/10 ff00::/8
diff --git a/internal/host/units/carlos-app@.service b/internal/host/units/carlos-app@.service
index b4ced2b1b..b50546f1d 100644
--- a/internal/host/units/carlos-app@.service
+++ b/internal/host/units/carlos-app@.service
@@ -91,7 +91,8 @@ SystemCallArchitectures=native
# The tenant syscall surface (#527 Q5), as on carlos-instance@: systemd's
# baseline for an ordinary service, less io_uring, the kernel keyring and
# userfaultfd. A refused call answers ENOSYS, so runtimes take the fallback
-# they already have rather than being killed.
+# they already have rather than being killed. A granted doc_engine's
+# drop-in clears it (internal/caps/render.go): no engine has run under it.
SystemCallFilter=@system-service
SystemCallFilter=~@keyring io_uring_setup io_uring_enter io_uring_register userfaultfd
SystemCallErrorNumber=ENOSYS