census: securelisten-337 overlay, PROPOSED (#337)
SecureUnixListen in internal/edge/purge_listen_linux.go is a new root-read unit: one Lstat of the socket it has just bound, so the bind fails closed if the file came out reachable by group or other. It runs in the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos) on sockets the agent itself serves, and makes no root decision. It is classified accepted legacy at J4 root-input, as pendingDirs.appeared (census-ruling-moves-offline-fixes) and its caller ListenControl. The overlay loads last, after moves-offline-precopy, re-pins the internal/edge envelope at 8fb4ccb1, and moves the seal to 265c6f07...798d. PROPOSED-securelisten-337; ruling asked on #280.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 files changed,
+23
−0
internal/provision/plan14_root_reads_test.go+17 −0internal/provision/testdata/plan14-root-reads-securelisten-337.tsv+6 −0
CI passed — run details
diff --git a/internal/provision/plan14_root_reads_test.go b/internal/provision/plan14_root_reads_test.go| index f99e6b6d8..377f899cf 100644 |
| --- a/internal/provision/plan14_root_reads_test.go |
| +++ b/internal/provision/plan14_root_reads_test.go |
| @@ -1083,6 +1083,23 @@ func TestPlan14RootReadCensus(t *testing.T) { |
| t.Fatal(err) |
| } |
| seal = "940ed1bba8d911e0f57af83ecac253c77ba5e14dad590258e0ee03ec98ccb818" |
| + // Census overlay securelisten-337 (amadan #337: edge.SecureUnixListen |
| + // makes its socket owner-only with fchmod before bind instead of setting |
| + // the process umask around it), loaded last, after |
| + // moves-offline-precopy. PROPOSED-securelisten-337, asked of the census |
| + // owner on #280. SecureUnixListen in purge_listen_linux.go is new |
| + // accepted legacy at J4 root-input (as pendingDirs.appeared and its |
| + // caller ListenControl): one Lstat of the socket the agent has just |
| + // bound for itself to serve. The internal/edge envelope is re-pinned. |
| + // One frozen declaration is added, so the seal moves; |
| + // moves-offline-precopy's is checked first. |
| + if errs := checkRootReadLegacy(inv, seal); len(errs) != 0 { |
| + t.Fatal(errs) |
| + } |
| + if err = loadRootReadInventory(filepath.Join(root, "internal/provision/testdata/plan14-root-reads-securelisten-337.tsv"), &inv, true); err != nil { |
| + t.Fatal(err) |
| + } |
| + seal = "265c6f074bbc271b92d78805e1c45a006878548ba17b68d30f51290a9a99798d" |
| errs := append(compareRootReads(got, inv), checkRootReadLegacy(inv, seal)...) |
| errs = append(errs, checkRootReadDeclarations(got, inv)...) |
| if len(errs) > 0 { |
diff --git a/internal/provision/testdata/plan14-root-reads-securelisten-337.tsv b/internal/provision/testdata/plan14-root-reads-securelisten-337.tsv| new file mode 100644 |
| index 000000000..3215d3e4f |
| --- /dev/null |
| +++ b/internal/provision/testdata/plan14-root-reads-securelisten-337.tsv |
| @@ -0,0 +1,6 @@ |
| +# Census overlay securelisten-337 (amadan #337: edge.SecureUnixListen makes its socket owner-only with fchmod before bind instead of setting the process umask to 0177 around the bind), loaded LAST, after moves-offline-precopy. PROPOSED-securelisten-337; ruling asked of the census owner on #280. |
| +# SecureUnixListen in internal/edge/purge_listen_linux.go (new file, //go:build linux) is a new unit with one read site: an Lstat of the socket it has just bound, to fail closed if group or other bits are set. It runs in the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos) on the sockets the agent itself is about to serve, and makes no root decision (it also refuses an empty or abstract @ path before bind, and the listener it returns removes its path on Close through SetUnlinkOnClose), so it is accepted legacy at J4 root-input, the disposition census-ruling-moves-offline-fixes gave pendingDirs.appeared (the agent's own Lstat of paths it made) and plan14-root-reads.tsv gives ListenControl, its caller. Its callers (listenLogs, listenCmdStream, ListenControl) are unchanged. The old umask implementation stays in purge_listen_unix.go for other unix systems (build tag now !windows && !linux); the census scans linux only and finds no read there. |
| +# Pinned at branch commit 8fb4ccb1 (Astra review: the listener returned is the *net.UnixListener itself with SetUnlinkOnClose(true); empty and abstract paths refused). One frozen declaration is added, so the seal moves; moves-offline-precopy's is checked first. The internal/edge envelope is re-pinned for the new file and the build tag change. |
| +@legacy b18f6dca9dd0e6bbc1a8967aa14c782e04bd104d1448fa2ccadc36a45ab8c3a9 internal/edge/purge_listen_linux.go SecureUnixListen legacy accepted-legacy accepted-legacy;rev3=PROPOSED-securelisten-337;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=root-input (J4, as pendingDirs.appeared under census-ruling-moves-offline-fixes and as ListenControl, its caller); new on Linux (amadan #337), replacing the umask bind, which set the process umask to 0177 and so stripped group and other bits from files other goroutines made meanwhile: one Lstat, which never follows a link, of the unix socket this call has just bound at socketPath for the agent itself to serve (an instance's purge control socket through ListenControl, a role's log socket through listenLogs, a cmd unit's stdout and stderr sockets through listenCmdStream), so the bind fails closed unless the file is a socket with no group or other bits (an empty or abstract @ path is refused before bind, since it has no file and so no permissions); it reads no file content, decides only whether this bind fails, and makes no root decision. startIsolated (claim mode, rolelaunch_root_linux.go) also calls listenLogs, as the agent and outside its l.Work.With step, before it asks root to run the reservation; root never opens or reads the socket file:Lstat@1490 2b037b125506ef5e89c9c2ffedca1474c23ecd30113eac3e7586fc41af6af6b6 |
| +internal/edge/purge_listen_linux.go SecureUnixListen legacy accepted-legacy accepted-legacy;rev3=PROPOSED-securelisten-337;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=root-input (J4, as pendingDirs.appeared under census-ruling-moves-offline-fixes and as ListenControl, its caller); new on Linux (amadan #337), replacing the umask bind, which set the process umask to 0177 and so stripped group and other bits from files other goroutines made meanwhile: one Lstat, which never follows a link, of the unix socket this call has just bound at socketPath for the agent itself to serve (an instance's purge control socket through ListenControl, a role's log socket through listenLogs, a cmd unit's stdout and stderr sockets through listenCmdStream), so the bind fails closed unless the file is a socket with no group or other bits (an empty or abstract @ path is refused before bind, since it has no file and so no permissions); it reads no file content, decides only whether this bind fails, and makes no root decision. startIsolated (claim mode, rolelaunch_root_linux.go) also calls listenLogs, as the agent and outside its l.Work.With step, before it asks root to run the reservation; root never opens or reads the socket file:Lstat@1490 2b037b125506ef5e89c9c2ffedca1474c23ecd30113eac3e7586fc41af6af6b6 |
| +@coverage internal/edge e8f21100bb0132adc26fb49e12143780e9fbcfecd33ea8e91b6ad7db89198021 |