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

Limiting the size of the lists in rule files #1736

Closed
konstantin-921 opened this issue Sep 27, 2021 · 4 comments
Closed

Limiting the size of the lists in rule files #1736

konstantin-921 opened this issue Sep 27, 2021 · 4 comments

Comments

@konstantin-921
Copy link

konstantin-921 commented Sep 27, 2021

Describe the bug

Following this article - https://sysdig.com/blog/how-to-identify-malicious-ip-activity-using-falco/ I configured a rule to track malicious IPs. The rule works when an incoming file from malicious IPs less than 500 KB is used. But the rule doesn't work when too many IPs (more than 2 MB) are used.

How to reproduce it

To reproduce the error you just need to follow this article - https://sysdig.com/blog/how-to-identify-malicious-ip-activity-using-falco/. But I made some adjustments to the proposed script, so in the presented form it did not work as it should. Therefore, I will describe it step by step:

Step 1: Writing the Falco rule

– rule: Malicious IPs
 desc: Detect connections to/from a malicious IP
 condition: (inbound_outbound) and fd.sip in (malicous_ip_list) or fd.cip in (malicous_ip_list)
 output: >
   Suspicious connection to/from a malicious IP detected (command=%proc.cmdline connection=%fd.name user=%user.name container_id=%container.id)
 priority: WARNING
 tags: [network]

To complete this step, we will write this rule to a file under/etc/falco/malicious_ips_rule.yaml.

Step 2: Generate a constantly updated malicious IP list

  • create new file /etc/falco/malicous_ips_list.yaml.
  • create the file get_malicious_ips.sh with this script for getting Malicious IPs:
#!/bin/bash
/usr/bin/curl --compressed https://raw.githubusercontent.com/stamparm/ipsum/master/ipsum.txt 2>/dev/null | grep -v "#" | grep -v -E "s[1-5]$" |  cut -f 1  | sed "s/.*/'\"&\"',/g" | tr '\n' ' ' | sed "s/, $//" | sed 's/.*/- list: malicous_ip_list\n  items: [&]/' > /etc/falco/malicious_ips_list.yaml

/usr/sbin/service falco restart

Step 3: Update Falco configuration (/etc/falco/falko.yml) like this:

rules_file:
 - /etc/falco/malicious_ips_rule.yaml
 - /etc/falco/falco_rules.yaml
 - /etc/falco/falco_rules.local.yaml
 - /etc/falco/rules.d
 - /etc/falco/malicious_ips_list.yaml

Step 4: Testing!

  • start get_malicious_ips.sh script
  • try to use any IP from the malicous_ips_list.yaml frome the same node, for example:
curl http://198.98.58.250

Expected behaviour

I was expecting new logs in /var/log/syslog.log file related to an attempt to connect to malicious IPs. But that didn't happen.

But if I use an incoming file with malicious IPs of smaller size, e.g. using a slightly different address in a script like this https://raw.githubusercontent.com/stamparm/ipsum/master/levels/2.txt, everything will work fine and we can see the new logs in the /var/log/syslog.log.

Environment

  • Falco version: 0.29.1
  • System info:
{
  "machine": "x86_64",
  "nodename": "kub-node",
  "release": "4.15.0-137-generic",
  "sysname": "Linux",
  "version": "#141-Ubuntu SMP Fri Feb 19 13:46:27 UTC 2021"
}
  • OS:
NAME="Ubuntu"
VERSION="18.04.5 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.5 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
  • Kernel:
    Linux kub-node1-fl 4.15.0-137-generic Rule fixes for dragent. #141-Ubuntu SMP Fri Feb 19 13:46:27 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
  • Installation method:
    APT package

Additional context

I did not find any information in the documentation about the limits for the lists used in the rules

@konstantin-921 konstantin-921 changed the title Limiting the size of rule files Limiting the size of list in rule files Sep 27, 2021
@konstantin-921 konstantin-921 changed the title Limiting the size of list in rule files Limiting the size of the lists in rule files Sep 27, 2021
@poiana
Copy link
Contributor

poiana commented Dec 26, 2021

Issues go stale after 90d of inactivity.

Mark the issue as fresh with /remove-lifecycle stale.

Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Provide feedback via https://github.com/falcosecurity/community.

/lifecycle stale

@poiana
Copy link
Contributor

poiana commented Jan 25, 2022

Stale issues rot after 30d of inactivity.

Mark the issue as fresh with /remove-lifecycle rotten.

Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Provide feedback via https://github.com/falcosecurity/community.

/lifecycle rotten

@poiana
Copy link
Contributor

poiana commented Feb 24, 2022

Rotten issues close after 30d of inactivity.

Reopen the issue with /reopen.

Mark the issue as fresh with /remove-lifecycle rotten.

Provide feedback via https://github.com/falcosecurity/community.
/close

@poiana poiana closed this as completed Feb 24, 2022
@poiana
Copy link
Contributor

poiana commented Feb 24, 2022

@poiana: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.

Reopen the issue with /reopen.

Mark the issue as fresh with /remove-lifecycle rotten.

Provide feedback via https://github.com/falcosecurity/community.
/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

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

No branches or pull requests

2 participants