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

adding an event on change_namespace_privilleges_using_unshare #128

Merged
merged 4 commits into from
Mar 28, 2024

Conversation

h4l0gen
Copy link
Contributor

@h4l0gen h4l0gen commented Mar 17, 2024

What type of PR is this?
adding an event for stable rule change_namespace_privillege_using_unshare

Uncomment one (or more) /kind <> lines:

/kind bug

/kind cleanup

/kind documentation

/kind tests

/kind feature

Any specific area of the project related to this PR?

Uncomment one (or more) /area <> lines:

/area commands

/area pkg

/area events

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #123

Special notes for your reviewer:

Comment on lines 31 to 35
cmd := exec.Command("/bin/sh", "-c", "unshare --fork --pid --mount-proc /bin/bash")
cmd.SysProcAttr = &syscall.SysProcAttr{
Cloneflags: syscall.CLONE_NEWNS | syscall.CLONE_NEWUSER,
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked by running container on my host machine with alpine image and only running unshare command inside it will trigger rule so here we can change it to only command execution.
cmd = exec.Command("unshare")
provide your thoughts @leogr @FedeDP , Then i will change it.
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, since the condition for the rule is:

 evt.type=unshare and evt.dir=< 
    and container 
    and not thread.cap_permitted contains CAP_SYS_ADMIN

Co-authored-by: Federico Di Pierro <[email protected]>
Signed-off-by: Kapil Sharma <[email protected]>
@h4l0gen h4l0gen requested a review from FedeDP March 28, 2024 12:15
"github.com/falcosecurity/event-generator/events"
)

var _ = events.Register(ChangeNamespacePrivilegesViaUnshare)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should disable by default since the rule is an incubating one:

events.WithDisabled(), // this rules is not included in falco_rules.yaml (stable rules), so disable the action

See https://github.com/falcosecurity/rules/blob/main/rules/falco-incubating_rules.yaml#L449

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"github.com/falcosecurity/event-generator/events"
)

var _ = events.Register(ChangeNamespacePrivilegesViaUnshare)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

…nge_namespace_privileges_via_unshare.go

Signed-off-by: Kapil Sharma <[email protected]>
Copy link
Contributor

@FedeDP FedeDP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve

@poiana poiana added the lgtm label Mar 28, 2024
@poiana
Copy link

poiana commented Mar 28, 2024

LGTM label has been added.

Git tree hash: 7e673f5f43e2486b0eea36b6dc50951d206752c5

@poiana
Copy link

poiana commented Mar 28, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: FedeDP, h4l0gen

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

@poiana poiana merged commit 55cf1af into falcosecurity:main Mar 28, 2024
4 checks passed
@leogr leogr added this to the v0.12.0 milestone Oct 2, 2024
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.

event on change namespacer privillege via unshare
4 participants