|
4 | 4 |
|
5 | 5 | from infraguard.common.severity import Severity |
6 | 6 |
|
7 | | -# ── Dangerous actions ───────────────────────────────────────── |
8 | | -# Actions that grant significant control and should be flagged. |
9 | | - |
10 | 7 | DANGEROUS_ACTIONS: dict[str, Severity] = { |
11 | | - # IAM — identity escalation |
12 | 8 | "iam:CreateUser": Severity.HIGH, |
13 | 9 | "iam:CreateRole": Severity.HIGH, |
14 | 10 | "iam:AttachUserPolicy": Severity.CRITICAL, |
|
24 | 20 | "iam:CreatePolicyVersion": Severity.HIGH, |
25 | 21 | "iam:SetDefaultPolicyVersion": Severity.HIGH, |
26 | 22 |
|
27 | | - # STS — credential abuse |
28 | 23 | "sts:AssumeRole": Severity.MEDIUM, |
29 | 24 | "sts:AssumeRoleWithSAML": Severity.MEDIUM, |
30 | 25 | "sts:AssumeRoleWithWebIdentity": Severity.MEDIUM, |
31 | 26 | "sts:GetFederationToken": Severity.MEDIUM, |
32 | 27 |
|
33 | | - # S3 — data destruction |
34 | 28 | "s3:DeleteBucket": Severity.HIGH, |
35 | 29 | "s3:PutBucketPolicy": Severity.HIGH, |
36 | 30 | "s3:PutBucketAcl": Severity.HIGH, |
37 | 31 |
|
38 | | - # EC2 — infrastructure destruction |
39 | 32 | "ec2:TerminateInstances": Severity.HIGH, |
40 | 33 | "ec2:DeleteSecurityGroup": Severity.MEDIUM, |
41 | 34 | "ec2:AuthorizeSecurityGroupIngress": Severity.MEDIUM, |
42 | 35 | "ec2:ModifyInstanceAttribute": Severity.MEDIUM, |
43 | 36 |
|
44 | | - # RDS — data destruction |
45 | 37 | "rds:DeleteDBInstance": Severity.HIGH, |
46 | 38 | "rds:DeleteDBCluster": Severity.HIGH, |
47 | 39 | "rds:ModifyDBInstance": Severity.MEDIUM, |
48 | 40 |
|
49 | | - # Lambda — code execution |
50 | 41 | "lambda:CreateFunction": Severity.MEDIUM, |
51 | 42 | "lambda:UpdateFunctionCode": Severity.HIGH, |
52 | 43 | "lambda:AddPermission": Severity.HIGH, |
53 | 44 | "lambda:CreateEventSourceMapping": Severity.MEDIUM, |
54 | 45 |
|
55 | | - # KMS — encryption control |
56 | 46 | "kms:Decrypt": Severity.MEDIUM, |
57 | 47 | "kms:ScheduleKeyDeletion": Severity.CRITICAL, |
58 | 48 | "kms:DisableKey": Severity.HIGH, |
59 | 49 | "kms:PutKeyPolicy": Severity.CRITICAL, |
60 | 50 |
|
61 | | - # Organizations — org-level control |
62 | 51 | "organizations:LeaveOrganization": Severity.CRITICAL, |
63 | 52 | "organizations:DeleteOrganization": Severity.CRITICAL, |
64 | 53 |
|
65 | | - # CloudTrail — audit evasion |
66 | 54 | "cloudtrail:DeleteTrail": Severity.CRITICAL, |
67 | 55 | "cloudtrail:StopLogging": Severity.CRITICAL, |
68 | 56 | "cloudtrail:UpdateTrail": Severity.HIGH, |
69 | 57 |
|
70 | | - # GuardDuty — security evasion |
71 | 58 | "guardduty:DeleteDetector": Severity.CRITICAL, |
72 | 59 | "guardduty:DisassociateFromMasterAccount": Severity.HIGH, |
73 | 60 | } |
74 | 61 |
|
75 | | -# ── Sensitive action prefixes ───────────────────────────────── |
76 | | -# Actions on these services with broad wildcards are extra risky. |
77 | | - |
78 | 62 | SENSITIVE_SERVICE_PREFIXES: list[str] = [ |
79 | 63 | "iam:", |
80 | 64 | "sts:", |
|
87 | 71 | "access-analyzer:", |
88 | 72 | ] |
89 | 73 |
|
90 | | -# ── Suggested replacements for common overpermissions ───────── |
91 | | - |
92 | 74 | WILDCARD_SUGGESTIONS: dict[str, list[str]] = { |
93 | 75 | "s3:*": ["s3:GetObject", "s3:PutObject", "s3:ListBucket", "s3:GetBucketLocation"], |
94 | 76 | "ec2:*": ["ec2:DescribeInstances", "ec2:DescribeSecurityGroups", "ec2:DescribeVpcs"], |
|
0 commit comments