desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'.. http:get:: /api/1/account_config/account_fields (all or custom)
Get a list of Account types
**Example Request**:
.. sourcecode:: http
GET /api/1/account_config/all HTTP/1.1
Host: example.com
Accept: application/json, text/javascript
**Example Response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept
Content-Typ... | def get(self, account_fields):
| load_all_account_types()
marshaled = {}
account_types = AccountType.query.all()
configs_marshaled = {}
for account_type in account_types:
acc_manager = account_registry.get(account_type.name)
if (acc_manager is not None):
values = {}
values['identifier_label']... |
'.. http:get:: /api/1/auditorsettings
Get a list of AuditorSetting items
**Example Request**:
.. sourcecode:: http
GET /api/1/auditorsettings HTTP/1.1
Host: example.com
Accept: application/json, text/javascript
**Example Response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Content-Type: application/json
count: 15,
items: [... | def get(self):
| self.reqparse.add_argument('count', type=int, default=30, location='args')
self.reqparse.add_argument('page', type=int, default=1, location='args')
self.reqparse.add_argument('accounts', type=str, default=None, location='args')
self.reqparse.add_argument('technologies', type=str, default=None, location=... |
'.. http:put:: /api/1/auditorsettings/<int ID>
Update an AuditorSetting
**Example Request**:
.. sourcecode:: http
PUT /api/1/auditorsettings/1 HTTP/1.1
Host: example.com
Accept: application/json, text/javascript
account: "aws-account-name",
disabled: false,
id: 1,
issue: "User with password login.",
technology: "iamuse... | def put(self, as_id):
| self.reqparse.add_argument('disabled', type=bool, required=True, location='json')
args = self.reqparse.parse_args()
disabled = args.pop('disabled', None)
results = AuditorSettings.query.get(as_id)
results.disabled = disabled
db.session.add(results)
db.session.commit()
return 200
|
'.. http:get:: /api/1/users
Get a list of users, checking that the requester is an admin.
**Example Request**:
.. sourcecode:: http
GET /api/1/users HTTP/1.1
Host: example.com
Accept: application/json
**Example Response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json
"auth": {
"authe... | def get(self):
| self.reqparse.add_argument('count', type=int, default=30, location='args')
self.reqparse.add_argument('page', type=int, default=1, location='args')
self.reqparse.add_argument('order_by', type=str, default=None, location='args')
self.reqparse.add_argument('order_dir', type=str, default='desc', location='... |
'.. http:delete:: /api/1/users/<int:user_id>
Change the settings for the current user.
**Example Request**:
.. sourcecode:: http
DELETE /api/1/users/15 HTTP/1.1
Host: example.com
Accept: application/json
**Example Response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json
:statuscode 2... | def delete(self, user_id):
| if (user_id == current_user.id):
return ({'status': 'Cannot modify own user account.'}, 403)
user = User.query.filter((User.id == user_id)).first()
if (not user):
return ({'status': 'User entry with the given ID not found.'}, 404)
db.session.delete(user)
... |
'.. http:put:: /api/1/users/<int:user_id>
Change the settings for the current user.
**Example Request**:
.. sourcecode:: http
PUT /api/1/users/15 HTTP/1.1
Host: example.com
Accept: application/json
"user": {
"active": true,
"email": "john@example.com",
"id": "15",
"roles": [
1,
2,
3,
6,
17,
21,
22
**Example Response**:... | def put(self, user_id):
| self.reqparse.add_argument('id', required=True, location='json', type=int)
self.reqparse.add_argument('email', required=True, location='json', type=unicode)
self.reqparse.add_argument('active', required=True, location='json', type=bool)
self.reqparse.add_argument('role_id', required=True, location='json... |
'.. http:get:: /api/1/roles
Get a list of roles, checking that the requester is an admin.
**Example Request**:
.. sourcecode:: http
GET /api/1/roles HTTP/1.1
Host: example.com
Accept: application/json
**Example Response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json
"auth": {
"authe... | def get(self):
| return_dict = {'auth': self.auth_dict}
roles = []
for name in RBACRole.roles:
roles.append({'name': RBACRole.roles[name].name})
return_dict['roles'] = roles
return (return_dict, 200)
|
'Alert when a KMS key is not configured for rotation
This is a AWS CIS Foundations Benchmark audit item (2.8)'
| def check_for_kms_key_rotation(self, kms_item):
| rotation_status = kms_item.config.get('KeyRotationEnabled')
if (not rotation_status):
self.add_issue(1, 'KMS key is not configured for rotation.', kms_item)
|
'alert when a KMS master key contains a policy giving permissions
to a foreign account'
| def check_for_kms_policy_with_foreign_account(self, kms_item):
| tag = '{0} contains policies with foreign account permissions.'.format(self.i_am_singular)
key_account_id = kms_item.config.get('AWSAccountId')
key_policies = kms_item.config.get('Policies')
for policy in key_policies:
for statement in policy.get('Statement'):
condi... |
'alert if non-vpc RDS SG contains RFC1918 CIDRS'
| def check_rds_ec2_rfc1918(self, sg_item):
| tag = 'Non-VPC RDS Security Group contains private RFC-1918 CIDR'
severity = 8
if sg_item.config.get('vpc_id', None):
return
for ipr in sg_item.config.get('ip_ranges', []):
cidr = ipr.get('cidr_ip', None)
if (cidr and check_rfc_1918(cidr)):
self.a... |
'Make sure the RDS SG does not contain large networks.'
| def check_securitygroup_large_subnet(self, sg_item):
| tag = 'RDS Security Group network larger than /24'
severity = 3
for ipr in sg_item.config.get('ip_ranges', []):
cidr = ipr.get('cidr_ip', None)
if (cidr and (not self._check_inclusion_in_network_whitelist(cidr))):
if (('/' in cidr) and (not (cidr == '0.0.0.0/0')... |
'Make sure the RDS SG does not contain a cidr with a subnet length of zero.'
| def check_securitygroup_zero_subnet(self, sg_item):
| tag = 'RDS Security Group subnet mask is /0'
severity = 10
for ipr in sg_item.config.get('ip_ranges', []):
cidr = ipr.get('cidr_ip', None)
if (cidr and ('/' in cidr) and (not (cidr == '0.0.0.0/0')) and (not (cidr == '10.0.0.0/8'))):
mask = int(cidr.split('/')[1]... |
'Make sure the RDS SG does not contain 0.0.0.0/0'
| def check_securitygroup_any(self, sg_item):
| tag = 'RDS Security Group contains 0.0.0.0/0'
severity = 5
for ipr in sg_item.config.get('ip_ranges', []):
cidr = ipr.get('cidr_ip')
if ('0.0.0.0/0' == cidr):
self.add_issue(severity, tag, sg_item, notes=cidr)
return
|
'Make sure the RDS SG does not contain 10.0.0.0/8'
| def check_securitygroup_10net(self, sg_item):
| tag = 'RDS Security Group contains 10.0.0.0/8'
severity = 5
for ipr in sg_item.config.get('ip_ranges', []):
cidr = ipr.get('cidr_ip')
if ('10.0.0.0/8' == cidr):
self.add_issue(severity, tag, sg_item, notes=cidr)
return
|
'alert when a public zone has private records.'
| def check_for_public_zone_with_private_records(self, route53_item):
| if (not route53_item.config.get('zoneprivate')):
for r in route53_item.config.get('records'):
for regex in self.internal_record_regex:
if re.match(regex, str(r)):
notes = ', '.join(route53_item.config.get('records'))
self.add_issue(1, 'R... |
'alert when not running in a VPC.'
| def check_running_in_vpc(self, redshift_cluster):
| if (not redshift_cluster.config.get('VpcId')):
message = 'POLICY - Redshift cluster not in VPC.'
self.add_issue(10, message, redshift_cluster)
|
'Check to see if a port range exists in the allowed field.'
| def _port_range_exists(self, allowed_list, error_cat='ALLOWED'):
| errors = []
for allowed in allowed_list:
ports = allowed.get('ports', None)
if ports:
for port in ports:
if (str(port).find('-') > (-1)):
ae = make_audit_issue(error_cat, 'EXISTS', 'PORTRANGE')
ae.notes = ('%s:%s' % (allowed['IP... |
'Check to see if target tags are present.'
| def _target_tags_valid(self, target_tags, error_cat='TARGET_TAGS'):
| errors = []
if (not target_tags):
ae = make_audit_issue(error_cat, 'FOUND', 'NOT')
errors.append(ae)
return errors
|
'Check to see if the source range field is set to allow all traffic'
| def _source_ranges_open(self, source_ranges, error_cat='SOURCE_RANGES'):
| errors = []
open_range = '0.0.0.0/0'
for source_range in source_ranges:
if (source_range == open_range):
ae = make_audit_issue(error_cat, 'OPEN', 'TRAFFIC')
errors.append(ae)
return errors
|
'Driver for Target Tags. Calls helpers as needed.
return: (bool, [list of AuditIssues])'
| def inspect_target_tags(self, item):
| errors = []
target_tags = item.config.get('TargetTags', None)
err = self._target_tags_valid(target_tags)
(errors.extend(err) if err else None)
if errors:
return (False, errors)
return (True, None)
|
'Driver for Source Ranges. Calls helpers as needed.
return: (bool, [list of AuditIssues])'
| def inspect_source_ranges(self, item):
| errors = []
source_ranges = item.config.get('SourceRanges', None)
if source_ranges:
err = self._source_ranges_open(source_ranges)
(errors.extend(err) if err else None)
if errors:
return (False, errors)
return (True, None)
|
'Driver for Allowed field (protocol/ports list). Calls helpers as needed.
return: (bool, [list of AuditIssues])'
| def inspect_allowed(self, item):
| errors = []
err = self._port_range_exists(item.config.get('Allowed'))
(errors.extend(err) if err else None)
if errors:
return (False, errors)
return (True, None)
|
'Look for legacy-style (non-subnetwork style) network.
return: [list of AuditIssues]'
| def _legacy_exists(self, network, error_cat='NET'):
| errors = []
subnetworks = network.get('Subnetworks', None)
auto_create_subnetworks = network.get('AutoCreateSubnetworks', None)
if ((subnetworks is None) and (auto_create_subnetworks is None)):
ae = make_audit_issue(error_cat, 'EXISTS', 'LEGACY')
errors.append(ae)
return errors
|
'Driver for Network. Calls helpers as needed.
return: (bool, [list of AuditIssues])'
| def inspect_network(self, item):
| errors = []
network = item.config
err = self._legacy_exists(network)
(errors.extend(err) if err else None)
if errors:
return (False, errors)
return (True, None)
|
'Alert when a service account has too many keys.
return: [list of AuditIssues]'
| def _max_keys(self, key_count, error_cat='SA'):
| errors = []
if (key_count > self.gcp_config.MAX_SERVICEACCOUNT_KEYS):
ae = make_audit_issue(error_cat, 'MAX', 'KEYS')
ae.notes = ('Too Many Keys (count: %s, max: %s)' % (key_count, self.gcp_config.MAX_SERVICEACCOUNT_KEYS))
errors.append(ae)
return errors
|
'Determine if a serviceaccount actor is specified.
return: [list of AuditIssues]'
| def _actor_role(self, policies, error_cat='SA'):
| errors = []
for policy in policies:
role = policy.get('Role')
if (role and (role == 'iam.serviceAccountActor')):
ae = make_audit_issue(error_cat, 'POLICY', 'ROLE', 'ACTOR')
errors.append(ae)
return errors
|
'Driver for ServiceAccount. Calls helpers as needed.
return: (bool, [list of AuditIssues])'
| def inspect_serviceaccount(self, item):
| errors = []
err = self._max_keys(item.config.get('keys'))
(errors.extend(err) if err else None)
policies = item.config.get('policy')
if policies:
err = self._actor_role(policies)
(errors.extend(err) if err else None)
if errors:
return (False, errors)
return (True, Non... |
'Looks for allUsers in acl.
return: [list of AuditIssues]'
| def _acl_allusers_exists(self, acl_list, error_cat='ACL'):
| allusers = 'allUsers'
errors = []
for acl in acl_list:
entity = acl.get('entity')
role = acl.get('role')
if (entity == allusers):
ae = make_audit_issue(error_cat, 'ROLE', allusers, role)
errors.append(ae)
return errors
|
'Looks for Max OWNERS in acl.
return: [list of AuditIssues]'
| def _acl_max_owners(self, acl_list, error_cat='ACL'):
| errors = []
if self.gcp_config.MAX_OWNERS_PER_BUCKET:
owner = 'OWNER'
count = 0
for acl in acl_list:
role = acl.get('role')
if (role == owner):
count += 1
if (count > self.gcp_config.MAX_OWNERS_PER_BUCKET):
ae = ... |
'Looks at the CORS method. Anything other than GET is flagged.
return: [list of AuditIssues]'
| def _cors_method(self, cors_list, error_cat='CORS'):
| errors = []
for cors in cors_list:
methods = cors.get('method')
for method in methods:
if (method == '*'):
method = 'ALL'
if (method != 'GET'):
ae = make_audit_issue(error_cat, 'METHOD', method)
errors.append(ae)
return ... |
'Driver for Bucket ACL. Calls helpers as needed.
return: (bool, [list of AuditIssues])'
| def inspect_acl(self, item):
| acl = item.config.get('Acl')
errors_acl = []
if acl:
err = self._acl_allusers_exists(acl, 'ACL')
(errors_acl.extend(err) if err else None)
err = self._acl_max_owners(acl, 'ACL')
(errors_acl.extend(err) if err else None)
if errors_acl:
return (False, errors... |
'Driver for Default Object ACL. Calls helpers as needed.
return: (bool, [list of AuditIssues])'
| def inspect_default_object_acl(self, item):
| def_obj_acl = item.config.get('DefaultObjectAcl')
errors_acl = []
if def_obj_acl:
err = self._acl_allusers_exists(def_obj_acl, 'DEFAULT_OBJECT_ACL')
(errors_acl.extend(err) if err else None)
err = self._acl_max_owners(def_obj_acl, 'DEFAULT_OBJECT_ACL')
(errors_acl.extend(err)... |
'Driver for CORS field. Calls helpers as needed.
return: (bool, [list of AuditIssues])'
| def inspect_cors(self, item):
| cors = item.config.get('Cors')
if cors:
errors = []
err = self._cors_method(cors)
(errors.extend(err) if err else None)
if errors:
return (False, errors)
return (True, None)
|
'Check CORS field.
CORS policy is set with: gsutil cors set /tmp/cors.json gs://your-bucket'
| def check_cors(self, item):
| (ok, errors) = self.inspect_cors(item)
process_issues(self, ok, errors, item)
|
'alert on empty SNS Policy'
| def check_snstopicpolicy_empty(self, snsitem):
| tag = 'SNS Topic Policy is empty'
severity = 1
if (snsitem.config.get('policy', {}) == {}):
self.add_issue(severity, tag, snsitem, notes=None)
|
'"subscriptions": [
"Owner": "020202020202",
"Endpoint": "someemail@example.com",
"Protocol": "email",
"TopicArn": "arn:aws:sns:us-east-1:020202020202:somesnstopic",
"SubscriptionArn": "arn:aws:sns:us-east-1:020202020202:somesnstopic:..."'
| def check_subscriptions_crossaccount(self, snsitem):
| subscriptions = snsitem.config.get('subscriptions', [])
for subscription in subscriptions:
source = '{0} subscription to {1}'.format(subscription.get('Protocol', None), subscription.get('Endpoint', None))
owner = subscription.get('Owner', None)
self._check_cross_account(owner, s... |
'alert on cross account access'
| def check_snstopicpolicy_crossaccount(self, snsitem):
| policy = snsitem.config.get('policy', {})
for statement in policy.get('Statement', []):
account_numbers = []
princ = statement.get('Principal', {})
if isinstance(princ, dict):
princ_val = (princ.get('AWS') or princ.get('Service'))
else:
princ_val = princ
... |
'alert on cross account access'
| def check_sqsqueue_crossaccount(self, sqsitem):
| policy = sqsitem.config
for statement in policy.get('Statement', []):
account_numbers = []
princ = statement.get('Principal', None)
if (not princ):
tag = 'SQS Policy is lacking Principal field'
notes = json.dumps(statement)
self.add_issu... |
'alert when an ELB has an "internet-facing" scheme.'
| def check_internet_scheme(self, elb_item):
| scheme = elb_item.config.get('Scheme', None)
vpc = elb_item.config.get('VPCId', None)
if (scheme and (scheme == u'internet-facing') and (not vpc)):
self.add_issue(1, 'ELB is Internet accessible.', elb_item)
elif (scheme and (scheme == u'internet-facing') and vpc):
security_group... |
'alert when an SSL listener is not using the latest reference policy.'
| def check_listener_reference_policy(self, elb_item):
| policy_port_map = defaultdict(list)
for listener in elb_item.config.get('ListenerDescriptions'):
if (len(listener.get('PolicyNames', [])) > 0):
for name in listener.get('PolicyNames', []):
policy_port_map[name].append(listener['LoadBalancerPort'])
policies = elb_item.conf... |
'Alert when elb logging is not enabled'
| def check_logging(self, elb_item):
| logging = elb_item.config.get('Attributes', {}).get('AccessLog', {})
if (not logging):
self.add_issue(1, 'ELB is not configured for logging.', elb_item)
return
if (not logging.get('Enabled')):
self.add_issue(1, 'ELB is not configured for logging.', elb_i... |
'Alerts on:
sslv2
sslv3
missing server order preference
deprecated ciphers'
| def _process_custom_listener_policy(self, policy_name, policy, port, elb_item):
| notes = 'Policy {0} on port {1}'.format(policy_name, port)
if policy.get('protocols', {}).get('sslv2', None):
self.add_issue(10, 'SSLv2 is enabled', elb_item, notes=notes)
if policy.get('protocols', {}).get('sslv3', None):
self.add_issue(10, 'SSLv3 is enabled', elb_it... |
'Looks at the from_port and to_port and returns a sane representation'
| def _port_for_rule(self, rule):
| if (rule['from_port'] == rule['to_port']):
return '{} {}'.format(rule['ip_protocol'], rule['from_port'])
return '{} {}-{}'.format(rule['ip_protocol'], rule['from_port'], rule['to_port'])
|
'alert if EC2 SG contains RFC1918 CIDRS'
| def check_securitygroup_ec2_rfc1918(self, sg_item):
| tag = 'Non-VPC Security Group contains private RFC-1918 CIDR'
severity = 5
if sg_item.config.get('vpc_id', None):
return
multiplier = _check_empty_security_group(sg_item)
for rule in sg_item.config.get('rules', []):
cidr = rule.get('cidr_ip', None)
if (cidr ... |
'alert if SG has more than 50 rules'
| def check_securitygroup_rule_count(self, sg_item):
| tag = 'Security Group contains 50 or more rules'
severity = 1
multiplier = _check_empty_security_group(sg_item)
rules = sg_item.config.get('rules', [])
if (len(rules) >= 50):
self.add_issue((severity * multiplier), tag, sg_item)
|
'Make sure the SG does not contain large port ranges.'
| def check_securitygroup_large_port_range(self, sg_item):
| multiplier = _check_empty_security_group(sg_item)
for rule in sg_item.config.get('rules', []):
if (rule['from_port'] == rule['to_port']):
continue
from_port = int(rule['from_port'])
to_port = int(rule['to_port'])
range_size = (to_port - from_port)
name = ''
... |
'Make sure the SG does not contain large networks.'
| def check_securitygroup_large_subnet(self, sg_item):
| tag = 'Security Group network larger than /24'
severity = 3
multiplier = _check_empty_security_group(sg_item)
for rule in sg_item.config.get('rules', []):
cidr = rule.get('cidr_ip', None)
if (cidr and (not self._check_inclusion_in_network_whitelist(cidr))):
if ... |
'Make sure the SG does not contain a cidr with a subnet length of zero.'
| def check_securitygroup_zero_subnet(self, sg_item):
| tag = 'Security Group subnet mask is /0'
severity = 10
multiplier = _check_empty_security_group(sg_item)
for rule in sg_item.config.get('rules', []):
cidr = rule.get('cidr_ip', None)
if (cidr and ('/' in cidr) and (not (cidr == '0.0.0.0/0')) and (not (cidr == '10.0.0.0/8')... |
'Make sure the SG does not contain any 0.0.0.0/0 or ::/0 ingress rules'
| def check_securitygroup_ingress_any(self, sg_item):
| tag = 'Security Group ingress rule contains 0.0.0.0/0'
severity = 10
multiplier = _check_empty_security_group(sg_item)
for rule in sg_item.config.get('rules', []):
cidr = rule.get('cidr_ip')
rtype = rule.get('rule_type')
if (('0.0.0.0/0' == cidr) and (rtype == 'ing... |
'Make sure the SG does not contain any 0.0.0.0/0 or ::/0 egress rules'
| def check_securitygroup_egress_any(self, sg_item):
| tag = 'Security Group egress rule contains 0.0.0.0/0'
severity = 5
multiplier = _check_empty_security_group(sg_item)
for rule in sg_item.config.get('rules', []):
cidr = rule.get('cidr_ip')
rtype = rule.get('rule_type')
if (('0.0.0.0/0' == cidr) and (rtype == 'egres... |
'Make sure the SG does not contain 10.0.0.0/8'
| def check_securitygroup_10net(self, sg_item):
| tag = 'Security Group contains 10.0.0.0/8'
severity = 5
if sg_item.config.get('vpc_id', None):
return
multiplier = _check_empty_security_group(sg_item)
for rule in sg_item.config.get('rules', []):
cidr = rule.get('cidr_ip')
if ('10.0.0.0/8' == cidr):
note... |
'Prepare for the audit by calculating 90 days ago.
This is used to check if access keys have been rotated.'
| def prep_for_audit(self):
| now = datetime.datetime.now()
then = (now - datetime.timedelta(days=90))
self.ninety_days_ago = then.replace(tzinfo=tz.gettz('UTC'))
|
'alert when an IAM User has an active access key.
score: 1'
| def check_active_access_keys(self, iamuser_item):
| akeys = iamuser_item.config.get('AccessKeys', {})
for akey in akeys:
if ('Status' in akey):
if (akey['Status'] == 'Active'):
self.add_issue(1, 'User has active accesskey.', iamuser_item, notes=akey['AccessKeyId'])
|
'alert when an IAM User has an inactive access key.
score: 0'
| def check_inactive_access_keys(self, iamuser_item):
| akeys = iamuser_item.config.get('AccessKeys', {})
for akey in akeys:
if ('Status' in akey):
if (akey['Status'] != 'Active'):
self.add_issue(0, 'User has an inactive accesskey.', iamuser_item, notes=akey['AccessKeyId'])
|
'alert when an IAM User has an active access key created more than 90 days go.'
| def check_access_key_rotation(self, iamuser_item):
| akeys = iamuser_item.config.get('AccessKeys', {})
for akey in akeys:
if ('Status' in akey):
if (akey['Status'] == 'Active'):
create_date = akey['CreateDate']
create_date = parser.parse(create_date)
if (create_date < self.ninety_days_ago):
... |
'alert if an active access key hasn\'t been used in 90 days'
| def check_access_key_last_used(self, iamuser_item):
| akeys = iamuser_item.config.get('AccessKeys', {})
for akey in akeys:
if ('Status' in akey):
if (akey['Status'] == 'Active'):
last_used_str = akey.get('LastUsedDate')
if (not last_used_str):
continue
last_used_date = parser.p... |
'alert when an IAM User has a policy allowing \'*\'.'
| def check_star_privileges(self, iamuser_item):
| self.library_check_iamobj_has_star_privileges(iamuser_item, policies_key='InlinePolicies')
|
'alert when an IAM User has a policy allowing \'iam:*\'.'
| def check_iam_star_privileges(self, iamuser_item):
| self.library_check_iamobj_has_iam_star_privileges(iamuser_item, policies_key='InlinePolicies')
|
'alert when an IAM User has a policy allowing \'iam:XxxxxXxxx\'.'
| def check_iam_privileges(self, iamuser_item):
| self.library_check_iamobj_has_iam_privileges(iamuser_item, policies_key='InlinePolicies')
|
'alert when an IAM User has a policy allowing \'iam:PassRole\'.
This allows the user to pass any role specified in the resource block to an ec2 instance.'
| def check_iam_passrole(self, iamuser_item):
| self.library_check_iamobj_has_iam_passrole(iamuser_item, policies_key='InlinePolicies')
|
'alert when an IAM User has a policy containing \'NotAction\'.
NotAction combined with an "Effect": "Allow" often provides more privilege
than is desired.'
| def check_notaction(self, iamuser_item):
| self.library_check_iamobj_has_notaction(iamuser_item, policies_key='InlinePolicies')
|
'alert when an IAM User has ec2:AuthorizeSecurityGroupEgress or ec2:AuthorizeSecurityGroupIngress.'
| def check_security_group_permissions(self, iamuser_item):
| self.library_check_iamobj_has_security_group_permissions(iamuser_item, policies_key='InlinePolicies')
|
'alert when an IAM user has a login profile and no MFA devices.
This means a human account which could be better protected with 2FA.'
| def check_no_mfa(self, iamuser_item):
| user_mfas = iamuser_item.config.get('MfaDevices', {})
login_profile = iamuser_item.config.get('LoginProfile', {})
if (login_profile and (not user_mfas)):
self.add_issue(1, 'User with password login and no MFA devices.', iamuser_item)
|
'alert when an IAM user has a login profile and API access via access keys.
An account should be used Either for API access OR for console access, but maybe not both.'
| def check_loginprofile_plus_akeys(self, iamuser_item):
| if (not iamuser_item.config.get('LoginProfile', None)):
return
akeys = iamuser_item.config.get('AccessKeys', {})
for akey in akeys:
if (('Status' in akey) and (akey['Status'] == 'Active')):
self.add_issue(1, 'User with password login and API access.', iamuser_it... |
'alert when an IAM Role is attached to a managed policy with issues'
| def check_attached_managed_policies(self, iamuser_item):
| self.library_check_attached_managed_policies(iamuser_item, 'user')
|
'alert when missing issuer.'
| def check_issuer(self, cert_item):
| issuer = cert_item.config.get('issuer', None)
if (issuer and ('ERROR_EXTRACTING_ISSUER' in issuer)):
self.add_issue(10, 'Could not extract valid certificate issuer.', cert_item, notes=issuer)
|
'alert when a cert is using less than 1024 bits'
| def check_cert_size_lt_1024(self, cert_item):
| size = cert_item.config.get('size', None)
if (size and (size < 1024)):
notes = 'Actual size is {0} bits.'.format(size)
self.add_issue(10, 'Cert size is less than 1024 bits.', cert_item, notes=notes)
|
'alert when a cert is using less than 2048 bits'
| def check_cert_size_lt_2048(self, cert_item):
| size = cert_item.config.get('size', None)
if (size and (1024 <= size < 2048)):
notes = 'Actual size is {0} bits.'.format(size)
self.add_issue(3, 'Cert size is less than 2048 bits.', cert_item, notes=notes)
|
'alert when a cert is using md5 for the hashing part
of the signature algorithm'
| def check_signature_algorith_for_md5(self, cert_item):
| sig_alg = cert_item.config.get('signature_algorithm', None)
if (sig_alg and ('md5' in sig_alg.lower())):
self.add_issue(3, 'Cert uses an MD5 signature Algorithm', cert_item, notes=sig_alg)
|
'alert when a cert is using sha1 for the hashing part of
its signature algorithm.
Microsoft and Google are aiming to drop support for sha1 by January 2017.'
| def check_signature_algorith_for_sha1(self, cert_item):
| sig_alg = cert_item.config.get('signature_algorithm', None)
if (sig_alg and ('sha1' in sig_alg.lower())):
self.add_issue(1, 'Cert uses an SHA1 signature Algorithm', cert_item, notes=sig_alg)
|
'alert when a cert\'s expiration is within 30 days'
| def check_upcoming_expiration(self, cert_item):
| expiration = cert_item.config.get('expiration', None)
if expiration:
expiration = parser.parse(expiration)
now = expiration.now(tzutc())
time_to_expiration = (expiration - now).days
if (0 <= time_to_expiration <= 30):
notes = 'Expires on {0}.'.format(str(expirat... |
'alert when a cert\'s expiration is within 60 days'
| def check_future_expiration(self, cert_item):
| expiration = cert_item.config.get('expiration', None)
if expiration:
expiration = parser.parse(expiration)
now = expiration.now(tzutc())
time_to_expiration = (expiration - now).days
if (0 <= time_to_expiration <= 60):
notes = 'Expires on {0}.'.format(str(expirat... |
'alert when a cert\'s expiration is within 30 days'
| def check_expired(self, cert_item):
| expiration = cert_item.config.get('expiration', None)
if expiration:
expiration = parser.parse(expiration)
now = expiration.now(tzutc())
time_to_expiration = (expiration - now).days
if (time_to_expiration < 0):
notes = 'Expired on {0}.'.format(str(expiration))
... |
'alert when a cert was uploaded pre-heartbleed.'
| def check_upload_date_for_heartbleed(self, cert_item):
| upload = cert_item.config.get('upload_date', None)
if upload:
upload = parser.parse(upload)
heartbleed = parser.parse(HEARTBLEED_DATE)
if (upload < heartbleed):
notes = 'Cert was uploaded {0} days before heartbleed.'.format((heartbleed - upload).days)
... |
'No prep necessary.'
| def prep_for_audit(self):
| pass
|
'alert when an IAM Object has a policy allowing \'*\'.'
| def check_star_privileges(self, iam_object):
| if ((not is_aws_managed_policy(iam_object)) or (is_aws_managed_policy(iam_object) and has_attached_resources(iam_object))):
self.library_check_iamobj_has_star_privileges(iam_object, policies_key='policy', multiple_policies=False)
|
'alert when an IAM Object has a policy allowing \'iam:*\'.'
| def check_iam_star_privileges(self, iam_object):
| if ((not is_aws_managed_policy(iam_object)) or (is_aws_managed_policy(iam_object) and has_attached_resources(iam_object))):
self.library_check_iamobj_has_iam_star_privileges(iam_object, policies_key='policy', multiple_policies=False)
|
'alert when an IAM Object has a policy allowing \'iam:XxxxxXxxx\'.'
| def check_iam_privileges(self, iam_object):
| if ((not is_aws_managed_policy(iam_object)) or (is_aws_managed_policy(iam_object) and has_attached_resources(iam_object))):
self.library_check_iamobj_has_iam_privileges(iam_object, policies_key='policy', multiple_policies=False)
|
'alert when an IAM Object has a policy allowing \'iam:PassRole\'.
This allows the object to pass any role specified in the resource block to an ec2 instance.'
| def check_iam_passrole(self, iam_object):
| if ((not is_aws_managed_policy(iam_object)) or (is_aws_managed_policy(iam_object) and has_attached_resources(iam_object))):
self.library_check_iamobj_has_iam_passrole(iam_object, policies_key='policy', multiple_policies=False)
|
'alert when an IAM Object has a policy containing \'NotAction\'.
NotAction combined with an "Effect": "Allow" often provides more privilege
than is desired.'
| def check_notaction(self, iam_object):
| if ((not is_aws_managed_policy(iam_object)) or (is_aws_managed_policy(iam_object) and has_attached_resources(iam_object))):
self.library_check_iamobj_has_notaction(iam_object, policies_key='policy', multiple_policies=False)
|
'alert when an IAM Object has ec2:AuthorizeSecurityGroupEgress or ec2:AuthorizeSecurityGroupIngress.'
| def check_security_group_permissions(self, iam_object):
| if ((not is_aws_managed_policy(iam_object)) or (is_aws_managed_policy(iam_object) and has_attached_resources(iam_object))):
self.library_check_iamobj_has_security_group_permissions(iam_object, policies_key='policy', multiple_policies=False)
|
'alert when an IAM Group has a policy allowing \'*\'.'
| def check_star_privileges(self, iamgroup_item):
| self.library_check_iamobj_has_star_privileges(iamgroup_item, policies_key='grouppolicies')
|
'alert when an IAM Group has a policy allowing \'iam:*\'.'
| def check_iam_star_privileges(self, iamgroup_item):
| self.library_check_iamobj_has_iam_star_privileges(iamgroup_item, policies_key='grouppolicies')
|
'alert when an IAM Group has a policy allowing \'iam:XxxxxXxxx\'.'
| def check_iam_privileges(self, iamgroup_item):
| self.library_check_iamobj_has_iam_privileges(iamgroup_item, policies_key='grouppolicies')
|
'alert when an IAM Group has a policy allowing \'iam:PassRole\'.
This allows the group to pass any role specified in the resource block to an ec2 instance.'
| def check_iam_passrole(self, iamgroup_item):
| self.library_check_iamobj_has_iam_passrole(iamgroup_item, policies_key='grouppolicies')
|
'alert when an IAM Group has a policy containing \'NotAction\'.
NotAction combined with an "Effect": "Allow" often provides more privilege
than is desired.'
| def check_notaction(self, iamgroup_item):
| self.library_check_iamobj_has_notaction(iamgroup_item, policies_key='grouppolicies')
|
'alert when an IAM Group has ec2:AuthorizeSecurityGroupEgress or ec2:AuthorizeSecurityGroupIngress.'
| def check_security_group_permissions(self, iamgroup_item):
| self.library_check_iamobj_has_security_group_permissions(iamgroup_item, policies_key='grouppolicies')
|
'alert when an IAM Group is attached to a managed policy with issues'
| def check_attached_managed_policies(self, iamgroup_item):
| self.library_check_attached_managed_policies(iamgroup_item, 'group')
|
'alert when an IAM Role has an assume_role_policy_document but using a star
instead of limiting the assume to a specific IAM Role.'
| def check_star_assume_role_policy(self, iamrole_item):
| tag = '{0} allows assume-role from anyone'.format(self.i_am_singular)
def check_statement(statement):
action = statement.get('Action', None)
if (action and (action == 'sts:AssumeRole')):
effect = statement.get('Effect', None)
if (effect and (effect == 'Allow')... |
'alert when an IAM Role has an assume_role_policy_document granting access to an unknown account'
| def check_assume_role_from_unknown_account(self, iamrole_item):
| def check_statement(statement):
def check_account_in_arn(input):
from security_monkey.common.arn import ARN
arn = ARN(input)
if arn.error:
print 'Could not parse ARN in Trust Policy: {arn}'.format(arn=input)
if ((not arn.er... |
'alert when an IAM Role has a policy allowing \'*\'.'
| def check_star_privileges(self, iamrole_item):
| self.library_check_iamobj_has_star_privileges(iamrole_item, policies_key='InlinePolicies')
|
'alert when an IAM Role has a policy allowing \'iam:*\'.'
| def check_iam_star_privileges(self, iamrole_item):
| self.library_check_iamobj_has_iam_star_privileges(iamrole_item, policies_key='InlinePolicies')
|
'alert when an IAM Role has a policy allowing \'iam:XxxxxXxxx\'.'
| def check_iam_privileges(self, iamrole_item):
| self.library_check_iamobj_has_iam_privileges(iamrole_item, policies_key='InlinePolicies')
|
'alert when an IAM Role has a policy allowing \'iam:PassRole\'.
This allows the role to pass any role specified in the resource block to an ec2 instance.'
| def check_iam_passrole(self, iamrole_item):
| self.library_check_iamobj_has_iam_passrole(iamrole_item, policies_key='InlinePolicies')
|
'alert when an IAM Role has a policy containing \'NotAction\'.
NotAction combined with an "Effect": "Allow" often provides more privilege
than is desired.'
| def check_notaction(self, iamrole_item):
| self.library_check_iamobj_has_notaction(iamrole_item, policies_key='InlinePolicies')
|
'alert when an IAM Role has ec2:AuthorizeSecurityGroupEgress or ec2:AuthorizeSecurityGroupIngress.'
| def check_security_group_permissions(self, iamrole_item):
| self.library_check_iamobj_has_security_group_permissions(iamrole_item, policies_key='InlinePolicies')
|
'alert when an IAM Role is attached to a managed policy with issues'
| def check_attached_managed_policies(self, iamrole_item):
| self.library_check_attached_managed_policies(iamrole_item, 'role')
|
'alert when an IAM Object has a policy allowing \'*\'.'
| def library_check_iamobj_has_star_privileges(self, iamobj_item, policies_key='InlinePolicies', multiple_policies=True):
| tag = '{0} has full admin privileges.'.format(self.i_am_singular)
def check_statement(statement):
if (statement['Effect'] == 'Allow'):
if (('Action' in statement) and (type(statement['Action']) is list)):
for action in statement['Action']:
if (... |
'alert when an IAM Object has a policy allowing \'iam:*\'.'
| def library_check_iamobj_has_iam_star_privileges(self, iamobj_item, policies_key='InlinePolicies', multiple_policies=True):
| tag = '{0} has full IAM privileges.'.format(self.i_am_singular)
def check_statement(statement):
if (statement['Effect'] == 'Allow'):
if (('Action' in statement) and (type(statement['Action']) is list)):
for action in statement['Action']:
if (ac... |
'alert when an IAM Object has a policy allowing \'iam:XxxxxXxxx\'.'
| def library_check_iamobj_has_iam_privileges(self, iamobj_item, policies_key='InlinePolicies', multiple_policies=True):
| tag = '{0} has IAM privileges.'.format(self.i_am_singular)
def check_statement(statement):
if (statement['Effect'] == 'Allow'):
if (('Action' in statement) and (type(statement['Action']) is list)):
for action in statement['Action']:
if (action.low... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.