Skip to content

test(observer): slice 7e macOS DYLD_INSERT_LIBRARIES integration test (#551) - #569

Merged
zackees merged 2 commits into
mainfrom
hooks
Jun 22, 2026
Merged

zackees merged 2 commits into
mainfrom
hooks

Conversation

@zackees

@zackees zackees commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Summary

Mirror of slice 7d (Linux) for macOS. Builds the slice 5 interposer dylib on demand, writes a probe file in a tempdir, spawns `/bin/cat probe.txt` with DYLD_INSERT_LIBRARIES set via slice 6e's `inject_via_env`, captures stderr on a background thread, asserts that a RPO_HOOK line with the probe path appears.

SIP / hardened-runtime caveat

macOS refuses DYLD_INSERT_LIBRARIES against library-validated binaries — includes most system binaries on recent macOS. When this happens (no RPO_HOOK lines at all), the test gracefully skips the detour assertion and logs the captured stderr. Matches the snapshot tier's posture from #539: the boundary is "binaries the user owns and library validation isn't enforced for."

Verification

  • Compile-checked on Windows host (`#[cfg(target_os = "macos")]`-gated, so the body's cfg-skip).
  • Runtime verification happens when this lands on CI's macOS runners.

Where this leaves #551

With #568 + this PR landed, all three tier-1 platforms have at least one end-to-end integration test exercising the inject + detour pipeline.

🤖 Generated with Claude Code

zackees and others added 2 commits June 22, 2026 06:34
Mirror of slice 7a (Windows) but driven by LD_PRELOAD instead of
CreateRemoteThread. Linux doesn't need an injection vehicle: the
dynamic linker reads the env var at process startup and loads the
interposer .so before main(), so the slice 4 symbol shadows
(open/openat/close/write/unlink/rename) are in effect for every
libc call from the spawned process and its descendants.

Test scenario:
- Build the slice 4 interposer cdylib on demand via cargo.
- Write a probe file in a tempdir.
- Spawn `sh -c "cat probe.txt"` with LD_PRELOAD set to the
  interposer via slice 6e's inject_via_env().
- Capture child stderr on a background thread.
- Assert a RPO_HOOK line appears AND contains the probe path —
  stronger assertion than slice 7a/7b's Windows version (which
  can only assert "some RPO_HOOK fires", pending slice 7c's
  investigation of why cmd's `type` doesn't go through
  kernel32!CreateFileW).

Verified in docker rust:1.85-slim:
  test interposer_so_fires_rpo_hook_via_ld_preload ... ok
  test result: ok. 1 passed; 0 failed; 0 ignored.

Closes the Linux half of the slice 7 acceptance criterion.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…#551)

Mirror of slice 7d (Linux) for macOS. Same shape — the dynamic
linker (dyld) reads DYLD_INSERT_LIBRARIES at process startup and
loads the slice 5 interposer dylib before main(), so the
open/openat/close/write/unlink/unlinkat/rename/renameat shadows
are in effect for every libc call from the spawned process and
descendants.

Test scenario:
- Build the slice 5 interposer dylib on demand via cargo.
- Write a probe file in a tempdir.
- Spawn `/bin/cat probe.txt` with DYLD_INSERT_LIBRARIES set via
  slice 6e's inject_via_env().
- Capture child stderr on a background thread.
- Assert a RPO_HOOK line with the probe path appears.

SIP / hardened-runtime caveat: macOS refuses to honor
DYLD_INSERT_LIBRARIES against library-validated binaries —
includes most system binaries on recent macOS. When that
happens, the test gracefully skips the detour assertion and
logs the captured stderr for diagnosis. Matches the snapshot
tier's posture from #539 (the boundary is "binaries the user
owns AND library validation isn't enforced for").

Compile-checked on Windows host (cfg-gated to macOS). Runtime
verification will happen on CI when this lands.

Closes the macOS half of the slice 7 acceptance criterion.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
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