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

[Auditbeat] Handle different bad login types #10865

Merged
merged 5 commits into from
Feb 22, 2019

Conversation

cwurm
Copy link
Contributor

@cwurm cwurm commented Feb 21, 2019

Depending on the distro and the type of login attempt (e.g. ssh, local login) the ut_type value in /var/log/btmp is different. So far, the login dataset only responded to the rarer login type 7 (USER_PROCESS). The more common one (seems to be exclusively used on Fedora 29, but also used on Ubuntu 18.04 for failed SSH login attempts) is 6 (LOGIN_PROCESS) that we are currently ignoring.

This changes the code to have a separate function to process UTMP records from btmp files that treats both USER_PROCESS and LOGIN_PROCESS the same.

It also adds a unit test for failed logins including a btmp test file from Ubuntu 18.04 with three bad login attempts.

This new test also highlights an issue of reading btmp files. For some reason, on Ubuntu 18.04 a failed SSH login attempt leads to two identical entries (including the timestamps) being written into the btmp file. I don't know why this is, it could be that somewhere in the chain of login logic two parts decide to write the same entry. This is easy for a human to recognize, but it can lead to inaccurate aggregation results on the Elasticsearch/Kibana side (e.g. for total number of failed login attempts). I suppose that since they are exactly identical we could de-duplicate them easily on the Beats side. The data sent to Elasticsearch would then no longer be an exact representation of what is present on the host, but that might be fine since in reality, only one attempt happened. Curious what others think - @andrewkroh @tsg?

@cwurm cwurm added review needs_backport PR is waiting to be backported to other branches. Auditbeat SecOps labels Feb 21, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/secops

@cwurm cwurm requested a review from a team as a code owner February 21, 2019 12:48
x-pack/auditbeat/module/system/login/utmp.go Outdated Show resolved Hide resolved
@andrewkroh
Copy link
Member

andrewkroh commented Feb 21, 2019

I'm still thinking about the deduplication part. My first thought is that we shouldn't change the log stream in the dataset, but this isn't Filebeat, it's a dedicated tool for getting login records. If the tool knows that it's a duplicate it might was well discard it. It could even set a field like event.count: 2 to indicate that record represents 2 messages.

@webmat
Copy link
Contributor

webmat commented Feb 22, 2019

I like the idea of event.count for duplicates. Could even be used when the source of the event reports duplicates (e.g. syslog).

I also agree philosophically on doing deduplication in Auditbeat, when the case is clear like this

@cwurm
Copy link
Contributor Author

cwurm commented Feb 22, 2019

Thanks @andrewkroh, @webmat - I've opened #10901 as a follow-up to address the de-duplication.

@cwurm cwurm merged commit 94666a8 into elastic:master Feb 22, 2019
@cwurm cwurm deleted the login_btmp_uttype branch February 22, 2019 18:39
cwurm pushed a commit to cwurm/beats that referenced this pull request Feb 22, 2019
Depending on the distro and the type of login attempt (e.g. ssh, local login) the `ut_type` value in `/var/log/btmp` is different. So far, the login dataset only responded to the rarer login type `7` (`USER_PROCESS`). The more common one (seems to be exclusively used on Fedora 29, but also used on Ubuntu 18.04 for failed SSH login attempts) is `6` (`LOGIN_PROCESS`) that we are currently ignoring.

This changes the code to have a separate function to process UTMP records from btmp files that treats both `USER_PROCESS` and `LOGIN_PROCESS` the same.

It also adds a unit test for failed logins including a btmp test file from Ubuntu 18.04 with three bad login attempts.

(cherry picked from commit 94666a8)
@cwurm cwurm added v6.7.0 and removed needs_backport PR is waiting to be backported to other branches. labels Feb 22, 2019
cwurm pushed a commit to cwurm/beats that referenced this pull request Feb 22, 2019
Depending on the distro and the type of login attempt (e.g. ssh, local login) the `ut_type` value in `/var/log/btmp` is different. So far, the login dataset only responded to the rarer login type `7` (`USER_PROCESS`). The more common one (seems to be exclusively used on Fedora 29, but also used on Ubuntu 18.04 for failed SSH login attempts) is `6` (`LOGIN_PROCESS`) that we are currently ignoring.

