Skip to content
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

rule(The docker client is executed in a container): modify condition to reduce false positive #955

Merged
merged 1 commit into from
Dec 5, 2019
Merged

Conversation

rung
Copy link
Contributor

@rung rung commented Dec 4, 2019

Signed-off-by: Hiroki Suezawa [email protected]

What type of PR is this?
/kind rule-update

Any specific area of the project related to this PR?
/area rules

What this PR does / why we need it:

  • What this PR does
    • Modify condition of The docker client is executed in a container rule.
  • Why we need it
    • On GKE, The rule has many false positives because default running container uses kubectl.
    • To reduce false positives, and to be able to set additional condition, I would like to add user_known_k8s_client_container macro to this rule.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

rule(The docker client is executed in a container): when executing the docker client, exclude containers running in the `kube-system` namespace to avoid false positives
rule(macro user_known_k8s_client_container): macro to match kube-system namespace

…to reduce false positive

Signed-off-by: Hiroki Suezawa <[email protected]>
@leodido
Copy link
Member

leodido commented Dec 4, 2019

/milestone 0.19.0

@poiana poiana added this to the 0.19.0 milestone Dec 4, 2019
@fntlnz
Copy link
Contributor

fntlnz commented Dec 5, 2019

Thanks @rung - it looks good to me! I edited the release notes to match what you did since here we have a user facing change.

@poiana
Copy link
Contributor

poiana commented Dec 5, 2019

LGTM label has been added.

Git tree hash: 9ba34479acedaaf81751c7ae59b340e4048a9284

@poiana poiana added the approved label Dec 5, 2019
@rung
Copy link
Contributor Author

rung commented Dec 5, 2019

@fntlnz Thank you!

@poiana
Copy link
Contributor

poiana commented Dec 5, 2019

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fntlnz, leodido

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@fntlnz fntlnz merged commit 559b7e1 into falcosecurity:dev Dec 5, 2019
@rung rung deleted the rule-docker-in-container branch December 5, 2019 21:23
@Kaizhe
Copy link
Contributor

Kaizhe commented Dec 5, 2019

@rung this change is not good to me:

- macro: user_known_k8s_client_container
  condition: (k8s.ns.name = "kube-system")

if some bad guy was able to hack into any container in namespace kube-system and run kubectl (with some of the privileged service accounts), falco will not be able to detect it with your change.

I would propose to change like:

condition:  container.image.repository = gcr/fluentd-scaler and proc.pname=xxx

@Kaizhe
Copy link
Contributor

Kaizhe commented Dec 5, 2019

And this is GKE specific. Hopefully we will have the cloud provider info to leverage in the future.

@rung
Copy link
Contributor Author

rung commented Dec 6, 2019

@Kaizhe Thank you for your comment!

How about changing the condition to this? If it's ok, I will send new PR with comments mentioning GKE behavior

condition: (k8s.ns.name="kube-system" and container.image.repository=k8s.gcr.io/fluentd-gcp-scaler)
  • The condition has namespace and image repository. So Falco user can get detections other than fluentd-gcp-scaler.

if some bad guy was able to hack into any container in namespace kube-system and run kubectl (with some of the privileged service accounts), falco will not be able to detect it with your change.

Make sense. On the other hand, if we don't specify namespaces, the attack surface could be extended imho.
Because RBAC of Kubernetes is set based on namespaces. And when we don't specify namespaces, user(non-admin) can deploy "gcr/fluentd-scaler" on their namespaces. So they can use "kubectl" using the container.

@Kaizhe
Copy link
Contributor

Kaizhe commented Dec 6, 2019

@rung adding k8s.ns.name="kube-system" is fine with me. Please add comment to the macro saying this is a GKE scenario.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants