Skip to content

Commit

Permalink
genpolicy: block self paths for copyFile requests
Browse files Browse the repository at this point in the history
Self paths are not useful and may cause security issues. Also move parent check to check_symlink_source since we only need
this check for symlinks. We already filter self and parent path references in this regexp
https://github.com/microsoft/kata-containers/blob/06ea44595d084461340fe172ec59826c168763ff/src/tools/genpolicy/rules.rego#L1185

Signed-off-by: Saul Paredes <[email protected]>
  • Loading branch information
Redent0r committed Dec 13, 2024
1 parent 06ea445 commit aabde30
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/tools/genpolicy/rules.rego
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,6 @@ match_caps(p_caps, i_caps) {
check_directory_traversal(i_path) {
contains(i_path, "../") == false
endswith(i_path, "/..") == false
i_path != ".."
}

check_symlink_source {
Expand All @@ -1148,6 +1147,9 @@ check_symlink_source {
i_src := input.symlink_src
print("check_symlink_source: i_src =", i_src)

i_src != "."
i_src != ".."

startswith(i_src, "/") == false
check_directory_traversal(i_src)
}
Expand Down

0 comments on commit aabde30

Please sign in to comment.