update(falco_rules): exclude systemd helpers from Read sensitive file… - #374
update(falco_rules): exclude systemd helpers from Read sensitive file…#374mayanksekhar 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 🎉 |
|
We need this change as well, got the same issue |
|
hello - will this one be taken? we are running into the same issue |
|
Noticed the Yamllint check is failing, the errors are pre-existing across all three rule files (line-length, indentation, trailing spaces) unrelated to this change, going back to line 20. Confirmed my added block doesn't introduce any new violations. Happy to look into a separate cleanup PR if that'd be useful, but wanted to flag it's not something introduced here. |
/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?: