* added dynamic region lookup

* building the product ARN dynamically
* Resource type is now Other in case we dont have instance_id
This commit is contained in:
maor.rayzin 2018-11-28 13:27:35 +02:00
parent 7d94185a10
commit bdecc7ade6
2 changed files with 176 additions and 79 deletions

View File

@ -7,6 +7,7 @@ from botocore.exceptions import UnknownServiceError
from cc.resources.exporter import Exporter
from cc.services.config import ConfigService
from cc.environment.environment import load_server_configuration_from_file
from common.cloud.aws import AWS
logger = logging.getLogger(__name__)
@ -75,7 +76,9 @@ class AWSExporter(Exporter):
# azure and conficker are not relevant issues for an AWS env
}
product_arn = load_server_configuration_from_file()['aws'].get('sec_hub_product_arn', '')
aws = AWS()
configured_product_arn = load_server_configuration_from_file()['aws'].get('sec_hub_product_arn', '')
product_arn = 'arn:aws:securityhub:{region}:{arn}'.format(region=aws.get_region(), arn=configured_product_arn)
account_id = AWSExporter._get_aws_keys().get('aws_account_id', '')
finding = {
@ -118,10 +121,7 @@ class AWSExporter(Exporter):
{"Severity": {
"Product": 5,
"Normalized": 100
}, "Resources": [{
"Type": "AwsEc2Instance",
"Id": issue['aws_instance_id']
}], "RecordState": "ACTIVE",
}, "RecordState": "ACTIVE",
"Title": "Weak segmentation - Machines were able to communicate over unused ports.",
"Description": "Use micro-segmentation policies to disable communication other than the required.",
"Remediation": {
@ -131,6 +131,14 @@ class AWSExporter(Exporter):
}
}}
if 'aws_instance_id' in issue:
finding["Resources"] = [{
"Type": "AwsEc2Instance",
"Id": issue['aws_instance_id']
}]
else:
finding["Resources"] = [{'Type': 'Other'}]
return finding
@staticmethod
@ -139,18 +147,23 @@ class AWSExporter(Exporter):
{"Severity": {
"Product": 10,
"Normalized": 100
}, "Resources": [{
"Type": "AwsEc2Instance",
"Id": issue['aws_instance_id']
}], "RecordState": "ACTIVE", "Title": "Samba servers are vulnerable to 'SambaCry'",
}, "RecordState": "ACTIVE", "Title": "Samba servers are vulnerable to 'SambaCry'",
"Description": "Change {0} password to a complex one-use password that is not shared with other computers on the network. Update your Samba server to 4.4.14 and up, 4.5.10 and up, or 4.6.4 and up." \
.format(issue['username']), "Remediation": {
.format(issue['username']), "Remediation": {
"Recommendation": {
"Text": "The machine {0} ({1}) is vulnerable to a SambaCry attack. The Monkey authenticated over the SMB protocol with user {2} and its password, and used the SambaCry vulnerability.".format(
issue['machine'], issue['ip_address'], issue['username'])
}
}}
if 'aws_instance_id' in issue:
finding["Resources"] = [{
"Type": "AwsEc2Instance",
"Id": issue['aws_instance_id']
}]
else:
finding["Resources"] = [{'Type': 'Other'}]
return finding
@staticmethod
@ -159,10 +172,7 @@ class AWSExporter(Exporter):
{"Severity": {
"Product": 5,
"Normalized": 100
}, "Resources": [{
"Type": "AwsEc2Instance",
"Id": issue['aws_instance_id']
}], "RecordState": "ACTIVE",
}, "RecordState": "ACTIVE",
"Title": "Machines are accessible using passwords supplied by the user during the Monkey's configuration.",
"Description": "Change {0}'s password to a complex one-use password that is not shared with other computers on the network.".format(
issue['username']), "Remediation": {
@ -172,6 +182,14 @@ class AWSExporter(Exporter):
}
}}
if 'aws_instance_id' in issue:
finding["Resources"] = [{
"Type": "AwsEc2Instance",
"Id": issue['aws_instance_id']
}]
else:
finding["Resources"] = [{'Type': 'Other'}]
return finding
@staticmethod
@ -180,10 +198,7 @@ class AWSExporter(Exporter):
{"Severity": {
"Product": 1,
"Normalized": 100
}, "Resources": [{
"Type": "AwsEc2Instance",
"Id": issue['aws_instance_id']
}], "RecordState": "ACTIVE",
}, "RecordState": "ACTIVE",
"Title": "Machines are accessible using SSH passwords supplied by the user during the Monkey's configuration.",
"Description": "Change {0}'s password to a complex one-use password that is not shared with other computers on the network.".format(
issue['username']), "Remediation": {
@ -193,6 +208,14 @@ class AWSExporter(Exporter):
}
}}
if 'aws_instance_id' in issue:
finding["Resources"] = [{
"Type": "AwsEc2Instance",
"Id": issue['aws_instance_id']
}]
else:
finding["Resources"] = [{'Type': 'Other'}]
return finding
@staticmethod
@ -201,10 +224,7 @@ class AWSExporter(Exporter):
{"Severity": {
"Product": 1,
"Normalized": 100
}, "Resources": [{
"Type": "AwsEc2Instance",
"Id": issue['aws_instance_id']
}], "RecordState": "ACTIVE",
}, "RecordState": "ACTIVE",
"Title": "Machines are accessible using SSH passwords supplied by the user during the Monkey's configuration.",
"Description": "Protect {ssh_key} private key with a pass phrase.".format(ssh_key=issue['ssh_key']),
"Remediation": {
@ -214,6 +234,13 @@ class AWSExporter(Exporter):
}
}}
if 'aws_instance_id' in issue:
finding["Resources"] = [{
"Type": "AwsEc2Instance",
"Id": issue['aws_instance_id']
}]
else:
finding["Resources"] = [{'Type': 'Other'}]
return finding
@staticmethod
@ -222,10 +249,7 @@ class AWSExporter(Exporter):
{"Severity": {
"Product": 10,
"Normalized": 100
}, "Resources": [{
"Type": "AwsEc2Instance",
"Id": issue['aws_instance_id']
}], "RecordState": "ACTIVE", "Title": "Elasticsearch servers are vulnerable to CVE-2015-1427",
}, "RecordState": "ACTIVE", "Title": "Elasticsearch servers are vulnerable to CVE-2015-1427",
"Description": "Update your Elastic Search server to version 1.4.3 and up.", "Remediation": {
"Recommendation": {
"Text": "The machine {0}({1}) is vulnerable to an Elastic Groovy attack. The attack was made possible because the Elastic Search server was not patched against CVE-2015-1427.".format(
@ -233,6 +257,14 @@ class AWSExporter(Exporter):
}
}}
if 'aws_instance_id' in issue:
finding["Resources"] = [{
"Type": "AwsEc2Instance",
"Id": issue['aws_instance_id']
}]
else:
finding["Resources"] = [{'Type': 'Other'}]
return finding
@staticmethod
@ -241,10 +273,7 @@ class AWSExporter(Exporter):
{"Severity": {
"Product": 1,
"Normalized": 100
}, "Resources": [{
"Type": "AwsEc2Instance",
"Id": issue['aws_instance_id']
}], "RecordState": "ACTIVE",
}, "RecordState": "ACTIVE",
"Title": "Weak segmentation - Machines from different segments are able to communicate.",
"Description": "Segment your network and make sure there is no communication between machines from different segments.",
"Remediation": {
@ -257,6 +286,14 @@ class AWSExporter(Exporter):
}
}}
if 'aws_instance_id' in issue:
finding["Resources"] = [{
"Type": "AwsEc2Instance",
"Id": issue['aws_instance_id']
}]
else:
finding["Resources"] = [{'Type': 'Other'}]
return finding
@staticmethod
@ -265,10 +302,7 @@ class AWSExporter(Exporter):
{"Severity": {
"Product": 1,
"Normalized": 100
}, "Resources": [{
"Type": "AwsEc2Instance",
"Id": issue['aws_instance_id']
}], "RecordState": "ACTIVE", "Title": "Multiple users have the same password",
}, "RecordState": "ACTIVE", "Title": "Multiple users have the same password",
"Description": "Some users are sharing passwords, this should be fixed by changing passwords.",
"Remediation": {
"Recommendation": {
@ -276,6 +310,14 @@ class AWSExporter(Exporter):
}
}}
if 'aws_instance_id' in issue:
finding["Resources"] = [{
"Type": "AwsEc2Instance",
"Id": issue['aws_instance_id']
}]
else:
finding["Resources"] = [{'Type': 'Other'}]
return finding
@staticmethod
@ -284,10 +326,7 @@ class AWSExporter(Exporter):
{"Severity": {
"Product": 10,
"Normalized": 100
}, "Resources": [{
"Type": "AwsEc2Instance",
"Id": issue['aws_instance_id']
}], "RecordState": "ACTIVE", "Title": "Machines are vulnerable to 'Shellshock'",
}, "RecordState": "ACTIVE", "Title": "Machines are vulnerable to 'Shellshock'",
"Description": "Update your Bash to a ShellShock-patched version.", "Remediation": {
"Recommendation": {
"Text": "The machine {0} ({1}) is vulnerable to a ShellShock attack. "
@ -296,6 +335,14 @@ class AWSExporter(Exporter):
}
}}
if 'aws_instance_id' in issue:
finding["Resources"] = [{
"Type": "AwsEc2Instance",
"Id": issue['aws_instance_id']
}]
else:
finding["Resources"] = [{'Type': 'Other'}]
return finding
@staticmethod
@ -304,10 +351,7 @@ class AWSExporter(Exporter):
{"Severity": {
"Product": 1,
"Normalized": 100
}, "Resources": [{
"Type": "AwsEc2Instance",
"Id": issue['aws_instance_id']
}], "RecordState": "ACTIVE",
}, "RecordState": "ACTIVE",
"Title": "Machines are accessible using passwords supplied by the user during the Monkey's configuration.",
"Description": "Change {0}'s password to a complex one-use password that is not shared with other computers on the network.".format(
issue['username']), "Remediation": {
@ -317,6 +361,14 @@ class AWSExporter(Exporter):
}
}}
if 'aws_instance_id' in issue:
finding["Resources"] = [{
"Type": "AwsEc2Instance",
"Id": issue['aws_instance_id']
}]
else:
finding["Resources"] = [{'Type': 'Other'}]
return finding
@staticmethod
@ -325,10 +377,7 @@ class AWSExporter(Exporter):
{"Severity": {
"Product": 1,
"Normalized": 100
}, "Resources": [{
"Type": "AwsEc2Instance",
"Id": issue['aws_instance_id']
}], "RecordState": "ACTIVE",
}, "RecordState": "ACTIVE",
"Title": "Machines are accessible using passwords supplied by the user during the Monkey's configuration.",
"Description": "Change {0}'s password to a complex one-use password that is not shared with other computers on the network.",
"Remediation": {
@ -338,6 +387,14 @@ class AWSExporter(Exporter):
}
}}
if 'aws_instance_id' in issue:
finding["Resources"] = [{
"Type": "AwsEc2Instance",
"Id": issue['aws_instance_id']
}]
else:
finding["Resources"] = [{'Type': 'Other'}]
return finding
@staticmethod
@ -346,10 +403,7 @@ class AWSExporter(Exporter):
{"Severity": {
"Product": 1,
"Normalized": 100
}, "Resources": [{
"Type": "AwsEc2Instance",
"Id": issue['aws_instance_id']
}], "RecordState": "ACTIVE",
}, "RecordState": "ACTIVE",
"Title": "Machines are accessible using passwords supplied by the user during the Monkey's configuration.",
"Description": "Change {0}'s password to a complex one-use password that is not shared with other computers on the network.".format(
issue['username']), "Remediation": {
@ -359,6 +413,14 @@ class AWSExporter(Exporter):
}
}}
if 'aws_instance_id' in issue:
finding["Resources"] = [{
"Type": "AwsEc2Instance",
"Id": issue['aws_instance_id']
}]
else:
finding["Resources"] = [{'Type': 'Other'}]
return finding
@staticmethod
@ -367,10 +429,7 @@ class AWSExporter(Exporter):
{"Severity": {
"Product": 1,
"Normalized": 100
}, "Resources": [{
"Type": "AwsEc2Instance",
"Id": issue['aws_instance_id']
}], "RecordState": "ACTIVE",
}, "RecordState": "ACTIVE",
"Title": "Machines are accessible using passwords supplied by the user during the Monkey's configuration.",
"Description": "Change {0}'s password to a complex one-use password that is not shared with other computers on the network.".format(
issue['username']), "Remediation": {
@ -380,6 +439,14 @@ class AWSExporter(Exporter):
}
}}
if 'aws_instance_id' in issue:
finding["Resources"] = [{
"Type": "AwsEc2Instance",
"Id": issue['aws_instance_id']
}]
else:
finding["Resources"] = [{'Type': 'Other'}]
return finding
@staticmethod
@ -388,10 +455,7 @@ class AWSExporter(Exporter):
{"Severity": {
"Product": 1,
"Normalized": 100
}, "Resources": [{
"Type": "AwsEc2Instance",
"Id": issue['aws_instance_id']
}], "RecordState": "ACTIVE", "Title": "Multiple users have the same password.",
}, "RecordState": "ACTIVE", "Title": "Multiple users have the same password.",
"Description": "Some domain users are sharing passwords, this should be fixed by changing passwords.",
"Remediation": {
"Recommendation": {
@ -400,6 +464,14 @@ class AWSExporter(Exporter):
}
}}
if 'aws_instance_id' in issue:
finding["Resources"] = [{
"Type": "AwsEc2Instance",
"Id": issue['aws_instance_id']
}]
else:
finding["Resources"] = [{'Type': 'Other'}]
return finding
@staticmethod
@ -408,10 +480,7 @@ class AWSExporter(Exporter):
{"Severity": {
"Product": 1,
"Normalized": 100
}, "Resources": [{
"Type": "AwsEc2Instance",
"Id": issue['aws_instance_id']
}], "RecordState": "ACTIVE",
}, "RecordState": "ACTIVE",
"Title": "Shared local administrator account - Different machines have the same account as a local administrator.",
"Description": "Make sure the right administrator accounts are managing the right machines, and that there isn\'t an unintentional local admin sharing.",
"Remediation": {
@ -421,6 +490,14 @@ class AWSExporter(Exporter):
}
}}
if 'aws_instance_id' in issue:
finding["Resources"] = [{
"Type": "AwsEc2Instance",
"Id": issue['aws_instance_id']
}]
else:
finding["Resources"] = [{'Type': 'Other'}]
return finding
@staticmethod
@ -429,10 +506,7 @@ class AWSExporter(Exporter):
{"Severity": {
"Product": 1,
"Normalized": 100
}, "Resources": [{
"Type": "AwsEc2Instance",
"Id": issue['aws_instance_id']
}], "RecordState": "ACTIVE",
}, "RecordState": "ACTIVE",
"Title": "Mimikatz found login credentials of a user who has admin access to a server defined as critical.",
"Description": "This critical machine is open to attacks via strong users with access to it.",
"Remediation": {
@ -442,6 +516,14 @@ class AWSExporter(Exporter):
}
}}
if 'aws_instance_id' in issue:
finding["Resources"] = [{
"Type": "AwsEc2Instance",
"Id": issue['aws_instance_id']
}]
else:
finding["Resources"] = [{'Type': 'Other'}]
return finding
@staticmethod
@ -450,10 +532,7 @@ class AWSExporter(Exporter):
{"Severity": {
"Product": 10,
"Normalized": 100
}, "Resources": [{
"Type": "AwsEc2Instance",
"Id": issue['aws_instance_id']
}], "RecordState": "ACTIVE", "Title": "Struts2 servers are vulnerable to remote code execution.",
}, "RecordState": "ACTIVE", "Title": "Struts2 servers are vulnerable to remote code execution.",
"Description": "Upgrade Struts2 to version 2.3.32 or 2.5.10.1 or any later versions.", "Remediation": {
"Recommendation": {
"Text": "Struts2 server at {machine} ({ip_address}) is vulnerable to remote code execution attack."
@ -462,6 +541,14 @@ class AWSExporter(Exporter):
}
}}
if 'aws_instance_id' in issue:
finding["Resources"] = [{
"Type": "AwsEc2Instance",
"Id": issue['aws_instance_id']
}]
else:
finding["Resources"] = [{'Type': 'Other'}]
return finding
@staticmethod
@ -470,10 +557,7 @@ class AWSExporter(Exporter):
{"Severity": {
"Product": 10,
"Normalized": 100
}, "Resources": [{
"Type": "AwsEc2Instance",
"Id": issue['aws_instance_id']
}], "RecordState": "ACTIVE", "Title": "Oracle WebLogic servers are vulnerable to remote code execution.",
}, "RecordState": "ACTIVE", "Title": "Oracle WebLogic servers are vulnerable to remote code execution.",
"Description": "Install Oracle critical patch updates. Or update to the latest version. " \
"Vulnerable versions are 10.3.6.0.0, 12.1.3.0.0, 12.2.1.1.0 and 12.2.1.2.0.",
"Remediation": {
@ -484,6 +568,14 @@ class AWSExporter(Exporter):
}
}}
if 'aws_instance_id' in issue:
finding["Resources"] = [{
"Type": "AwsEc2Instance",
"Id": issue['aws_instance_id']
}]
else:
finding["Resources"] = [{'Type': 'Other'}]
return finding
@staticmethod
@ -492,10 +584,7 @@ class AWSExporter(Exporter):
{"Severity": {
"Product": 10,
"Normalized": 100
}, "Resources": [{
"Type": "AwsEc2Instance",
"Id": issue['aws_instance_id']
}], "RecordState": "ACTIVE", "Title": "Hadoop/Yarn servers are vulnerable to remote code execution.",
}, "RecordState": "ACTIVE", "Title": "Hadoop/Yarn servers are vulnerable to remote code execution.",
"Description": "Run Hadoop in secure mode, add Kerberos authentication.", "Remediation": {
"Recommendation": {
"Text": "The Hadoop server at {machine} ({ip_address}) is vulnerable to remote code execution attack."
@ -503,4 +592,12 @@ class AWSExporter(Exporter):
}
}}
if 'aws_instance_id' in issue:
finding["Resources"] = [{
"Type": "AwsEc2Instance",
"Id": issue['aws_instance_id']
}]
else:
finding["Resources"] = [{'Type': 'Other'}]
return finding

View File

@ -1,6 +1,6 @@
{
"server_config": "standard",
"aws": {
"sec_hub_product_arn": "arn:aws:securityhub:eu-west-2:324264561773:product/guardicore/aws-infection-monkey"
"sec_hub_product_arn": "324264561773:product/guardicore/aws-infection-monkey"
}
}