-
Notifications
You must be signed in to change notification settings - Fork 690
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
[0.7.0] Journalist and admin notifications can group and cause "SecureDrop Submissions Error" #3368
Comments
Ah, so we assumed here that the "level 1" and "level 7" are sent separately, but this is not accurate, so we need another method to prevent alert grouping. |
Shoot. I'll work on that first thing in the morning tomorrow. |
UpdateI think I have some issues in my instance about emails. Doing an update to make sure of the right state of the system. Update2I can confirm this error. Received the |
Did you instead see #3367? You should see one or the other with the current configuration, unless we are really misunderstanding something |
So this bug results from two underlying issues:
Digging more into the second issue, OSSEC notifications are grouped by default. This is set by However, if we toggle To test this, I set this option ( |
For the record I'm looking at email-alerts-config.c and more generally trying to get an understanding of how do_not_group works. |
The do_not_group element is used in ossec.conf server side <email_alerts> <email_to>root@localhost</email_to> <rule_id>400600</rule_id> <do_not_delay /> <do_not_group /> </email_alerts> so the mail triggered by alert_by_email in the the daily notification rule is not grouped with another email alert: <group name="Ossec daily notifications"> <rule id="400600" level="1" > <if_sid>530</if_sid> <options>alert_by_email</options> <!-- force email to be sent --> <match>ossec: output: 'head -1 /var/lib/securedrop/submissions_today.txt</match> <description>Boolean value indicating if there were submissions in the past 24h.</description> </rule> </group> However... this is apparently ignored or ineffective for some reason. |
Browsed OSSEC issues looking for group and do_not_group keywords and did not find anything related. |
The sendmail.c debug flag is set at compile time and maild.c does not implement debug messages. The ossec-maild daemon relies on file-queue.c to get alerts reading files from lf->generated_rule->alert_opts & DO_MAILALERT?" mail ":"", The tests should be modified to check the content of Running ossec-maild with -dddd should set the debug level to 2 or more and create some debug where the debug functions (debug1, debug2 etc.) are called. |
After running ./testinfra/test.py app-staging the file ** Alert 1525519439.229786: mail - Ossec daily notifications 2018 May 05 11:23:59 (app-staging) 10.0.1.2->head -1 /var/lib/securedrop/submissions_today.txt | grep '^[0-9]*$' Rule: 400600 (level 1) -> 'Boolean value indicating if there were submissions in the past 24h.' ossec: output: 'head -1 /var/lib/securedrop/submissions_today.txt | grep '^[0-9]*$'': 0 |
The ossec.conf on the app server <localfile> <log_format>full_command</log_format> <command>head -1 /var/lib/securedrop/submissions_today.txt | grep '^[0-9]*$'</command> <frequency>86400</frequency> </localfile> It is run by ossec-logcollector (see logcollector.c). A more verbose output can be configured in # Log collector (server, local or unix agent) logcollector.debug=2 and when starting again manually it shows in 2018/05/05 12:33:36 ossec-logcollector: DEBUG: Entering LogCollectorStart(). ... 2018/05/05 12:33:36 ossec-logcollector: INFO: Monitoring full output of command(86400): head -1 /var/lib/securedrop/submissions_today.txt | grep '^[0-9]*$' When logcollector starts, the else if(strcmp(logff[i].logformat, "command") == 0) { logff[i].file = NULL; logff[i].fp = NULL; logff[i].size = 0; and the daemon loop checks this field to compare it with the current time /* Checking which file is available */ for(i = 0; i <= max_file; i++) { if(!logff[i].fp) { /* Run the command. */ if(logff[i].command && (f_check %2)) { curr_time = time(0); if((curr_time - logff[i].size) >= logff[i].ign) { logff[i].size = curr_time; logff[i].read(i, &r, 0); } } continue; } and always finds that it needs to run at boot time. This logic did not change in newer versions and a but was reported. |
On the mon server it is possible to verify the do_not_group option is indeed taken into account by doing the following: Tmux window 0 $ sudo service postfix start $ sudo service ossec stop $ sudo postsuper -d ALL $ sudo strace /var/ossec/bin/ossec-maild -f -dddd Tmux window 1 $ sudo cat >> /var/ossec/logs/alerts/2018/May/ossec-alerts-05.log <head -1 /var/lib/securedrop/submissions_today.txt | grep '^[0-9]*$' Rule: 400600 (level 1) -> 'Boolean value indicating if there were submissions in the past 24h.' ossec: output: 'head -1 /var/lib/securedrop/submissions_today.txt | grep '^[0-9]*$'': 0 ** Alert 1525529439.229786: mail - Ossec daily notifications 2018 May 05 13:23:59 (app-staging) 10.0.1.2->head -1 /var/lib/securedrop/submissions_today.txt | grep '^[0-9]*$' Rule: 400600 (level 1) -> 'Boolean value indicating if there were submissions in the past 24h.' ossec: output: 'head -1 /var/lib/securedrop/submissions_today.txt | grep '^[0-9]*$'': 0 EOF $ sudo mailq # see two mails to [email protected] Repeat the above after commenting out the do_not_group in <!-- Ossec daily notifications --> <email_alerts> <email_to>root@localhost</email_to> <rule_id>400600</rule_id> <!-- <do_not_delay /> <do_not_group /> --> </email_alerts> and verify that
|
@redshiftzero if you are able to repeat the problem, could you please also provide the content of the most recent Thanks! |
Thanks for looking into this issue @dachary, I have confirmed that
is in
which produces this (decrypted) "SecureDrop Submissions Error" email:
|
thanks for the additional information, I'll work on reproducing the problem today |
I'm able to reproduce the problem with the provided content, every time. Cool :-) |
Note in the following the timestamp following Alert is set in the distant future so alerts are always parsed and acted upon. The following does not trigger an error, it sends one mail per alert as expected. cat >> logs/alerts/2018/May/ossec-alerts-07.log <<'EOF' ** Alert 1625693173.315226: mail - ossec,syscheck, 2018 May 07 11:39:33 mon-prod->syscheck Rule: 550 (level 7) -> 'Integrity checksum changed.' Integrity checksum changed for: '/var/ossec/etc/ossec.conf' Size changed from '6442' to '6455' Old md5sum was: '7c1f892fce8df29d304356e13b721748' New md5sum is : '685ce9610b46c1c5581b35157539d426' Old sha1sum was: '6b75ff00c135101d474bad5e151dcea6500edc8a' New sha1sum is : '3cd01be22a8ed70de92aaead01d2ad11d3fe1d6a' ** Alert 1625637904.11923: mail - Ossec daily notifications 2018 May 06 20:18:24 (app) 10.0.1.4->head -1 /var/lib/securedrop/submissions_today.txt | grep '^[0-9]*$' Rule: 400600 (level 1) -> 'Boolean value indicating if there were submissions in the past 24h.' ossec: output: 'head -1 /var/lib/securedrop/submissions_today.txt | grep '^[0-9]*$'': 0 EOF The following produces a single mail that contains both alerts instead of just one cat >> logs/alerts/2018/May/ossec-alerts-07.log <<'EOF' ** Alert 1625637904.10900: mail - ossec, 2018 May 06 20:18:24 (app) 10.0.1.4->netstat -tan |grep LISTEN |grep -v 127.0.0.1 | sort Rule: 552 (level 7) -> 'Listened ports status (netstat) changed (new port opened or closed).' ossec: output: 'netstat -tan |grep LISTEN |grep -v 127.0.0.1 | sort': tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:37294 0.0.0.0:* LISTEN tcp6 0 0 :::111 :::* LISTEN tcp6 0 0 :::44352 :::* LISTEN Previous output: ossec: output: 'netstat -tan |grep LISTEN |grep -v 127.0.0.1 | sort': tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:48638 0.0.0.0:* LISTEN tcp6 0 0 :::111 :::* LISTEN tcp6 0 0 :::37312 :::* LISTEN ** Alert 1625637904.11923: mail - Ossec daily notifications 2018 May 06 20:18:24 (app) 10.0.1.4->head -1 /var/lib/securedrop/submissions_today.txt | grep '^[0-9]*$' Rule: 400600 (level 1) -> 'Boolean value indicating if there were submissions in the past 24h.' ossec: output: 'head -1 /var/lib/securedrop/submissions_today.txt | grep '^[0-9]*$'': 0 EOF The difference between the two is that Rule: 552 does not send a mail alert. It could be a bug in how ossec-maild handles that particular case. |
Filed a bug report against OSSEC ossec/ossec-hids#1416 |
I can't reproduce the problem, I was testing against prod on the development branch which does the following:
The alerts are grouped into a single mail because the required ossec.conf + rules are not in the 0.6 packages. Back to square one. |
For the record, @kushaldas & @redshiftzero managed to reproduce it as follows: On the app server
@redshiftzero sent me the content of the ossec.log containing the alerts and despite injecting them in a mon I was not able to reproduce the problem. |
it could be a race condition when writing the log file while reading is going on |
Hum, reading read-alert.c I don't see how that theory would work. The file is append only. |
Note that myself and @kushaldas were only able to reproduce this (and only intermittently even then) when the journalist notification time was dramatically increased. We could not reproduce this issue with the notification time at 24 hours. A commit was added in #3384 by @dachary to mitigate this issue - as such I'm closing this for now. |
Description
While trying to reproduce #3367, I discovered a related issue, where a "SecureDrop Submissions Error" is sent to the administrator.
Steps to Reproduce
Expected Behavior
No journalist notification is sent
Actual Behavior
A notification entitled "SecureDrop Submissions Error" is sent to the administrator, clipped:
Comments
I found a similar issue during review, that should be the first thing to investigate
The text was updated successfully, but these errors were encountered: