This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 329
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #223 from gdestuynder/master
New alert for https://github.com/mozilla-it/duo_openvpn
- Loading branch information
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env python | ||
|
||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
# Copyright (c) 2014 Mozilla Corporation | ||
# | ||
# Contributors: | ||
# kang@mozilla.com | ||
# | ||
# This script alerts when openvpn's duo security failed to contact the duo server and let the user in. | ||
# This is a very serious warning that must be acted upon as it means MFA failed and only one factor was validated (in | ||
# this case a VPN certificate) | ||
|
||
from lib.alerttask import AlertTask | ||
import pyes | ||
|
||
class AlertDuoFailOpen(AlertTask): | ||
def main(self): | ||
# look for events in last 15 mins | ||
date_timedelta = dict(minutes=15) | ||
# Configure filters using pyes | ||
must = [ | ||
pyes.TermFilter('_type', 'event'), | ||
pyes.TermFilter('_source.tags', 'openvpn,duosecurity'), | ||
pyes.QueryFilter(pyes.MatchQuery('summary','DuoAPI contact failed','phrase')), | ||
pyes.QueryFilter(pyes.MatchQuery('summary','DuoAPI contact failed','phrase')), | ||
] | ||
self.filtersManual(date_timedelta, must=must) | ||
|
||
# Search aggregations on field 'sourceipaddress', keep 50 samples of events at most | ||
self.searchEventsAggreg('hostname', samplesLimit=1) | ||
# alert when >= X matching events in an aggregation | ||
# in this case, always | ||
self.walkAggregations(threshold=1) | ||
|
||
# Set alert properties | ||
def onAggreg(self, aggreg): | ||
# aggreg['count']: number of items in the aggregation, ex: number of failed login attempts | ||
# aggreg['value']: value of the aggregation field, ex: toto@example.com | ||
# aggreg['events']: list of events in the aggregation | ||
category = 'bypass' | ||
tags = ['openvpn', 'duosecurity'] | ||
severity = 'WARNING' | ||
|
||
summary = ('DuoSecurity OpenVPN contact failed, fail open triggered on {0}'.aggreg['value'])) | ||
|
||
# Create the alert object based on these properties | ||
return self.createAlertDict(summary, category, tags, aggreg['events'], severity) |