Sample pull request
Synthetic: the test suite's made-up role app-worker in account 123456789012. No real account. Role app-worker, 90-day window. Nothing was applied to AWS.
The patch against iam/app.json
What git apply takes, against the policy file in your repo (indentation kept, so the hunk stays small):
--- a/iam/app.json
+++ b/iam/app.json
@@ -7,7 +7,6 @@
"Action": [
"s3:GetObject",
"s3:PutObject",
- "s3:DeleteBucket",
"s3:ListBucket"
],
"Resource": [
@@ -16,17 +15,10 @@
]
},
{
- "Sid": "Queue",
- "Effect": "Allow",
- "Action": "sqs:*",
- "Resource": "arn:aws:sqs:us-east-1:123456789012:jobs"
- },
- {
"Sid": "Dynamo",
"Effect": "Allow",
"Action": [
- "dynamodb:GetItem",
- "dynamodb:RestoreTableFromBackup"
+ "dynamodb:GetItem"
],
"Resource": "*"
},
@@ -35,17 +27,6 @@
"Effect": "Deny",
"Action": "iam:*",
"Resource": "*"
- },
- {
- "Sid": "Rotate",
- "Effect": "Allow",
- "Action": "secretsmanager:RotateSecret",
- "Resource": "*",
- "Condition": {
- "StringEquals": {
- "aws:ResourceTag/app": "worker"
- }
- }
}
]
}
The PR body
As the PR would carry it (Markdown, shown as text here):
## Least privilege for `app-worker`
Removes 5 permission(s) not used in the last 90 days (2 high, 0 medium, 3 low risk). Generated read-only by Dawnfix Leastpriv 0.5.0; nothing was applied to AWS.
**Evidence notes**
- IAM last-accessed data can lag by up to 4 hours and only covers authenticated calls this role made itself.
### legacy-ses (customer managed `arn:aws:iam::123456789012:policy/legacy-ses`)
Every statement was removed: detach and delete this policy.
| Risk | Action | Why it goes | Last used | Evidence |
|---|---|---|---|---|
| low | `ses:SendEmail` | the whole service was unused for 90+ days. Re-add if something breaks. | never | IAM last accessed |
<details><summary>json diff</summary>
```diff
--- a/iam/legacy_ses.json
+++ b/iam/legacy_ses.json
@@ -1,10 +0,0 @@
-{
- "Version": "2012-10-17",
- "Statement": [
- {
- "Effect": "Allow",
- "Action": "ses:SendEmail",
- "Resource": "*"
- }
- ]
-}
```
</details>
<details><summary>terraform diff</summary>
```diff
--- a/iam/legacy_ses.tf
+++ b/iam/legacy_ses.tf
@@ -1,7 +1 @@
-data "aws_iam_policy_document" "legacy_ses" {
- statement {
- effect = "Allow"
- actions = ["ses:SendEmail"]
- resources = ["*"]
- }
-}
+# legacy-ses: every statement was removed; delete this policy document and its attachment.
```
</details>
<details><summary>cloudformation diff</summary>
```diff
--- a/iam/legacy_ses.yaml
+++ b/iam/legacy_ses.yaml
@@ -1,7 +1 @@
-# legacy-ses
-PolicyDocument:
- Version: "2012-10-17"
- Statement:
- - Effect: "Allow"
- Action: "ses:SendEmail"
- Resource: "*"
+# legacy-ses: every statement was removed; delete this policy from the template.
```
</details>
### app (inline policy)
| Risk | Action | Why it goes | Last used | Evidence |
|---|---|---|---|---|
| high | `dynamodb:RestoreTableFromBackup` | restore/DR path: typically only exercised during an incident or a drill. Not seen in 90 days; a yearly or quarterly job would not show up in this window. Confirm with the owning team before merging. | never | IAM last accessed (action level) + Access Analyzer |
| high | `secretsmanager:RotateSecret` | secret rotation: runs every 30-90+ days. Not seen in 90 days; a yearly or quarterly job would not show up in this window. Confirm with the owning team before merging. | 2026-05-01 | IAM last accessed |
| low | `s3:DeleteBucket` | IAM tracks this action and saw no use in 90+ days; removing an unused destructive permission also shrinks the blast radius. Re-add if something breaks. | never | IAM last accessed (action level) |
| low | `sqs:*` | the whole service was unused for 90+ days; Access Analyzer agrees. Re-add if something breaks. | never | IAM last accessed + Access Analyzer |
<details><summary>json diff</summary>
```diff
--- a/iam/app.json
+++ b/iam/app.json
@@ -7,7 +7,6 @@
"Action": [
"s3:GetObject",
"s3:PutObject",
- "s3:DeleteBucket",
"s3:ListBucket"
],
"Resource": [
@@ -16,17 +15,10 @@
]
},
{
- "Sid": "Queue",
- "Effect": "Allow",
- "Action": "sqs:*",
- "Resource": "arn:aws:sqs:us-east-1:123456789012:jobs"
- },
- {
"Sid": "Dynamo",
"Effect": "Allow",
"Action": [
- "dynamodb:GetItem",
- "dynamodb:RestoreTableFromBackup"
+ "dynamodb:GetItem"
],
"Resource": "*"
},
@@ -35,17 +27,6 @@
"Effect": "Deny",
"Action": "iam:*",
"Resource": "*"
- },
- {
- "Sid": "Rotate",
- "Effect": "Allow",
- "Action": "secretsmanager:RotateSecret",
- "Resource": "*",
- "Condition": {
- "StringEquals": {
- "aws:ResourceTag/app": "worker"
- }
- }
}
]
}
```
</details>
<details><summary>terraform diff</summary>
```diff
--- a/iam/app.tf
+++ b/iam/app.tf
@@ -5,7 +5,6 @@
actions = [
"s3:GetObject",
"s3:PutObject",
- "s3:DeleteBucket",
"s3:ListBucket",
]
resources = [
@@ -14,18 +13,9 @@
]
}
statement {
- sid = "Queue"
- effect = "Allow"
- actions = ["sqs:*"]
- resources = ["arn:aws:sqs:us-east-1:123456789012:jobs"]
- }
- statement {
sid = "Dynamo"
effect = "Allow"
- actions = [
- "dynamodb:GetItem",
- "dynamodb:RestoreTableFromBackup",
- ]
+ actions = ["dynamodb:GetItem"]
resources = ["*"]
}
statement {
@@ -34,15 +24,4 @@
actions = ["iam:*"]
resources = ["*"]
}
- statement {
- sid = "Rotate"
- effect = "Allow"
- actions = ["secretsmanager:RotateSecret"]
- resources = ["*"]
- condition {
- test = "StringEquals"
- variable = "aws:ResourceTag/app"
- values = ["worker"]
- }
- }
}
```
</details>
<details><summary>cloudformation diff</summary>
```diff
--- a/iam/app.yaml
+++ b/iam/app.yaml
@@ -7,29 +7,16 @@
Action:
- "s3:GetObject"
- "s3:PutObject"
- - "s3:DeleteBucket"
- "s3:ListBucket"
Resource:
- "arn:aws:s3:::app-bucket"
- "arn:aws:s3:::app-bucket/*"
- - Sid: "Queue"
- Effect: "Allow"
- Action: "sqs:*"
- Resource: "arn:aws:sqs:us-east-1:123456789012:jobs"
- Sid: "Dynamo"
Effect: "Allow"
Action:
- "dynamodb:GetItem"
- - "dynamodb:RestoreTableFromBackup"
Resource: "*"
- Sid: "NoIam"
Effect: "Deny"
Action: "iam:*"
Resource: "*"
- - Sid: "Rotate"
- Effect: "Allow"
- Action: "secretsmanager:RotateSecret"
- Resource: "*"
- Condition:
- StringEquals:
- "aws:ResourceTag/app": "worker"
```
</details>
<sub>Merge only after the high-risk rows are confirmed. https://dawnfix.dev/leastpriv</sub>