Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added rule to detect LKM module injects using insmod used by rootkits for kernel hooking #1389

Closed
wants to merge 15 commits into from
Closed

Added rule to detect LKM module injects using insmod used by rootkits for kernel hooking #1389

wants to merge 15 commits into from

Conversation

josehelps
Copy link
Contributor

What type of PR is this?

/kind rule-create

Any specific area of the project related to this PR?

/area rules

What this PR does / why we need it:

This PR adds a new falco rule that looks for when insmod is called as part of a execve event. Injecting LKM modules on (post build) running production instances should be rare and is a common way for rootkits that employ kernel hooking to obfuscate themselves.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

This is my first PR please let me know if I missed anything 😇

Does this PR introduce a user-facing change?:

Yes new rule in falco_rules.yml

rule(Linux Kernel Module injection detected): adds a new rule that detects when a LKM module is inject using insmod typically used by rookits looking to obfuscate their behavior via kernel hooking. 

@poiana
Copy link
Contributor

poiana commented Sep 9, 2020

@d1vious: Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

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
Copy link
Contributor

poiana commented Sep 9, 2020

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

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
Copy link
Contributor

poiana commented Sep 9, 2020

Welcome @d1vious! It looks like this is your first PR to falcosecurity/falco 🎉

@poiana poiana added the size/XS label Sep 9, 2020
@josehelps josehelps changed the title New rule to detect LKM module injects using insmod used by rootkits for kernel hooking Added rule to detect LKM module injects using insmod used by rootkits for kernel hooking Sep 9, 2020
Signed-off-by: divious1 <josehelps@gmail.com>

Signed-off-by: divious1 <josehelps@gmail.com>
Signed-off-by: divious1 <josehelps@gmail.com>
@josehelps
Copy link
Contributor Author

Added a commit with the DOC sign-off, also:
/assign @mstemm

@leogr
Copy link
Member

leogr commented Sep 10, 2020

/cc @Kaizhe

@poiana poiana requested a review from Kaizhe September 10, 2020 07:39
@csschwe
Copy link
Contributor

csschwe commented Sep 10, 2020

It would be good to add user_loginuid=%user.loginuid to the rule so that we would know if a particular account started the process or not. example: user4 was logged in/hacked, elevated privledges and executed the command/rootkit.

Signed-off-by: divious1 <josehelps@gmail.com>
@josehelps
Copy link
Contributor Author

josehelps commented Sep 10, 2020

@csschwe Great suggestion 👍 , just updated the PR to include that in the output! This is a test I ran:

Sep 10 15:28:04 ip-172-31xxx falco: 15:28:04.191984695: Warning Linux Kernel Module injection using insmod detected (user=root user_loginuid=1000 parent_process=sudo module=rootkit.ko)

Signed-off-by: divious1 <josehelps@gmail.com>

Signed-off-by: divious1 <josehelps@gmail.com>
Signed-off-by: divious1 <josehelps@gmail.com>
…o into rule_lkm_injection_detected

Signed-off-by: divious1 <josehelps@gmail.com>
@poiana
Copy link
Contributor

poiana commented Sep 11, 2020

@d1vious: Adding label do-not-merge/contains-merge-commits because PR contains merge commits, which are not allowed in this repository.
Use git rebase to reapply your commits on top of the target branch. Detailed instructions for doing so can be found here.

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.

Signed-off-by: divious1 <josehelps@gmail.com>
Signed-off-by: divious1 <josehelps@gmail.com>
Signed-off-by: divious1 <josehelps@gmail.com>
@poiana
Copy link
Contributor

poiana commented Sep 11, 2020

Thanks for your pull request. Before we can look at it, you'll need to add a 'DCO signoff' to your commits.

📝 Please follow instructions in the contributing guide to update your commits with the DCO

Full details of the Developer Certificate of Origin can be found at developercertificate.org.

The list of commits missing DCO signoff:

  • 467bbe5 detect insmod trying to inject LKM modules
  • 539999c added user login id
  • 452ed29 detect insmod trying to inject LKM modules
  • 0cc1ba3 Merge branch 'rule_lkm_injection_detected' of github.com:d1vious/falco into rule_lkm_injection_detected
  • a27e25c Merge branch 'rule_lkm_injection_detected' of github.com:d1vious/falco into rule_lkm_injection_detected

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. I understand the commands that are listed here.

@leogr
Copy link
Member

leogr commented Sep 14, 2020

Hey @d1vious

First of all, thank you for your contribution!

I have noticed there're merge commits that are not allowed in this repo. Could you rebase and fix that?
Also, please ensure that all commits have been signed off.

@josehelps
Copy link
Contributor Author

josehelps commented Sep 14, 2020

@leogr I cleaned up this in #1401 closing this one for now.

@josehelps josehelps closed this Sep 14, 2020
@josehelps josehelps deleted the rule_lkm_injection_detected branch October 6, 2020 02:49
@josehelps josehelps mentioned this pull request Nov 6, 2020
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.

5 participants