Open petterreinholdtsen opened 3 days ago
With a closer look at the logs, I now suspect that fd.net work for IPv4, but not for IPv6.
Perhaps it is related to https://github.com/draios/sysdig/pull/1091and https://github.com/falcosecurity/falco/pull/343 ? The unit test in the latter only test for IPv4, perhaps it could be extended to test IPv6 too? The patch in sysdig only mention IPv4, but I guess the case is equally valid for IPv6.
I suspect something like this might be a step in the right direction. Unfortunately I do not know how to make the IPv6 .scap file, so I am unable to complete the test.
diff --git a/test/falco_tests.yaml b/test/falco_tests.yaml
index f8dedc0..378462d 100644
--- a/test/falco_tests.yaml
+++ b/test/falco_tests.yaml
@@ -1066,12 +1066,19 @@ trace_files: !mux
trace_file: trace_files/cat_write.scap
stdout_contains: "^(.*\"tags\":[ ]*\\[\\],.*)"
- in_operator_netmasks:
+ in_operator_ipv4_netmasks:
detect: True
detect_level: INFO
rules_file:
- rules/detect_connect_using_in.yaml
- trace_file: trace_files/connect_localhost.scap
+ trace_file: trace_files/connect_ipv4_localhost.scap
+
+ in_operator_ipv6_netmasks:
+ detect: True
+ detect_level: INFO
+ rules_file:
+ - rules/detect_connect_using_in.yaml
+ trace_file: trace_files/connect_ipv6_localhost.scap
syscalls:
detect: True
diff --git a/test/rules/detect_connect_using_in.yaml b/test/rules/detect_connect_using_in.yaml
index ad65bdc..30abb87 100644
--- a/test/rules/detect_connect_using_in.yaml
+++ b/test/rules/detect_connect_using_in.yaml
@@ -14,9 +14,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-- rule: Localhost connect
- desc: Detect any connect to the localhost network, using fd.net and the in operator
+- rule: Localhost IPv4 connect
+ desc: Detect any connect to the IPv4 localhost network, using fd.net and the in operator
condition: evt.type=connect and fd.net in ("127.0.0.1/24")
- output: Program connected to localhost network
+ output: Program connected to IPv4 localhost network
+ (user=%user.name user_loginuid=%user.loginuid command=%proc.cmdline connection=%fd.name)
+ priority: INFO
+- rule: Localhost IPv6 connect
+ desc: Detect any connect to the IPv6 localhost network, using fd.net and the in operator
+ condition: evt.type=connect and fd.net in ("::1/128")
+ output: Program connected to IPv6 localhost network
(user=%user.name user_loginuid=%user.loginuid command=%proc.cmdline connection=%fd.name)
priority: INFO
diff --git a/test/trace_files/connect_localhost.scap b/test/trace_files/connect_ipv4_localhost.scap
similarity index 100%
rename from test/trace_files/connect_localhost.scap
rename to test/trace_files/connect_ipv4_localhost.scap
I am using the rule set from falco-incubating_rules.yaml, and try to filter out some of the irrelevant UDP traffic from the 'Unexpected UDP traffic' rule. When I try to filter on fd.net to avoid reports for traffic to and from localhost, this do not work. This is using the RPM packages for falco version 0.39.1-1.
For reference, the rule I am trying to modify look like this:
I am overriding the expected_udp_traffic. This do not work as expected. I've tried to reduce it to a simple test case, to demonstrate the problem, using this simpler rule to trigger on ping packages not heading for localhost:
When I test with 'ping localhost' with this rule loaded, I get events like this in /var/log/falco.log:
I expected these events to be ignored, as the fd.net content should match the localhost IPv4 and IPv6 content.
Environment
Falco version: Wed Nov 13 11:09:04 2024: Using deprecated config key 'rules_file' (singular form). Please use new 'rules_files' config key (plural form). Wed Nov 13 11:09:04 2024: Falco version: 0.39.1 (x86_64) Wed Nov 13 11:09:04 2024: Falco initialized with configuration files: Wed Nov 13 11:09:04 2024: /etc/falco/falco.yaml | schema validation: failed for[webserver]: Object contains a property that could not be validated using 'properties' or 'additionalProperties' constraints: 'k8s_audit_endpoint'.
Wed Nov 13 11:09:04 2024: System info: Linux version 6.10.7-100.fc39.x86_64 (mockbuild@bcd4ebc81e1d4849aca2632ad651b39e) (gcc (GCC) 13.3.1 20240522 (Red Hat 13.3.1-1), GNU ld version 2.40-14.fc39) #1 SMP PREEMPT_DYNAMIC Fri Aug 30 00:07:39 UTC 2024
{"default_driver_version":"7.3.0+driver","driver_api_version":"8.0.0","driver_schema_version":"2.0.0","engine_version":"43","engine_version_semver":"0.43.0","falco_version":"0.39.1","libs_version":"0.18.1","plugin_api_version":"3.7.0"}
System info: { "machine": "x86_64", "nodename": "mytesthost", "release": "6.10.7-100.fc39.x86_64", "sysname": "Linux", "version": "#1 SMP PREEMPT_DYNAMIC Fri Aug 30 00:07:39 UTC 2024" }
Cloud provider or hardware configuration: libvirt VM x86_64/amd64
OS: Fedora release 39
Kernel: Linux mytesthost 6.10.7-100.fc39.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Aug 30 00:07:39 UTC 2024 x86_64 GNU/Linux
Installation method: RPM