Skip to content

Enforce pids_max in macOS sessions, and warn on limits macOS ignores - #94

Merged
ihavespoons merged 1 commit into
mainfrom
macos-resource-limits
Nov 10, 2026
Merged

ihavespoons merged 1 commit into
mainfrom
macos-resource-limits

Conversation

@ihavespoons

Copy link
Copy Markdown
Contributor

Part of SECENG-308, phase 3 of docs/plans/2026-10-29-macos-enforcement-gaps.md.

macOS did not enforce any resource_limits field under wrap.

What changed

  • The policy snapshot carries pids_max.
  • The extension denies an exec in a session that holds more processes than pids_max. It sends an execve event with rule resource-limit-pids-max. ES has no AUTH event for fork, so a plain fork still works.
  • On macOS, agentmon policy validate warns for max_memory_mb, memory_swap_max_mb, cpu_quota_percent, the disk and network rates, and the fork gap in pids_max.

The plan also named RLIMIT_NOFILE, RLIMIT_CPU and RLIMIT_FSIZE. The policy has no field for them, so this PR does not add them.

Verification

  • go test -tags nofuse ./internal/cli/ ./internal/platform/darwin/policysock/ passes. Lint reports 0 issues.
  • Build 1683, notarized and installed: scripts/test-macos-pids-max.sh passes 2/2. /bin/echo runs, is denied with 520 forked children against pids_max: 500, and runs again after they exit.
  • scripts/test-macos-wrap-python.sh 3/3 and scripts/test-macos-wrap-session-reuse.sh 4/4 pass on the same build.

🤖 Generated with Claude Code

The snapshot now carries resource_limits.pids_max. The extension denies an
exec in a session that holds more processes than pids_max, and sends an
execve event with rule resource-limit-pids-max. ES has no AUTH event for
fork, so a plain fork still works.

On macOS, `agentmon policy validate` now warns for max_memory_mb,
memory_swap_max_mb, cpu_quota_percent, the disk and network rates, and
the fork gap in pids_max.

scripts/test-macos-pids-max.sh is the hardware test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ihavespoons
ihavespoons merged commit 6299ed4 into main Nov 10, 2026
8 checks passed
@ihavespoons
ihavespoons deleted the macos-resource-limits branch November 10, 2026 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant