Skip to content

wip: add is_exe_writable flag to execve - #16

Closed
luca-sd wants to merge 3 commits into
falcosecurity:masterfrom
luca-sd:is_exe_writable
Closed

luca-sd wants to merge 3 commits into
falcosecurity:masterfrom
luca-sd:is_exe_writable

Conversation

@luca-sd

@luca-sd luca-sd commented Mar 10, 2021 •

Copy link
Copy Markdown

What type of PR is this?

Uncomment one (or more) /kind <> lines:

/kind feature

Any specific area of the project related to this PR?

Uncomment one (or more) /area <> lines:

/area driver-kmod

/area driver-ebpf

/area libscap

What this PR does / why we need it:

This PR adds the is_exe_writable flag to execve events, and tracks it as a flag in the process structure. The flag is set if the user running the process has ownership or write access to the executable file.
This flag can be meaningful when the user in question is not root (to be more precise, root with CAP_FOWNER). In some scenarios it is interesting to analyze whether or not the regular user that spawned a process wrote its own binary. Sometimes this behavior is not expected and so I feel it is worth having this flag so that it can be used in Falco rules to catch these cases.

Special notes for your reviewer:

Alas, the bpf probe part of this PR is not currently working (verifier fails on the compiled probe). It sounds like this can get better after some improvements to the BPF probe in this PR #5 .

Does this PR introduce a user-facing change?:

new: A new flag, is_exe_writable, is available for execve events. This tracks whether or not the user invoking the systemcall has ownership or write access to the executable file used.

Luca Guerra added 3 commits March 10, 2021 13:26
Signed-off-by: Luca Guerra <luca.guerra@sysdig.com>
Signed-off-by: Luca Guerra <luca.guerra@sysdig.com>
Signed-off-by: Luca Guerra <luca.guerra@sysdig.com>
@poiana

poiana commented Mar 10, 2021

Copy link
Copy Markdown
Contributor

Welcome @luca-sd! It looks like this is your first PR to falcosecurity/libs 🎉

@poiana

poiana commented Mar 10, 2021

Copy link
Copy Markdown
Contributor

Hi @luca-sd. Thanks for your PR.

I'm waiting for a falcosecurity member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@poiana

poiana commented Mar 10, 2021

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please assign leogr after the PR has been reviewed.
You can assign the PR to them by writing /assign @leogr in a comment when ready.

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

@leogr

leogr commented Mar 19, 2021

Copy link
Copy Markdown
Member

/ok-to-test

@fntlnz

fntlnz commented Mar 22, 2021 •

Copy link
Copy Markdown
Contributor

Waiting for #22 for the verifier fixes since #5 was closed

@fntlnz

fntlnz commented Mar 26, 2021

Copy link
Copy Markdown
Contributor

@luca-sd you can probably rebase this and test again for bpf now that the fixes for clang 10 are in.

@fntlnz fntlnz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't approve yet because of the comment I posted that needs a fix.

This is one of the greatest first-time contributions I've seen here, well done @luca-sd .

Comment thread driver/bpf/fillers.h
struct inode *inode = _READ(exe_file->f_inode);
if (inode) {
// XXX if I remove the following two lines this compiles and runs under clang-7
is_exe_writable |= (inode_permission(inode, MAY_WRITE) == 0);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@luca-sd - as discussed privately we can't do this kind of call in this context. I'll be happy to help in getting that rewritten for eBPF or for another review once that is done.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes sense, thanks for checking. I'll find some time to see if I can come up with an idea to do this in BPF and thanks a lot for the offer to help, I'm going to need it 😄

@poiana

poiana commented Jun 28, 2021

Copy link
Copy Markdown
Contributor

Issues go stale after 90d of inactivity.

Mark the issue as fresh with /remove-lifecycle stale.

Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Provide feedback via https://github.com/falcosecurity/community.

/lifecycle stale

@poiana

poiana commented Aug 9, 2021

Copy link
Copy Markdown
Contributor

Stale issues rot after 30d of inactivity.

Mark the issue as fresh with /remove-lifecycle rotten.

Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Provide feedback via https://github.com/falcosecurity/community.

/lifecycle rotten

@poiana

poiana commented Sep 8, 2021

Copy link
Copy Markdown
Contributor

Rotten issues close after 30d of inactivity.

Reopen the issue with /reopen.

Mark the issue as fresh with /remove-lifecycle rotten.

Provide feedback via https://github.com/falcosecurity/community.
/close

@poiana

poiana commented Sep 8, 2021

Copy link
Copy Markdown
Contributor

@poiana: Closed this PR.

Details

In response to this:

Rotten issues close after 30d of inactivity.

Reopen the issue with /reopen.

Mark the issue as fresh with /remove-lifecycle rotten.

Provide feedback via https://github.com/falcosecurity/community.
/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@poiana poiana closed this Sep 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants