-
Notifications
You must be signed in to change notification settings - Fork 733
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
Allow sendto/recvfrom events for falco, add fd.name_changed filtercheck #1052
Conversation
Expand the inbound/outbound macros to handle sendfrom/recvto events, so they can work on unconnected udp sockets. In order to avoid a flood of events, they also depend on is_different_addr to only consider sendto/recvfrom when the address changes. This depends on draios/sysdig#1052.
We'll be using this to expand coverage for udp traffic, some of which can be sent using sendto/recvfrom/sendmsg/recvmsg.
a2d205f
to
5dfb914
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.
UDP connections can use connect
multiple times to change the remote peer, so you're not actually monitoring those changes, but just the first recv{from,msg}
/send{to,msg}
of not-connected UDP sockets. What about calling it "is_first_udp_event" or something like that?
I hadn't thought of the case of connect() being called multiple times. I was trying to address the case of a single socket being used for different sets of to/from addresses at different times. The idea is that is_different_addr would be true each time the set of to/from addresses changed for a given socket. |
b12e034
to
58f4795
Compare
I changed the filtercheck a bit so it's not as tied to recvfrom/sendto. It also works for cases like bind/connect/etc where the "name" of a fd changes. Does this seem better. I have some unit test changes on the agent side that I'm getting ready as well. |
Add a filtercheck fd.name_changed which is true when parsing an event changes the "name" of a fd. This mostly occurs when a bind/connect/sendto/recvfrom/etc changes the ip/port information associated with a socket fd, and is useful if you want to track when a stream of sendto/recvfroms on a single socket changes addresses. This is done by adding a m_oldname to fdinfo, which is set when threadinfo returns a fd and associates it with an event. If after parsing, the name changes, the filtercheck will return true. Whether the name changed or not is an event property and set at the end of sinsp_parser::process_event(). It does this by checking the original fd name and comparing it to the fd name that exists after parsing the event.
6bb8ce6
to
6b35e44
Compare
Expand the inbound/outbound macros to handle sendfrom/recvto events, so they can work on unconnected udp sockets. In order to avoid a flood of events, they also depend on fd.name_changed to only consider sendto/recvfrom when the connection tuple changes. Also make the check for protocol a positive check for udp instead of not tcp, to avoid a warning about event type filters potentially appearing before a negative condition. This makes filtering rules by event type easier. This depends on draios/sysdig#1052.
Expand the inbound/outbound macros to handle sendfrom/recvto events, so they can work on unconnected udp sockets. In order to avoid a flood of events, they also depend on fd.name_changed to only consider sendto/recvfrom when the connection tuple changes. Also make the check for protocol a positive check for udp instead of not tcp, to avoid a warning about event type filters potentially appearing before a negative condition. This makes filtering rules by event type easier. This depends on draios/sysdig#1052.
Expand the inbound/outbound macros to handle sendfrom/recvto events, so they can work on unconnected udp sockets. In order to avoid a flood of events, they also depend on fd.name_changed to only consider sendto/recvfrom when the connection tuple changes. Also make the check for protocol a positive check for udp instead of not tcp, to avoid a warning about event type filters potentially appearing before a negative condition. This makes filtering rules by event type easier. This depends on draios/sysdig#1052.
* Add Rule for unexpected udp traffic New rule Unexpected UDP Traffic checks for udp traffic not on a list of expected ports. Currently blocked on #308. * Add sendto/recvfrom in inbound/outbound macros Expand the inbound/outbound macros to handle sendfrom/recvto events, so they can work on unconnected udp sockets. In order to avoid a flood of events, they also depend on fd.name_changed to only consider sendto/recvfrom when the connection tuple changes. Also make the check for protocol a positive check for udp instead of not tcp, to avoid a warning about event type filters potentially appearing before a negative condition. This makes filtering rules by event type easier. This depends on draios/sysdig#1052. * Add additional restrictions for inbound/outbound - only look for fd.name_changed on unconnected sockets. - skip connections where both ips are 0.0.0.0 or localhost network. - only look for successful or non-blocking actions that are in progress * Add a combined inbound/outbound macro Add a combined inbound/outbound macro so you don't have to do all the other net/result related tests more than once. * Fix evt generator for new in/outbound restrictions The new rules skip localhost, so instead connect a udp socket to a non-local port. That still triggers the inbound/outbound macros. * Address FPs in regression tests In some cases, an app may make a udp connection to an address with a port of 0, or to an address with an application's port, before making a tcp connection that actually sends/receives traffic. Allow these connects. Also, check both the server and client port and only consider the traffic unexpected if neither port is in range.
* Add Rule for unexpected udp traffic New rule Unexpected UDP Traffic checks for udp traffic not on a list of expected ports. Currently blocked on falcosecurity/falco#308. * Add sendto/recvfrom in inbound/outbound macros Expand the inbound/outbound macros to handle sendfrom/recvto events, so they can work on unconnected udp sockets. In order to avoid a flood of events, they also depend on fd.name_changed to only consider sendto/recvfrom when the connection tuple changes. Also make the check for protocol a positive check for udp instead of not tcp, to avoid a warning about event type filters potentially appearing before a negative condition. This makes filtering rules by event type easier. This depends on draios/sysdig#1052. * Add additional restrictions for inbound/outbound - only look for fd.name_changed on unconnected sockets. - skip connections where both ips are 0.0.0.0 or localhost network. - only look for successful or non-blocking actions that are in progress * Add a combined inbound/outbound macro Add a combined inbound/outbound macro so you don't have to do all the other net/result related tests more than once. * Fix evt generator for new in/outbound restrictions The new rules skip localhost, so instead connect a udp socket to a non-local port. That still triggers the inbound/outbound macros. * Address FPs in regression tests In some cases, an app may make a udp connection to an address with a port of 0, or to an address with an application's port, before making a tcp connection that actually sends/receives traffic. Allow these connects. Also, check both the server and client port and only consider the traffic unexpected if neither port is in range.
* Add Rule for unexpected udp traffic New rule Unexpected UDP Traffic checks for udp traffic not on a list of expected ports. Currently blocked on falcosecurity/falco#308. * Add sendto/recvfrom in inbound/outbound macros Expand the inbound/outbound macros to handle sendfrom/recvto events, so they can work on unconnected udp sockets. In order to avoid a flood of events, they also depend on fd.name_changed to only consider sendto/recvfrom when the connection tuple changes. Also make the check for protocol a positive check for udp instead of not tcp, to avoid a warning about event type filters potentially appearing before a negative condition. This makes filtering rules by event type easier. This depends on draios/sysdig#1052. * Add additional restrictions for inbound/outbound - only look for fd.name_changed on unconnected sockets. - skip connections where both ips are 0.0.0.0 or localhost network. - only look for successful or non-blocking actions that are in progress * Add a combined inbound/outbound macro Add a combined inbound/outbound macro so you don't have to do all the other net/result related tests more than once. * Fix evt generator for new in/outbound restrictions The new rules skip localhost, so instead connect a udp socket to a non-local port. That still triggers the inbound/outbound macros. * Address FPs in regression tests In some cases, an app may make a udp connection to an address with a port of 0, or to an address with an application's port, before making a tcp connection that actually sends/receives traffic. Allow these connects. Also, check both the server and client port and only consider the traffic unexpected if neither port is in range.
We'll be using this to expand coverage for udp traffic, some of which
can be send using sendto/recvfrom.