-
Notifications
You must be signed in to change notification settings - Fork 376
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
policylibrary: add a catch all for setuid root and suid execution #1706
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
246 changes: 246 additions & 0 deletions
246
examples/policylibrary/privileges/privileges-setuid-root.yaml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,246 @@ | ||
# This 'privileges-setuid-root' Tracing Policy monitors processes trying | ||
# to change their uids/gids to user root. | ||
# | ||
# __sys_setuid | ||
# - __x64_sys_setuid | ||
# - __ia32_sys_setuid | ||
# - __x64_sys_setuid16 | ||
# - __ia32_sys_setuid16 | ||
# | ||
# __sys_setgid | ||
# - __x64_sys_setgid | ||
# - __ia32_sys_setgid | ||
# - __x64_sys_setgid16 | ||
# - __ia32_sys_setgid16 | ||
# | ||
# __sys_setreuid | ||
# - __x64_sys_setreuid | ||
# - __ia32_sys_setreuid | ||
# - __x64_sys_setreuid16 | ||
# - __ia32_sys_setreuid16 | ||
# | ||
# __sys_setregid | ||
# - __x64_sys_setregid | ||
# - __ia32_sys_setregid | ||
# - __x64_sys_setregid16 | ||
# - __ia32_sys_setregid16 | ||
# | ||
# __sys_setresuid | ||
# - __x64_sys_setresuid | ||
# - __ia32_sys_setresuid | ||
# - __x64_sys_setresuid16 | ||
# - __ia32_sys_setresuid16 | ||
# | ||
# __sys_setresgid | ||
# - __x64_sys_setresgid | ||
# - __ia32_sys_setresgid | ||
# - __x64_sys_setresgid16 | ||
# - __ia32_sys_setresgid16 | ||
# | ||
# __sys_setfsuid | ||
# - __x64_sys_setfsuid | ||
# - __ia32_sys_setfsuid | ||
# - __x64_sys_setfsuid16 | ||
# - __ia32_sys_setfsuid16 | ||
# | ||
# __sys_setfsgid | ||
# - __x64_sys_setfsgid | ||
# - __ia32_sys_setfsgid | ||
# - __x64_sys_setfsgid16 | ||
# - __ia32_sys_setfsgid16 | ||
# | ||
|
||
apiVersion: cilium.io/v1alpha1 | ||
kind: TracingPolicy | ||
metadata: | ||
name: "privileges-setuid-root.yaml" | ||
spec: | ||
kprobes: | ||
- call: "__sys_setuid" | ||
syscall: false | ||
return: true | ||
args: | ||
- index: 0 | ||
type: "int" | ||
returnArg: | ||
index: 0 | ||
type: "int" | ||
selectors: | ||
- matchArgs: | ||
- index: 0 | ||
operator: "Equal" | ||
values: | ||
- "0" | ||
matchActions: | ||
- action: Post | ||
rateLimit: "1m" # Rate limit messages to 1min | ||
- call: "__sys_setgid" | ||
syscall: false | ||
return: true | ||
args: | ||
- index: 0 | ||
type: "int" | ||
returnArg: | ||
index: 0 | ||
type: "int" | ||
selectors: | ||
- matchArgs: | ||
- index: 0 | ||
operator: "Equal" | ||
values: | ||
- "0" | ||
matchActions: | ||
- action: Post | ||
rateLimit: "1m" # Rate limit messages to 1min | ||
- call: "__sys_setreuid" | ||
syscall: false | ||
return: true | ||
args: | ||
- index: 0 | ||
type: "int" | ||
- index: 1 | ||
type: "int" | ||
returnArg: | ||
index: 0 | ||
type: "int" | ||
selectors: | ||
- matchArgs: | ||
- index: 0 | ||
operator: "Equal" | ||
values: | ||
- "0" | ||
matchActions: | ||
- action: Post | ||
rateLimit: "1m" # Rate limit messages to 1min | ||
- matchArgs: | ||
- index: 1 | ||
operator: "Equal" | ||
values: | ||
- "0" | ||
matchActions: | ||
- action: Post | ||
rateLimit: "1m" # Rate limit messages to 1min | ||
- call: "__sys_setregid" | ||
syscall: false | ||
return: true | ||
args: | ||
- index: 0 | ||
type: "int" | ||
- index: 1 | ||
type: "int" | ||
returnArg: | ||
index: 0 | ||
type: "int" | ||
selectors: | ||
- matchArgs: | ||
- index: 0 | ||
operator: "Equal" | ||
values: | ||
- "0" | ||
matchActions: | ||
- action: Post | ||
rateLimit: "1m" # Rate limit messages to 1min | ||
- matchArgs: | ||
- index: 1 | ||
operator: "Equal" | ||
values: | ||
- "0" | ||
matchActions: | ||
- action: Post | ||
rateLimit: "1m" # Rate limit messages to 1min | ||
- call: "__sys_setresuid" | ||
syscall: false | ||
return: true | ||
args: | ||
- index: 0 | ||
type: "int" | ||
- index: 1 | ||
type: "int" | ||
- index: 2 | ||
type: "int" | ||
returnArg: | ||
index: 0 | ||
type: "int" | ||
selectors: | ||
- matchArgs: | ||
- index: 1 # We care about the effective user id to reduce noise | ||
operator: "Equal" | ||
values: | ||
- "0" | ||
matchActions: | ||
- action: Post | ||
rateLimit: "1m" # Rate limit messages to 1min | ||
- matchArgs: | ||
- index: 2 | ||
operator: "Equal" | ||
values: | ||
- "0" | ||
matchActions: | ||
- action: Post | ||
rateLimit: "1m" # Rate limit messages to 1min | ||
- call: "__sys_setresgid" | ||
syscall: false | ||
return: true | ||
args: | ||
- index: 0 | ||
type: "int" | ||
- index: 1 | ||
type: "int" | ||
- index: 2 | ||
type: "int" | ||
returnArg: | ||
index: 0 | ||
type: "int" | ||
selectors: | ||
- matchArgs: | ||
- index: 1 # We care about the effective group id to reduce noise | ||
operator: "Equal" | ||
values: | ||
- "0" | ||
matchActions: | ||
- action: Post | ||
rateLimit: "1m" # Rate limit messages to 1min | ||
- matchArgs: | ||
- index: 2 | ||
operator: "Equal" | ||
values: | ||
- "0" | ||
matchActions: | ||
- action: Post | ||
rateLimit: "1m" # Rate limit messages to 1min | ||
- call: "__sys_setfsuid" | ||
syscall: false | ||
return: true | ||
args: | ||
- index: 0 | ||
type: "int" | ||
returnArg: | ||
index: 0 | ||
type: "int" | ||
selectors: | ||
- matchArgs: | ||
- index: 0 | ||
operator: "Equal" | ||
values: | ||
- "0" | ||
matchActions: | ||
- action: Post | ||
rateLimit: "1m" # Rate limit messages to 1min | ||
- call: "__sys_setfsgid" | ||
syscall: false | ||
return: true | ||
args: | ||
- index: 0 | ||
type: "int" | ||
returnArg: | ||
index: 0 | ||
type: "int" | ||
selectors: | ||
- matchArgs: | ||
- index: 0 | ||
operator: "Equal" | ||
values: | ||
- "0" | ||
matchActions: | ||
- action: Post | ||
rateLimit: "1m" # Rate limit messages to 1min |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we miss seteuid/setegid ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The seteuid/setegid are usually library that call syscall setreuid and setregid which is handled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm, but it's still separate syscall right? should we cover any possible way? I might misunderstood the purpose of that spec though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Jiri so the seteuid/setegid are wrappers https://www.man7.org/linux/man-pages/man2/seteuid.2.html check c library, internally they are calling the real system calls setreuid/setregid (there is no seteuid syscall). In this tracing library we handle all the syscalls around that, if you check, the setreuid/setregid are covered ;-)
Thank you Jiri for the review ;-)