[PR #7147] fix(process): identify inaccessible Linux namespace peers #7673

Open
opened 2026-11-03 13:39:33 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/7147
Author: @dhruvac29
Created: 10/25/2026
Status: 🔄 Open

Base: main ← Head: fix/7143-linux-process-ownership


📝 Commits (2)

  • 4bbb66c fix(process): recognize permission-denied user namespace peers
  • 566379a fix(process): fall back to UID maps when namespace links are denied

📊 Changes

5 files changed (+255 additions, -14 deletions)

View changed files

📝 src/process/LinuxProcessStatus.test.ts (+14 -0)
📝 src/process/LinuxProcessStatus.ts (+44 -7)
📝 src/process/ProcessOwnership.procIdentity.test.ts (+134 -1)
📝 src/process/ProcessOwnership.ts (+5 -2)
📝 src/process/ProcessOwnershipObservation.ts (+58 -4)

📄 Description

Summary

Addresses #7143. This is a ready-for-review alternative to #7145 while contributors coordinate on one implementation. An unrelated Linux process in another user namespace can deny /proc/<pid>/environ with EACCES even when its UID matches REA's. When procfs provides evidence of a different user namespace, cleanup records that process as unverified instead of returning cleanup_incomplete.

Problem and expected behavior

The cleanup scan already exempts unrelated processes whose environments are known to be withheld. Its Linux identity reader did not recognize a different user namespace, so a sandboxed peer caused a hard cleanup failure.

Change and scope

Compare /proc/self/ns/user and /proc/<pid>/ns/user symlink identities for token-unreadable candidates when existing credential and non-dumpable checks do not explain the denial. Linux applies the same ptrace read check to environ and namespace symlink lookup (ptrace(2)), so a denied symlink lookup falls back to comparing readable uid_map files. Differing maps prove different namespaces; equal or unreadable maps remain unknown. A confirmed difference adds a user-namespace restriction. The scan uses it only for EACCES or EPERM, and only when the candidate has a stable, unrelated identity and relation. Same-namespace, unknown-namespace, other read failures, descendants, and owned-group members stay strict.

Compared with #7145, readable namespace identities distinguish separate namespaces even when their uid_map text is equal. The UID-map fallback covers the permission-denied symlink case. The permission-error check keeps an unrelated EIO from being reclassified as withheld.

Contribution scope: ordinary fix within existing process ownership boundaries; no new target authority.

Contract and boundary impact

  • Semantic owner and earliest changed stage: ProcessOwnershipObservation.ts reads native namespace identity; LinuxProcessStatus.ts derives the restriction; ProcessOwnership.ts applies the existing unrelated-process cleanup policy with the permission-error condition.
  • Contribution scope fit and linked maintainer decision: not applicable.
  • CLI and MCP/tool-catalog contract: no schema change.
  • Provider, bridge, target-format, or platform compatibility: Linux process cleanup only.
  • Evidence, artifact, provenance, or reconstruction contract: the existing unverified entry retains the original diagnostic.
  • Target selection, authority, upstream behavior, and cleanup details: no new signal authority; related and unresolved candidates remain failures.
  • Generated metadata, package, or installation impact: none.

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added: mocked procfs cleanup regressions for another namespace with EACCES and EPERM, denied symlink lookup with differing UID maps, equal or unreadable maps, same namespace, owned group, and EIO controls; UID-map parser cases.
  • Base reproduction: the new cleanup regression returned cleaned: false on origin/main before the fix; it returns cleaned: true with the original diagnostic under unverified after the fix.
  • User-visible CLI/MCP output: not run through a real provider.
  • Remaining proof gaps: no Linux user-namespace or Ghidra end-to-end run on this macOS host. If symlink lookup is denied and UID maps are equal or unreadable, this change deliberately cannot establish a different namespace and cleanup still fails closed. The compiled process-finalization acceptance file selected 12 tests, all skipped by its platform condition.

The regression covers the native observation and final ownership sweep. It does not establish real kernel behavior in the reporter's container.

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npm run test:local -- src/process/ProcessOwnership.procIdentity.test.ts src/process/ProcessOwnership.identity.test.ts src/process/ProcessOwnership.finalSweep.test.ts src/process/LinuxProcessStatus.test.ts — 71 passed, one platform skip.
  • npm run test:focused -- tests/acceptance/process/processFinalization.test.ts — build passed; 12 acceptance tests skipped on macOS.
  • npm run check — passed, including typecheck, formatting, standard and typed lint, module boundaries, architecture guards, and metadata checks.
  • git diff --check — passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: no real-provider or Linux namespace run here.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no extra signal authority. A process first observed only after leaving the owned group and entering another user namespace can remain unverified when its token is permission-denied; retained owned candidates still fail closed. This follows the existing policy for provably withheld unrelated processes.

Author readiness

Human owner: @dhruvac29

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/7147 **Author:** [@dhruvac29](https://github.com/dhruvac29) **Created:** 10/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/7143-linux-process-ownership` --- ### 📝 Commits (2) - [`4bbb66c`](https://github.com/morluto/rea/commit/4bbb66c649c65eb9069cfee2c22e35ce9bc80836) fix(process): recognize permission-denied user namespace peers - [`566379a`](https://github.com/morluto/rea/commit/566379af67a5d954a1ae697e7a149ae87ecd9a8c) fix(process): fall back to UID maps when namespace links are denied ### 📊 Changes **5 files changed** (+255 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `src/process/LinuxProcessStatus.test.ts` (+14 -0) 📝 `src/process/LinuxProcessStatus.ts` (+44 -7) 📝 `src/process/ProcessOwnership.procIdentity.test.ts` (+134 -1) 📝 `src/process/ProcessOwnership.ts` (+5 -2) 📝 `src/process/ProcessOwnershipObservation.ts` (+58 -4) </details> ### 📄 Description ## Summary Addresses #7143. This is a ready-for-review alternative to #7145 while contributors coordinate on one implementation. An unrelated Linux process in another user namespace can deny `/proc/<pid>/environ` with `EACCES` even when its UID matches REA's. When procfs provides evidence of a different user namespace, cleanup records that process as unverified instead of returning `cleanup_incomplete`. ## Problem and expected behavior The cleanup scan already exempts unrelated processes whose environments are known to be withheld. Its Linux identity reader did not recognize a different user namespace, so a sandboxed peer caused a hard cleanup failure. ## Change and scope Compare `/proc/self/ns/user` and `/proc/<pid>/ns/user` symlink identities for token-unreadable candidates when existing credential and non-dumpable checks do not explain the denial. Linux applies the same ptrace read check to `environ` and namespace symlink lookup ([ptrace(2)](https://man7.org/linux/man-pages/man2/ptrace.2.html)), so a denied symlink lookup falls back to comparing readable `uid_map` files. Differing maps prove different namespaces; equal or unreadable maps remain unknown. A confirmed difference adds a `user-namespace` restriction. The scan uses it only for `EACCES` or `EPERM`, and only when the candidate has a stable, unrelated identity and relation. Same-namespace, unknown-namespace, other read failures, descendants, and owned-group members stay strict. Compared with #7145, readable namespace identities distinguish separate namespaces even when their `uid_map` text is equal. The UID-map fallback covers the permission-denied symlink case. The permission-error check keeps an unrelated `EIO` from being reclassified as withheld. Contribution scope: ordinary fix within existing process ownership boundaries; no new target authority. ## Contract and boundary impact - Semantic owner and earliest changed stage: `ProcessOwnershipObservation.ts` reads native namespace identity; `LinuxProcessStatus.ts` derives the restriction; `ProcessOwnership.ts` applies the existing unrelated-process cleanup policy with the permission-error condition. - Contribution scope fit and linked maintainer decision: not applicable. - CLI and MCP/tool-catalog contract: no schema change. - Provider, bridge, target-format, or platform compatibility: Linux process cleanup only. - Evidence, artifact, provenance, or reconstruction contract: the existing `unverified` entry retains the original diagnostic. - Target selection, authority, upstream behavior, and cleanup details: no new signal authority; related and unresolved candidates remain failures. - Generated metadata, package, or installation impact: none. Expected effects: - [x] Read existing files or captured data. - [ ] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [ ] Change process memory, registers, files, or configuration. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [ ] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage - Tests added: mocked procfs cleanup regressions for another namespace with `EACCES` and `EPERM`, denied symlink lookup with differing UID maps, equal or unreadable maps, same namespace, owned group, and `EIO` controls; UID-map parser cases. - Base reproduction: the new cleanup regression returned `cleaned: false` on `origin/main` before the fix; it returns `cleaned: true` with the original diagnostic under `unverified` after the fix. - User-visible CLI/MCP output: not run through a real provider. - Remaining proof gaps: no Linux user-namespace or Ghidra end-to-end run on this macOS host. If symlink lookup is denied and UID maps are equal or unreadable, this change deliberately cannot establish a different namespace and cleanup still fails closed. The compiled process-finalization acceptance file selected 12 tests, all skipped by its platform condition. The regression covers the native observation and final ownership sweep. It does not establish real kernel behavior in the reporter's container. - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed - `npm run test:local -- src/process/ProcessOwnership.procIdentity.test.ts src/process/ProcessOwnership.identity.test.ts src/process/ProcessOwnership.finalSweep.test.ts src/process/LinuxProcessStatus.test.ts` — 71 passed, one platform skip. - `npm run test:focused -- tests/acceptance/process/processFinalization.test.ts` — build passed; 12 acceptance tests skipped on macOS. - `npm run check` — passed, including typecheck, formatting, standard and typed lint, module boundaries, architecture guards, and metadata checks. - `git diff --check` — passed. ## Compatibility, safety, and release - Breaking changes or migration steps: none. - Real Hopper/Ghidra, browser, or OS coverage: no real-provider or Linux namespace run here. - Package or release metadata impact: none. - Security, privacy, process, or containment review: no extra signal authority. A process first observed only after leaving the owned group and entering another user namespace can remain unverified when its token is permission-denied; retained owned candidates still fail closed. This follows the existing policy for provably withheld unrelated processes. ## Author readiness Human owner: @dhruvac29 - [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge - [ ] This PR addresses a concrete problem or an agreed enhancement. - [ ] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [ ] The PR has one focused outcome and the title follows `type(scope): outcome`. - [ ] Related issue is linked, or the reason for not linking one is stated above. - [ ] Tests cover changed observable behavior and meaningful failure paths. - [ ] Owning docs, contracts, and generated metadata are updated where needed. - [ ] User-visible CLI/MCP changes include representative output. - [ ] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#7673
No description provided.