This changes the code to have a separate function to process UTMP records from btmp files that treats both `USER_PROCESS` and `LOGIN_PROCESS` the same.

It also adds a unit test for failed logins including a btmp test file from Ubuntu 18.04 with three bad login attempts.

(cherry picked from commit 94666a8)
@cwurm cwurm added the v7.0.0 label Feb 22, 2019
cwurm pushed a commit to cwurm/beats that referenced this pull request Feb 22, 2019
Depending on the distro and the type of login attempt (e.g. ssh, local login) the `ut_type` value in `/var/log/btmp` is different. So far, the login dataset only responded to the rarer login type `7` (`USER_PROCESS`). The more common one (seems to be exclusively used on Fedora 29, but also used on Ubuntu 18.04 for failed SSH login attempts) is `6` (`LOGIN_PROCESS`) that we are currently ignoring.

This changes the code to have a separate function to process UTMP records from btmp files that treats both `USER_PROCESS` and `LOGIN_PROCESS` the same.

It also adds a unit test for failed logins including a btmp test file from Ubuntu 18.04 with three bad login attempts.

(cherry picked from commit 94666a8)
@cwurm cwurm added the v7.2.0 label Feb 22, 2019
cwurm pushed a commit that referenced this pull request Feb 25, 2019
Depending on the distro and the type of login attempt (e.g. ssh, local login) the `ut_type` value in `/var/log/btmp` is different. So far, the login dataset only responded to the rarer login type `7` (`USER_PROCESS`). The more common one (seems to be exclusively used on Fedora 29, but also used on Ubuntu 18.04 for failed SSH login attempts) is `6` (`LOGIN_PROCESS`) that we are currently ignoring.

This changes the code to have a separate function to process UTMP records from btmp files that treats both `USER_PROCESS` and `LOGIN_PROCESS` the same.

It also adds a unit test for failed logins including a btmp test file from Ubuntu 18.04 with three bad login attempts.

(cherry picked from commit 94666a8)
cwurm pushed a commit that referenced this pull request Feb 25, 2019
…es (#10910)

Cherry-pick of PR #10865 to 7.x branch. Original message: 

Depending on the distro and the type of login attempt (e.g. ssh, local login) the `ut_type` value in `/var/log/btmp` is different. So far, the login dataset only responded to the rarer login type `7` (`USER_PROCESS`). The more common one (seems to be exclusively used on Fedora 29, but also used on Ubuntu 18.04 for failed SSH login attempts) is `6` (`LOGIN_PROCESS`) that we are currently ignoring.

This changes the code to have a separate function to process UTMP records from btmp files that treats both `USER_PROCESS` and `LOGIN_PROCESS` the same.

It also adds a unit test for failed logins including a btmp test file from Ubuntu 18.04 with three bad login attempts.
cwurm pushed a commit that referenced this pull request Feb 25, 2019
…es (#10909)

Cherry-pick of PR #10865 to 7.0 branch. Original message: 

Depending on the distro and the type of login attempt (e.g. ssh, local login) the `ut_type` value in `/var/log/btmp` is different. So far, the login dataset only responded to the rarer login type `7` (`USER_PROCESS`). The more common one (seems to be exclusively used on Fedora 29, but also used on Ubuntu 18.04 for failed SSH login attempts) is `6` (`LOGIN_PROCESS`) that we are currently ignoring.

This changes the code to have a separate function to process UTMP records from btmp files that treats both `USER_PROCESS` and `LOGIN_PROCESS` the same.

It also adds a unit test for failed logins including a btmp test file from Ubuntu 18.04 with three bad login attempts.
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.

4 participants