update(falco_rules): exclude systemd helpers from Read sensitive file…#374
Open
mayanksekhar wants to merge 1 commit into
Open
update(falco_rules): exclude systemd helpers from Read sensitive file…#374mayanksekhar wants to merge 1 commit into
mayanksekhar wants to merge 1 commit into
Conversation
… untrusted systemd spawns short-lived helper processes that legitimately read sensitive account and PAM files during normal operation. Because these helpers report a bare-number or comm-truncated proc.name, they cannot be matched by name, so the existing systemd exclusions in the rule do not cover them and the rule fires a false positive on every affected host. This adds a systemd_sensitive_file_readers macro that matches on proc.exepath (kernel-resolved and unspoofable) anchored to the expected systemd parent, covering two observed helpers: - systemd-executor (unit re-exec deserialize handoff) - systemd-userwork (userdb User/Group Record Lookup worker) The systemd-userwork case was reproduced locally on systemd 259 / Falco 0.44.1 and verified by deterministic capture replay. The systemd-executor case is reported in falcosecurity#291 and falcosecurity/falco#3480. Signed-off-by: MayankSekhar <mayankshekharsingh@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mayanksekhar The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Welcome @mayanksekhar! It looks like this is your first PR to falcosecurity/rules 🎉 |
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.
/kind bug
/area rules
/area maturity-stable
What this PR does / why we need it:
The
Read sensitive file untrustedrule (maturity_stable) fires false positives on modern systemd hosts when systemd's own short-lived helper processes read account/PAM files during normal operation.The rule already attempts to exclude systemd, but those exclusions match on
proc.name, which is unusable for these helpers: it is a bare file-descriptor number (e.g.16) forsystemd-executor, and comm-truncated to 15 chars (systemd-userwor) forsystemd-userwork. The existing name-based exclusions therefore never match, and the rule alerts.This adds a
systemd_sensitive_file_readersmacro that matches onproc.exepathinstead.proc.exepathis kernel-resolved and cannot be influenced byargv[0], and each entry is anchored to its expected systemd parent so the exclusion stays tight rather than blanket-trusting/usr/lib/systemd/*. Two helpers are covered:systemd-executor— unit (re)exec deserialize handoffsystemd-userwork— userdb (User/Group Record Lookup) query workerPer the repo's versioning guidelines this is a backward-compatible patch change (adding an exception to an existing rule; no
required_engine_versionchange).Which issue(s) this PR fixes:
Fixes #291
Related: falcosecurity/falco#3480
Special notes for your reviewer:
The
systemd-userworkvariant was reproduced locally on systemd 259 / Falco 0.44.1 and verified by deterministic capture replay: replaying the same.scapagainst the rule produces 2Read sensitive file untrustedalerts before this change and 0 after, while a genuine untrusted read (cat /etc/shadow) still fires.I could not reproduce the
systemd-executorvariant on my systemd version, but it is documented with full field dumps in #291 (thanks to @marwinski, who identified thatproc.namematching was the blocker) and in falcosecurity/falco#3480.If you'd prefer to land this incrementally, I'm happy to scope it down to
systemd-userworkonly — the case I reproduced directly — and tracksystemd-executorseparately.Does this PR introduce a user-facing change?: