-
Notifications
You must be signed in to change notification settings - Fork 912
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
new(rules): Directory traversal monitored file read #2118
new(rules): Directory traversal monitored file read #2118
Conversation
This is a really good one @incertum , do you think adding a condition about non shell parent process would make more sense? I am thinking a scenario a path traverse is an exploit through a web app. |
Thanks @Kaizhe. Absolutely can add the additional filter statement in and concur this rule is only relevant for web applications that have an Arbitrary File Read bug. |
rules/falco_rules.yaml
Outdated
command=%proc.cmdline parent=%proc.pname file=%fd.name fileraw=%fd.nameraw parent=%proc.pname | ||
gparent=%proc.aname[2] container_id=%container.id image=%container.image.repository returncode=%evt.res) | ||
priority: WARNING | ||
rule: Directory traversal etc passwd read |
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,
could you please follow the best practice on the rule syntax with the name on the top?
Thank you for the change and the contribution
@darryk10: changing LGTM is restricted to collaborators In response to this: 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. |
/milestone 0.33.0 |
One liner to simulate if rule triggers |
@darryk10 indeed, this seems more economic to just create one more complete rule, good call :)
(1) Number of occurrences of a substring could be a neat future filter option. Meanwhile while not perfect matching for (2) (3) Would need to place this rule before rule (4) Any additional output fields we should add? (5) Failed file access attempts seem not to be logged -> likely need |
Hi @incertum, really good summary and I really like the condition you came up with. |
Tweaked it a bit, proposing that it could be even simpler - just look for
|
Just lookup |
LGTM @incertum. Amazing job and thenks for all the changes :) |
301b9e9
to
ecfcf64
Compare
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.
LGTM
LGTM label has been added. Git tree hash: 0cd3d21c6163d61e25e880f026337225f0ca4430
|
Hey @incertum we just bumped the libs version on master, so now the changes of falcosecurity/libs#468 should be merged into Falco. After rebasing this branch on master, I think tests will pass! |
ecfcf64
to
b86edeb
Compare
@darryk10 placed the rule before |
rules/falco_rules.yaml
Outdated
desc: > | ||
Web applications can be vulnerable to directory traversal attacks that allow accessing files outside of the web app's root directory (e.g. Arbitrary File Read bugs). | ||
System directories like /etc are typically accessed via absolute paths. Access patterns outside of this (here path traversal) can be regarded as suspicious. | ||
condition: open_read and (etc_dir or fd.name contains ".ssh/" or fd.name contains "id_rsa") and fd.nameraw contains "../" and fd.nameraw glob *../*../* and not proc.pname in (shell_binaries) |
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.
great the etc_dir
macro. What you think of using user_ssh_directory
macro instead of fd.name contains ".ssh/"
to check the user ssh directory?
also I agree with you re the position 👍🏻
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.
Done, now also directory_traversal
macro, we are slowly closing in 🙃 .
Suggesting to optimize user_ssh_directory
? Running glob against fd.name
across few rules may have perf impacts. For instance, Big Data technologies are best used via pushing down cheap filters like startswith
, contains
, endswith
... before adding more expensive expressions.
b86edeb
to
326a1b2
Compare
Signed-off-by: Melissa Kilby <[email protected]>
Signed-off-by: Melissa Kilby <[email protected]>
…ed open attempts w/ new macro open_file_failed Signed-off-by: Melissa Kilby <[email protected]>
326a1b2
to
16b8142
Compare
Mystery solved, not a In addition, included a minor cleanup (adding parentheses to important macros just to be consistent and safe). @jasondellaluce @leodido @Kaizhe @darryk10 - Let's brainstorm if the new macro Quick Simulation [removed
|
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.
LGTM! I also agree on trying to see if open_file_failed
can be applied elsewhere too, but let's go with these changes for now!
LGTM label has been added. Git tree hash: 2e90fad7b193a1c727a242d5ae5057b6cce962ca
|
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 PR is great 🤩
Thank you!
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.
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: incertum, jasondellaluce The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Signed-off-by: Melissa Kilby [email protected]
What type of PR is this?
/kind feature
/kind rule-create
Any specific area of the project related to this PR?
/area rules
What this PR does / why we need it:
Add new rule
Directory traversal monitored file read
.Web applications can be vulnerable to directory traversal attacks that allow accessing files outside of the web app's root directory (e.g. Arbitrary File Read bugs). System directories like /etc are typically accessed via absolute paths. Access patterns outside of this (here path traversal) can be regarded as suspicious. This for example will allow monitoring the entire
/etc
directory. For instance while/etc/passwd
is not regarded a sensitive file like/etc/shadow
- reading/etc/passwd
via directory traversal is often performed as reconnaissance / probing for Arbitrary File Read vulnerabilities especially in web applications, because/etc/passwd
is always there and it is world readable. In addition, vulnerability scanners will often try reading/etc/passwd
via directory traversal../../../../../../../etc/passwd
.Thanks @Kaizhe and @darryk10 for feedback to derive final version.
Example simulated log
Which issue(s) this PR fixes:
Special notes for your reviewer:
Needs new filter/display field
fd.nameraw
falcosecurity/libs#468Does this PR introduce a user-facing change?: