Skip to content

fix(sandbox): replace user.uid with user.loginuid in SUID privilege escalation rules#356

Open
KrakoX wants to merge 1 commit intofalcosecurity:mainfrom
KrakoX:fix/suid-uid-loginuid-sandbox-rules
Open

fix(sandbox): replace user.uid with user.loginuid in SUID privilege escalation rules#356
KrakoX wants to merge 1 commit intofalcosecurity:mainfrom
KrakoX:fix/suid-uid-loginuid-sandbox-rules

Conversation

@KrakoX
Copy link

@KrakoX KrakoX commented Mar 19, 2026

What type of PR is this?

/kind bug

Any specific area of the project related to this PR?

/area rules

Proposed rule maturity level

/area maturity-sandbox

What this PR does / why we need it:

sudo and pkexec are SUID root binaries. Falco's user.uid field reflects the effective UID, which the kernel sets to 0 when any user executes a SUID binary. The condition user.uid != 0 is therefore permanently false for these binaries.

Fix: replace user.uid != 0 with user.loginuid != 0.

user.loginuid is the Linux kernel audit UID (loginuid), set by PAM at session login and preserved through SUID execution. It correctly identifies the actual caller:

Scenario user.uid user.loginuid Old condition New condition
non-root on host runs sudo/pkexec 0 (SUID) > 0 false — miss true — fires
root on host runs sudo/pkexec 0 (SUID) 0 false — miss false — correct
any user in container runs sudo/pkexec 0 (SUID) -1 (no PAM) false — miss true — fires

Verified empirically on Ubuntu 22.04 and 24.04 / kernel 6.8.0 / Falco 0.43.0 via debug rule capturing live user.uid and user.loginuid field values during pkexec and sudo executions.

@poiana
Copy link

poiana commented Mar 19, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: KrakoX
Once this PR has been reviewed and has the lgtm label, please assign darryk10 for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@poiana poiana requested review from Kaizhe and loresuso March 19, 2026 12:46
@poiana
Copy link

poiana commented Mar 19, 2026

Welcome @KrakoX! It looks like this is your first PR to falcosecurity/rules 🎉

@poiana poiana added the size/XS label Mar 19, 2026
…scalation rules

sudo and pkexec are SUID root binaries. Falco's user.uid reflects the
effective UID, which is always 0 for SUID binaries regardless of who
invokes them. The condition user.uid != 0 is therefore always false and
the rules never fire.

Replace with user.loginuid != 0. The loginuid (kernel audit UID) is set
by PAM at session login and preserved through SUID execution. This fires
for non-root users on host (loginuid > 0), is silent for root on host
(loginuid = 0), and fires for all container processes (loginuid = -1,
no PAM session) — covering the primary threat surface.

Affects:
- Sudo Potential Privilege Escalation (CVE-2021-3156)
- Polkit Local Privilege Escalation Vulnerability (CVE-2021-4034)

Signed-off-by: KrakoX <krakox.entryway360@passmail.net>
@KrakoX KrakoX force-pushed the fix/suid-uid-loginuid-sandbox-rules branch from eedca76 to 589eafa Compare March 19, 2026 12:49
@KrakoX KrakoX marked this pull request as ready for review March 19, 2026 12:49
@poiana poiana requested a review from leodido March 19, 2026 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/maturity-sandbox See the Rules Maturity Framework area/rules dco-signoff: yes kind/bug Something isn't working size/XS

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants