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 interpreted procs outbound network activity #188

Merged
merged 1 commit into from
May 2, 2024

Conversation

h4l0gen
Copy link
Contributor

@h4l0gen h4l0gen commented Mar 20, 2024

What type of PR is this?

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:
this triggers rule interpreted procs outbound network activity
Which issue(s) this PR fixes:

Fixes #152

Special notes for your reviewer:

@poiana poiana requested review from FedeDP and leogr March 20, 2024 23:52
@poiana poiana added the size/M label Mar 20, 2024
@h4l0gen h4l0gen changed the title adding an event on interpreted procs outbound network activity WIP: adding an event on interpreted procs outbound network activity Apr 7, 2024
@h4l0gen
Copy link
Contributor Author

h4l0gen commented Apr 9, 2024

@leogr @FedeDP Here I created a new helper action OutboundConnection. This rule triggered successfully
WhatsApp Image 2024-04-09 at 20 42 45_e17177c6

@h4l0gen
Copy link
Contributor Author

h4l0gen commented Apr 9, 2024

Before proceeding with this PR, I would like to discuss these two points :

  • In outbound_connection.go, an important condition is to establish connection as per outbound_connection macro condition. For testing purposes, I used Google's public DNS server (8.8.8.8:53)(rule triggered on using this). What do you think about using this DNS server?
  • Sending written data is not required to trigger this rule; the important thing is a successful connection. I included this part (sending written data) in action, to establish a connection only. If you prefer, we can remove this part.

@h4l0gen h4l0gen changed the title WIP: adding an event on interpreted procs outbound network activity adding an event on interpreted procs outbound network activity Apr 9, 2024
Copy link
Member

@leogr leogr left a comment

Choose a reason for hiding this comment

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

quick look, just left preliminary comments.

PS
I like the helper 👍

events/helper/outbound_connection.go Outdated Show resolved Hide resolved
Comment on lines 16 to 18
if _, err := conn.Write([]byte("Sent by event-generator")); err != nil {
return err
}
Copy link
Member

Choose a reason for hiding this comment

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

re:

Sending written data is not required to trigger this rule; the important thing is a successful connection. I included this part (sending written data) in action, to establish a connection only. If you prefer, we can remove this part.

I've no strong opinion. I'd avoid bothering 3rd-party service, if possible.
@FedeDP wdyt?

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 rule triggers without the data being actually written, we should just skip this part.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@FedeDP @leogr made changes.

Copy link
Member

Choose a reason for hiding this comment

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

hey @h4l0gen

have you tried the latest implementation? does it still trigger the rule? 🤔

Copy link
Member

Choose a reason for hiding this comment

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

which part of this macro condition is meeting?

- macro: outbound
  condition: >
    (((evt.type = connect and evt.dir=<) or
      (evt.type in (sendto,sendmsg) and evt.dir=< and
       fd.l4proto != tcp and fd.connected=false and fd.name_changed=true)) and
     (fd.typechar = 4 or fd.typechar = 6) and
     (fd.ip != "0.0.0.0" and fd.net != "127.0.0.0/8" and not fd.snet in (rfc_1918_addresses)) and
     (evt.rawres >= 0 or evt.res = EINPROGRESS))

Copy link
Contributor Author

@h4l0gen h4l0gen Apr 30, 2024

Choose a reason for hiding this comment

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

Hii @leogr. Yes rule triggered successfully after changes too.
Screenshot from 2024-05-01 03-45-59

Copy link
Contributor Author

@h4l0gen h4l0gen Apr 30, 2024

Choose a reason for hiding this comment

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

This is how macro condition got satisfied:

  • As we used net.Dial method, which performs outbound connection hence (evt.type = connect and evt.dir=<) is satisfied.
  • UDP connectuon is used.
  • Using example.net not RFC 1918 addresses (private IP range)

Signed-off-by: h4l0gen <[email protected]>

git squashed

Signed-off-by: h4l0gen <[email protected]>
@poiana poiana added the lgtm label May 2, 2024
@poiana
Copy link

poiana commented May 2, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: h4l0gen, 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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@poiana
Copy link

poiana commented May 2, 2024

LGTM label has been added.

Git tree hash: b75de9ef16e6312348f0bff9b3d60ffb1b31ba91

@poiana poiana added the approved label May 2, 2024
@poiana poiana merged commit 7b0b5b9 into falcosecurity:main May 2, 2024
4 checks passed
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 Interpreted procs outbound network activity
4 participants