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

adds daily OSSEC check/alert for v2 onion service config #5682

Merged
merged 2 commits into from
Jan 12, 2021

Conversation

zenmonkeykstop
Copy link
Contributor

@zenmonkeykstop zenmonkeykstop commented Jan 5, 2021

Status

Ready for review

Description of Changes

Fixes #5673.

Adds a daily OSSEC check for "HiddenServiceVersion 2" matches in the /etc/tor/torrc files on the app and mon servers.

Testing:

Prod:

  • install latest prod version with only v2 onion services enabled

  • build debs from this branch

  • install built securedrop-ossec-agent .deb on app, securedrop-ossec-server .deb on mon and restart OSSEC on both servers with the command sudo systemctl restart ossec

  • observe the /var/ossec/logs/alerts/alerts.log file on mon and confirm there are v2_service_check alerts generated for both app and mon

  • if configured, the OSSEC alert email address receives both the alerts above

  • install latest prod version with both v2 and v3 onion services enabled

  • build debs from this branch

  • install built securedrop-ossec-agent .deb on app, securedrop-ossec-server .deb on mon and restart OSSEC on both servers with the command sudo systemctl restart ossec

  • observe the /var/ossec/logs/alerts/alerts.log file on mon and confirm there are v2_service_check alerts generated for both app and mon

  • if configured, the OSSEC alert email address receives both the alerts above

  • update the last prod install to use v3 onion services only via ./securedrop-admin sdconfig && ./securedrop-admin install

  • reinstall the built debs if overwritten and restart OSSEC as above

  • observe the /var/ossec/logs/alerts/alerts.log file on mon and confirm there are nov2_service_check alerts generated for both app and mon

  • confirm no v2_service_check alert emails are sent.

Checklist

If you made non-trivial code changes:

  • I have written a test plan and validated it for this PR

Choose one of the following:

  • I have opened a PR in the docs repo for these changes, or will do so later
  • I would appreciate help with the documentation
  • These changes do not require documentation

@zenmonkeykstop zenmonkeykstop added this to Ready for Review in SecureDrop Team Board Jan 5, 2021
@zenmonkeykstop zenmonkeykstop added this to the 1.7.0 milestone Jan 5, 2021
@rmol rmol self-assigned this Jan 5, 2021
@rmol rmol moved this from Ready for Review to Under Review in SecureDrop Team Board Jan 5, 2021
rmol
rmol previously approved these changes Jan 5, 2021
Copy link
Contributor

@rmol rmol left a comment

Choose a reason for hiding this comment

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

Looks good:

  • install latest prod version with only v2 onion services enabled

  • build debs from this branch

  • install built securedrop-ossec-agent .deb on app, securedrop-ossec-server .deb on mon and restart OSSEC on both servers with the command sudo systemctl restart ossec

  • observe the /var/ossec/logs/alerts/alerts.log file on mon and confirm there are v2_service_check alerts generated for both app and mon

  • if configured, the OSSEC alert email address receives both the alerts above

  • install latest prod version with both v2 and v3 onion services enabled

  • build debs from this branch

  • install built securedrop-ossec-agent .deb on app, securedrop-ossec-server .deb on mon and restart OSSEC on both servers with the command sudo systemctl restart ossec

  • observe the /var/ossec/logs/alerts/alerts.log file on mon and confirm there are v2_service_check alerts generated for both app and mon

  • if configured, the OSSEC alert email address receives both the alerts above

  • update the last prod install to use v3 onion services only via ./securedrop-admin sdconfig && ./securedrop-admin install

  • reinstall the built debs if overwritten and restart OSSEC as above

  • observe the /var/ossec/logs/alerts/alerts.log file on mon and confirm there are nov2_service_check alerts generated for both app and mon

  • confirm no v2_service_check alert emails are sent.

@eloquence
Copy link
Member

What does the email look like that's generated by these alerts - I don't see a subject line or message body in the PR itself, so I'm guessing it's fairly cryptic? If so, can we customize it to be much more explicit and human-friendly?

@rmol
Copy link
Contributor

rmol commented Jan 5, 2021

Currently the subject is OSSEC Notification - (app) - Alert level 12 and the body is:

OSSEC HIDS Notification.
2021 Jan 05 12:59:21

Received From: (app) 10.20.2.2->v2_service_check
Rule: 400901 fired (level 12) -> "Indicates that legacy v2 onion services are still configured and should be disabled in favour of v3 services."
Portion of the log(s):

ossec: output: 'v2_service_check': HiddenServiceVersion 2

 --END OF NOTIFICATION

Pretty typical for an OSSEC alert, with the exception of the misspelling of "favor". 😉 I'd be all for making these more readable, but how to do that isn't obvious from a glance at the OSSEC docs.

@eloquence
Copy link
Member

eloquence commented Jan 5, 2021

Thanks @rmol. A level 12 alert will hopefully stand out, but if there are other ways that we can customize the subject line, that might help the email to not get lost in the flood.

Regarding the body, I would suggest more directive language, e.g.:

v2 onion services are still enabled. Support for v2 onion services is deprecated and will be removed starting in February 2021. To preserve access to SecureDrop, you must migrate to v3 onion services: https://securedrop.org/v2-onion-eol

Whether this goes into the description or the command output (assuming that's fully included in the email) doesn't matter as much, I think, as long as it's clearly visible in the email body.

@zenmonkeykstop
Copy link
Contributor Author

Updating language in the description field - I don't see any easy way to update the subject line either.

@codecov-io
Copy link

codecov-io commented Jan 7, 2021

Codecov Report

Merging #5682 (4ae7469) into develop (0454478) will increase coverage by 0.13%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #5682      +/-   ##
===========================================
+ Coverage    85.54%   85.68%   +0.13%     
===========================================
  Files           52       52              
  Lines         3771     3771              
  Branches       474      474              
===========================================
+ Hits          3226     3231       +5     
+ Misses         440      436       -4     
+ Partials       105      104       -1     
Impacted Files Coverage Δ
securedrop/source_app/main.py 93.29% <0.00%> (+1.54%) ⬆️
securedrop/source_app/utils.py 92.20% <0.00%> (+2.59%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0454478...4ae7469. Read the comment docs.

@eloquence
Copy link
Member

Updated description LGTM, thanks!

Copy link
Contributor

@rmol rmol left a comment

Choose a reason for hiding this comment

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

New alert text looks good to me.

@rmol rmol merged commit e4d5f2f into develop Jan 12, 2021
SecureDrop Team Board automation moved this from Under Review to Done Jan 12, 2021
@rmol rmol deleted the 5673-v3-ossec-warning branch January 12, 2021 14:01
@kushaldas kushaldas mentioned this pull request Jan 18, 2021
22 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Send 24h OSSEC alert if v2 onion services are enabled
4 participants