-
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
Add new rule that detect retrieving environment variables from /proc files #2193
Add new rule that detect retrieving environment variables from /proc files #2193
Conversation
Signed-off-by: Hi120ki <[email protected]>
Welcome @hi120ki! It looks like this is your first PR to falcosecurity/falco 🎉 |
Hi @hi120ki, thanks for contributing first of all :) |
/ok-to-test |
/milestone 0.33.0 |
Signed-off-by: Hi120ki <[email protected]>
@darryk10 @jasondellaluce I update my proposed rule to expand host. - rule: Read environment variable from /proc files
desc: An attempt to read process environment variables from /proc files
condition: >
open_read and (fd.name glob /proc/*/environ)
and not proc.name in (systemctl, systemd-detect-, cloud-id)
enabled: true
output: >
Environment variables were retrieved from /proc files (user=%user.name user_loginuid=%user.loginuid program=%proc.name
command=%proc.cmdline file=%fd.name parent=%proc.pname gparent=%proc.aname[2] ggparent=%proc.aname[3] gggparent=%proc.aname[4] container_id=%container.id image=%container.image.repository)
priority: WARNING
tags: [filesystem, mitre_credential_access, mitre_discovery] Host machine has many processes, and there is many Then, in host machine some system process such as |
Signed-off-by: Hi120ki <[email protected]>
@darryk10 @jasondellaluce I tryed to apply my rule to my testbed, there are so many false positive detection from host machine. (For example, So, we should restrict this rule only container. I'm waiting for your comments. |
Hi @hi120ki, thanks for the further test. I've been testing the host condition and I agree the rule generates too noise. Even though would be good to have a role covering host as well, I would suggest to keep this use case for container only to reduce the noise as you suggested in the PR. |
b10fa31
to
ba28ee2
Compare
Signed-off-by: Hi120ki <[email protected]>
Signed-off-by: Hi120ki <[email protected]>
@darryk10 Hi, I run this rule on my testbed, and found one false positive detection in |
@hi120ki I think you also need to specify the change log in the PR otherwise the PR isn't mergeable. |
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
rules/falco_rules.yaml
Outdated
- rule: Read environment variable from /proc files | ||
desc: An attempt to read process environment variables from /proc files | ||
condition: > | ||
container and open_read and (fd.name glob /proc/*/environ) |
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.
to optimize rule checking performance, it is good to put open_read
in the beginning of the rule.
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.
Thank you! I put open_read in the beginning of the rule.
Signed-off-by: Hi120ki <[email protected]>
40ecf54
LGTM label has been added. Git tree hash: 36807142c07ff0a54c78bd2f0180c69e8a4cd8ca
|
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: darryk10, hi120ki, jasondellaluce, leogr 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 |
Closing and reopening to trigger the CI |
@leogr: Closed this PR. 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. |
/reopen |
@leogr: Reopened this PR. 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. |
/hold for the CI to complete |
/hold cancel |
Signed-off-by: Hi120ki [email protected]
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:
These days, it's common to pass a secret to an application running on a container via an environment variable. Secrets store very sensitive information such as cloud credentials and JWT secretkeys, so it is important to detect when environment variables have been retrieved by an attack.
And if the application has SSRF or path traversal vulnerabilities, the attacker can steal the environment variables of the application process by reading
/proc/self/environ
and/proc/1/environ
under the/proc
directory.https://linux.die.net/man/5/proc
For example, SSRF:
Path traversal:
In MITRE ATT&CK, this technique is categorised as T1552 : Unsecured Credentials, and Sub-technique T1552.001 : Unsecured Credentials: Credentials In Files, and Detection is DS0022 - File - File Access, and component is T1003.007 OS Credential Dumping: Proc Filesystem.
I propose the following as a rule to detect environment variable reading from files under the
/proc
directory.I'm waiting for your comments on detecting reading these files and my proposed rules.
Thank you.
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?: