-
Notifications
You must be signed in to change notification settings - Fork 160
git client domain fixes #971
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
base: main
Are you sure you want to change the base?
Changes from all commits
c22e406
7803301
fc9eff3
139cab8
e958739
f2f6504
e4565ac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,6 +92,7 @@ template(`git_client_role_template',` | |
gen_require(` | ||
attribute git_client_domain; | ||
type git_exec_t, git_home_t, git_home_hook_t; | ||
type git_xdg_config_t; | ||
') | ||
|
||
######################################## | ||
|
@@ -117,16 +118,43 @@ template(`git_client_role_template',` | |
allow $2 git_home_hook_t:dir { manage_dir_perms relabel_dir_perms }; | ||
allow $2 git_home_hook_t:file { exec_file_perms manage_file_perms relabel_file_perms }; | ||
filetrans_pattern($2, git_home_t, git_home_hook_t, dir, "hooks") | ||
xdg_config_filetrans($2, git_xdg_config_t, dir, "git") | ||
userdom_user_home_dir_filetrans($2, git_xdg_config_t, file, ".gitconfig") | ||
userdom_user_home_dir_filetrans($2, git_xdg_config_t, file, ".git-credentials") | ||
|
||
allow $3 $1_git_t:process { ptrace signal_perms }; | ||
ps_process_pattern($3, $1_git_t) | ||
|
||
auth_use_nsswitch($1_git_t) | ||
|
||
type $1_git_tmp_t; | ||
userdom_user_tmp_file($1_git_tmp_t) | ||
|
||
allow $2 $1_git_tmp_t:dir { manage_dir_perms relabel_dir_perms }; | ||
allow $2 $1_git_tmp_t:file { exec_file_perms manage_file_perms relabel_file_perms }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How is the exec used? This is an obvious path for arbitrary code execution. |
||
allow $2 $1_git_tmp_t:lnk_file { manage_lnk_file_perms relabel_lnk_file_perms }; | ||
allow $1_git_t $1_git_tmp_t:dir manage_dir_perms; | ||
allow $1_git_t $1_git_tmp_t:file mmap_manage_file_perms; | ||
allow $1_git_t $1_git_tmp_t:lnk_file manage_lnk_file_perms; | ||
files_tmp_filetrans($1_git_t, $1_git_tmp_t, {dir file}) | ||
|
||
# allow userdomains to exec git hooks | ||
exec_files_pattern($3, git_home_hook_t, git_home_hook_t) | ||
# transition back to the user domain when executing git hooks | ||
domtrans_pattern($1_git_t, git_home_t, $2) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you please add I'm not opposed to a separate tmp type for the git client, but it introduces some additional complexity that would be nice to avoid if we can. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately, the temporary file is created by the git binary itself. For example, when you use There may be other reasons to do transitions to other domains, but this cannot help the need to handle temporary file creation by the git binary itself. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be fine then, but we still need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also done! I was originally trying to provide some protection from a rogue (e.g.,) staff_git_t process, and this would trivially allow staff_t elevation. I'm still trying to understand what exactly we're trying to stop/allow with each policy. |
||
# execute shell scripts | ||
corecmd_exec_shell($1_git_t) | ||
# execute user utilities, e.g., editor | ||
corecmd_bin_domtrans($1_git_t, $2) | ||
|
||
optional_policy(` | ||
tunable_policy(`git_client_use_gpg', ` | ||
gpg_domtrans($1_git_t) | ||
dev_read_urand($1_git_t) | ||
|
||
gpg_read_files($1_git_tmp_t) | ||
') | ||
') | ||
|
||
# transition to ssh client domain when performing ssh operations | ||
optional_policy(` | ||
|
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.
This would be better with a name that isn't confused with an interface that gives access to gpg files. Something like
gpg_encrypted_content()
. It's a bit imprecise in this PR's case, since it is simply signing git commits, but it has clearer intent. The docs can be updated that it's for encryption and signing.