Repository navigation
Socket peer authentication on the in-app browser's cua socket (cua board #95) - #7
Merged
Merged
Conversation
…ted darwin-arm64 prebuild, scripts/build-peer-auth.sh, node-api-headers), the loader and policy in src/main/browser/cua/peer.ts with Acceptance 1 and 2, the extraResources entry
…nConnect, 0600, the session's engine as a process-instance root from every status, a 3 s wait for it, refusal destroyed unread with one log line, fail closed without the addon), inspect() gains peerModule and per-session refused, the MAWS_E2E trustRoot seam, Acceptance 3 and 4 unit tests, browser-cua scenes 6 (orphan refused) and 7 (a stub engine's child let in), the packaged peerModule assertion, the SIGUSR1 finding in the tracker's E13 row
… to the shell as arguments (the orphan's sh -c) or quoted as plugin-cli-stub.ts quotes them (the engine wrapper), never pasted inside quotes
…both sockets now enforce, the accepted residual in the spec's words, the SIGUSR1 and supervisor-token routes, the follow-ups that remain)
…isor install a no-op SIGUSR1 listener at their entries, so a same-user kill -USR1 opens no Node inspector (a route around the cua socket's peer check); e2e/sigusr1.spec.ts signals a main the case starts itself (dev or packaged), the packaged supervisor spec signals its supervisor
…able-sigusr1 (closed from exec on, the listener kept); both SIGUSR1 checks fail while 127.0.0.1:9229 is taken and reject any inspector line in main's stderr and the supervisor's host.log; the new tracker row names main's remaining startup window
# Conflicts: # docs/tech-debt-tracker.md
SSFSKIM
added a commit
that referenced
this pull request
Oct 10, 2026
…52 amendment (socket peer authentication by process ancestry), the P1 ledger's §6 clause for native/peer-auth and its §5 row's inert field, the charter's §19 line
SSFSKIM
added a commit
that referenced
this pull request
Oct 19, 2026
…act resolves as a handle, so a UUID-shaped handle reads back and collides as any handle does
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.
MAWS side of SSFSKIM/cua#95 (socket peer authentication). The spec lives in the cua repository:
docs/doperpowers/specs/2026-10-09-maws-socket-peer-auth-design.mdon SSFSKIM/cua branchspec/socket-peer-auth-95, opened as the companion cua PR. Merge this PR first. The cua PR merges after it.What changes
The per-session cua socket,
<userData>/browser/cua/<appSessionId>.sock, now checks every peer when it connects, before it reads a byte or sends the hello. It admits a peer only if two things hold. The peer runs as MAWS's user. And it descends from the session's engine process instance: thesession.statuspid, stored with its start time and re-checked every time. Before this change, any same-user process that named the path got every cua primitive.native/peer-auth/is a small N-API addon: one C file overLOCAL_PEERPID,getpeereidandproc_pidinfo. Its darwin-arm64 prebuild is committed, rebuilt byscripts/build-peer-auth.sh(pnpm build:peer-auth), and is byte-identical to cua's copy.electron-builder.ymlcopies it toResources/peer-auth.src/main/browser/cua/peer.tsholds the loader and the ancestry policy. A peer is refused for one of five reasons:module_unavailable,peer_unavailable,uid_mismatch,no_rootornot_descendant. The peer is read again after the ancestry walk, and a peer whose start time is later than the accept is refused.src/main/browser/cua/index.ts:pauseOnConnectand the socket file is 0600.inspect()gainspeerModuleand a per-sessionrefusedcount.src/main/browser/index.tsfeeds every known session'ssession.statuspid toengineProcess.trustRoot, exists only in main underMAWS_E2E=1. There is no IPC change and no version slot moves.e2e:browser-cuagains scene 6 (an orphaned same-user connector is refused before the hello) and scene 7 (a stub engine's own child is admitted on the realstatus.pidpath).e2e/smoke.spec.tsassertspeerModule === 'loaded'in the packaged app.Validation Evidence
Typecheck and lint:
pnpm typecheck && pnpm lintexit 0 (M2 executor; re-run by the whole-branch reviewer at 5178d7f).Unit tests:
pnpm testgave 11033 passed and 3 failed at 36cea2a. The failures are in the tracker's known-flakysrc/main/sessions/pause-take-over.pty.test.tsand in oneremote-runnergrandchild-cancel case. Both files pass alone, 27/27. Focused suites (peer,admission,cua/index,browser/index) gave 65/65 at the branch head.e2e browser-cua:
pnpm e2e:browser-cuaat 5178d7f gave7 passed (33.6s), exit 0. Scene 6 is "an orphaned connector is refused, the trusted host keeps its connection"; scene 7 is "the connector its engine starts hears the hello, on the engine's pid from the session's status".e2e browser:
pnpm e2e:browsergave 8 passed (M2).Packaged:
pnpm build:app && pnpm e2e:packagedat 5178d7f gave61 passed, 140 skipped (4.0m), exit 0. That run includes the smoke assertionpeerModule === 'loaded', anddist/mac-arm64/MAWS.app/Contents/Resources/peer-auth/peer-auth.nodeis present.Addon identity:
diffof the two repositories'native/peer-auth/peer-auth.cprints nothing, andcmpof the two prebuilds prints nothing. SHA-256 is 5c94d2b4… for the source and 9de92f2c… for the prebuild. A reviewer rebuilt the addon from source with the script's flags and got the same bytes.Reviews: each milestone was reviewed by
reviewer-mediumand the whole branch byreviewer-high, all on opus. Every verdict was correct. The two P3 findings are fixed: the shell quoting in the e2e scenes (8ab7258) and the PR-number placeholder in the tracker row (filled after this PR opened).After the SIGUSR1 follow-up and the merge of master 8f43ab9 (at 0a0214e, every e2e group run through the quiet wrapper,
MAWS_E2E_QUIET=1):pnpm testgave 11446 passed (at 0b6ea59); the only failure was the known pty flake, which passes alone.src/main/hostsplusdetached.test.tsgave 134/134.build:appexit 0.e2e:packagedgave 64 passed, 142 skipped, includingsigusr1.spec.e2e:supervisor:packagedgave 1 passed.e2e:browser-cuagave 7/7.Follow-up review: reviewer-medium on opus found a P2 (a false pass while 9229 is held) and a P3 (the supervisor's startup window). Both are fixed in 0a0214e.
SIGUSR1 in MAWS main and the supervisor (2026-10-10, the spec owner's decision)
The spec asked whether MAWS main answers SIGUSR1. It does: dev and packaged main, and the detached supervisor (the app binary run as Node), each opened an inspector on 127.0.0.1:9229. That route goes around this check entirely. This branch now closes it:
process.on('SIGUSR1', () => {})besideguardStdioinsrc/main/index.ts. The remaining window is process start until that line runs, after the module bodies are evaluated; main cannot take a flag.--disable-sigusr1(src/main/hosts/detached-transport.ts), so it is closed from exec, and the listener stays at its entry.e2e/sigusr1.spec.ts(dev and packaged) signals a main process the case launched itself, because Playwright's--inspect=0would mask the result.EnableNodeCliInspectArguments,EnableNodeOptionsEnvironmentVariableandOnlyLoadAppFromAsar.Tracker
The E13 row is unchanged from master, because P2-F edits rows by script. The amendment is one new dated row appended at the end of
docs/tech-debt-tracker.md, naming the row it amends (2026-10-08, E13, "Security note: the cookie-jar…"), cua board #95 and this PR.Residue
EnableNodeCliInspectArguments,EnableNodeOptionsEnvironmentVariableandOnlyLoadAppFromAsar. These are MAWS-wide decisions; the SIGUSR1 route itself is closed on this branch.src/engine-host/detached.ts). Any same-user process can read it and take over the supervisor and the session's engine. This is a MAWS-wide authorization question.--strict-mcp-configor narrower--setting-sourcesfor the engine launch. Configuration-injected hooks and MCP servers are admitted as engine descendants. Changing that is a charter decision against §4.1's launch line.remote-runnergrandchild-cancel flake. It failed once in a fullpnpm testrun under load and passes alone. It is not yet in the tracker.