fix(clean): never delete endpoint-security agent caches - #1154
Merged
Conversation
ImL1s
force-pushed
the
fix/edr-cache-tamper-protection
branch
2 times, most recently
from
June 24, 2026 11:56
b7b0136 to
e88ff0b
Compare
ImL1s
force-pushed
the
fix/edr-cache-tamper-protection
branch
from
June 24, 2026 12:29
e88ff0b to
e3f7c07
Compare
mo clean and mo analyze deleted rebuildable Metal/GPU shader caches,
code-signature clones, and old user-owned files under each app's per-user
Darwin folder (/private/var/folders/.../{C,X,T}). For CrowdStrike Falcon this
removed files inside the sensor's own container, tripping its tamper protection
(IOA MacFalconSensorTamper, MITRE T1562.001), which corporate security reports
as malware.
Add ENDPOINT_SECURITY_BUNDLE_PREFIXES (app_protection_data.sh) listing EDR/MDM
vendor bundle ids (CrowdStrike, SentinelOne, ESET, Jamf, GlobalProtect, Cisco
Secure Client; mirrors OFFICIAL_UNINSTALLER_RULES) and the predicate
is_endpoint_security_cache_path() matching them under /private/var/folders (or
the /var/folders symlink form). Enforce it at every deletion path:
- validate_path_for_deletion() rejects these paths before the var/folders
allowlist, so all safe_remove / safe_sudo_remove callers are covered, not
just the cleanup sweeps.
- The clean sweeps (GPU cache, code_sign_clone, Darwin user runtime) and
should_protect_path() also pre-check it.
- mo analyze (Go) refuses to move them to Trash via validateTrashTarget().
Protection-only: rebuildable caches for every other app are still reclaimed.
Tests: predicate + validate_path_for_deletion coverage in
core_safe_functions.bats, skip-EDR regressions for the system sweeps
(clean_system_maintenance.bats) and user runtime cleanup (clean_user_core.bats),
and analyze Trash protection (cmd/analyze/delete_test.go).
ImL1s
force-pushed
the
fix/edr-cache-tamper-protection
branch
from
June 24, 2026 13:06
e3f7c07 to
f042601
Compare
Owner
|
@ImL1s thank you for the detailed fix and context. I added one test update before merging:
Merged to main in 1eb04fe. This will be included in the next release; users can try the main build via mo update --nightly after Nightly refreshes. |
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.
Summary
mo cleanandmo analyzedeleted rebuildable GPU/Metal shader caches, code-signature clones, and old user-owned files under every app's per-user Darwin folder (/private/var/folders/.../C,.../X,.../T). On a Mac managed with CrowdStrike Falcon this removed files inside the Falcon sensor's own cache container (com.crowdstrike.falcon.App/com.apple.metalfe), which tripped the sensor's tamper protection (IOAMacFalconSensorTamper, MITRE T1562.001) and was flagged as malware by the company's security team.The fix follows the repo's data/logic split and protects every deletion path:
app_protection_data.sh: newENDPOINT_SECURITY_BUNDLE_PREFIXESarray of endpoint-security / EDR / MDM vendor bundle ids (CrowdStrike, SentinelOne, ESET, Jamf, GlobalProtect, Cisco Secure Client), mirroring the vendors already inOFFICIAL_UNINSTALLER_RULES.app_protection.sh:is_endpoint_security_cache_path()iterates the array and matches a vendor id under/private/var/folders(or the/var/folderssymlink form).file_ops.sh:validate_path_for_deletion()rejects these paths before its/private/var/foldersallowlist — so everysafe_remove/safe_sudo_removecaller is covered, not only the cleanup sweeps.lib/clean/system.sh(GPU-cache +code_sign_clonesweeps),lib/clean/user.sh(_clean_darwin_user_runtime_dir), andshould_protect_path()also pre-check the predicate.cmd/analyze/delete.go:mo analyzerefuses to move these paths to Trash (validateTrashTarget/isProtectedAnalyzeDeletePath), mirroring the shell predicate.The match is protection-only: rebuildable caches for all other apps are still reclaimed.
Safety Review
clean(system + user cleanup) andanalyze(interactive Trash) deletion behavior.var/folders, enforced centrally invalidate_path_for_deletion()so no future caller can regress. It does not broaden any deletion matcher, remove an existing protection, or change sudo / Trash / dry-run / operation-logging behavior./private/var/folders/*and/var/folders/*(an unrelated.../var/folders/...path cannot match) and is protection-only: the worst case is leaving a few MB of a security agent's rebuildable cache unreclaimed; it can never cause an unwanted deletion. Non-security products (e.g.com.cisco.webex) are not matched.Tests
./scripts/check.sh(shfmt, shellcheck, go vet, syntax) andMOLE_TEST_NO_AUTH=1 ./scripts/test.sh(full bats + Go): pass.core_safe_functions.bats: predicate matches every vendor acrossC//X//T/, rejects normal apps /com.cisco.webex/ non-Darwin.../var/folders/.../ non-var/folderspaths;validate_path_for_deletionrejects the Falcon path but allows a normal Darwin cache shard.clean_system_maintenance.bats: GPU-cache andcode_sign_clonesweeps skip EDR paths while reclaiming a normal app's cache.clean_user_core.bats:_clean_darwin_user_runtime_dirskips an EDR agent's user-owned cache while reclaiming a normal old cache file.cmd/analyze/delete_test.go:validateTrashTargetrejects EDR Darwin caches and allows a normal Darwin cache.Safety-related changes
ENDPOINT_SECURITY_BUNDLE_PREFIXES(data) +is_endpoint_security_cache_path()(shell) + a Go mirror, enforced atvalidate_path_for_deletion()(covers all shell deletion callers), the threecleansweeps,should_protect_path(), andmo analyze's Trash validation. Protection-only: no new deletion surface, no change to sudo / Trash / dry-run / logging.