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

fix false positives on /etc/hosts caused by unescaped . character #144

Merged
merged 1 commit into from Aug 22, 2019

Conversation

erinish
Copy link
Contributor

@erinish erinish commented Jun 20, 2018

The dot character in these regular expressions is matching any character instead of a literal dot, causing strings like "camcom" to match ^[^#]*ca.com resulting in a false positive.

The fix is to escape the dot so it matches literal dot. I've tested this on my own systems and it seems to correctly match on "ca.com" and no longer match any string with a character between ca and com.

@jesuslinares jesuslinares self-assigned this Jun 25, 2018
Copy link
Contributor

@SitoRBJ SitoRBJ left a comment

Choose a reason for hiding this comment

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

Hello @erinish,

Thank you for your contribution, we consider very important the collaboration of the community as it helps us to grow and improve.

We have tested the changes and indeed have cases of false positives:

  • Rootkit file
root@manager:/etc# cat /var/ossec/etc/rootcheck/rootkit_trojans.txt
. . .
/etc/hosts  !^[^#]*avp\.ch!Anti-virus site on the hosts file
/etc/hosts  !^[^#]*avp.ru!Anti-virus site on the hosts file
/etc/hosts  !^[^#]*awaps\.net! Anti-virus site on the hosts file
/etc/hosts  !^[^#]*ca.com! Anti-virus site on the hosts file
. . . 
  • Hosts file
root@manager:/etc# cat hosts
. . .
dnsavpxch       truenegative
dnsavp.ru       truepositive
dnsawaps.net    truepositive
dnscapcom       falsepositive
. . .

With this configuration we would only have to have alerts for "dnsavp.ru" and "dnsawaps.net".

** Alert 1531825408.117790: - ossec,rootcheck,gdpr_IV_35.7.d,
2018 Jul 17 13:03:28 manager->rootcheck
Rule: 510 (level 7) -> 'Host-based anomaly detection event (rootcheck).'
Trojaned version of file '/etc/hosts' detected. Signature used: '^[^#]*avp.ru' (Anti-virus site on the hosts file).
title: Trojaned version of file detected.
file: /etc/hosts

** Alert 1531825408.118141: - ossec,rootcheck,gdpr_IV_35.7.d,
2018 Jul 17 13:03:28 manager->rootcheck
Rule: 510 (level 7) -> 'Host-based anomaly detection event (rootcheck).'
Trojaned version of file '/etc/hosts' detected. Signature used: '^[^#]*awaps\.net' (Anti-virus site on the hosts file).
title: Trojaned version of file detected.
file: /etc/hosts

** Alert 1531825408.118496: - ossec,rootcheck,gdpr_IV_35.7.d,
2018 Jul 17 13:03:28 manager->rootcheck
Rule: 510 (level 7) -> 'Host-based anomaly detection event (rootcheck).'
Trojaned version of file '/etc/hosts' detected. Signature used: '^[^#]*ca.com' (Anti-virus site on the hosts file).
title: Trojaned version of file detected.
file: /etc/hosts

But we also have an alert for "dnscapcom".

Kind regards,

Alfonso Ruiz-Bravo

@SitoRBJ SitoRBJ changed the base branch from master to 3.7 September 12, 2018 09:40
@bah07 bah07 added this to Under review in Wazuh 3.9.3 via automation Jun 14, 2019
@bah07 bah07 assigned chemamartinez and unassigned migruiz4 Jun 18, 2019
@vikman90 vikman90 added this to In progress in Wazuh 3.10.0 via automation Jun 28, 2019
@vikman90 vikman90 removed this from Under review in Wazuh 3.9.3 Jun 28, 2019
@vikman90 vikman90 moved this from In progress to Review in progress in Wazuh 3.10.0 Jun 28, 2019
@Lopuiz Lopuiz added this to In progress in Wazuh 3.11.0 via automation Aug 14, 2019
@Lopuiz Lopuiz removed this from Review in progress in Wazuh 3.10.0 Aug 14, 2019
@Lopuiz Lopuiz removed this from In progress in Wazuh 3.11.0 Aug 14, 2019
@Lopuiz Lopuiz added this to In progress in Wazuh 3.10.0 via automation Aug 14, 2019
@Lopuiz Lopuiz moved this from In progress to Review in progress in Wazuh 3.10.0 Aug 14, 2019
@chemamartinez chemamartinez changed the base branch from 3.7 to 3.10 August 22, 2019 12:27
@chemamartinez chemamartinez merged commit 1f77a4c into wazuh:3.10 Aug 22, 2019
Wazuh 3.10.0 automation moved this from Review in progress to Done Aug 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Wazuh 3.10.0
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

6 participants