Dawnfix

That role has permissions nobody uses. Here is the PR.

Works with AWS IAM Terraform GitHubGitHub PythonPython

Dawnfix Leastpriv reads an IAM role's last-accessed data (and Access Analyzer's unused-access findings, when you have an analyzer), works out which permissions went unused for 90 days, and writes the change as a reviewable diff: a patch for your policy JSON in the repo, Terraform and CloudFormation renderings, and a PR body with a risk note for every removed action. It never changes IAM. Free and source available.

An IAM role's last-accessed data shows which permissions went unused for 90 days, and Leastpriv writes the trim as a pull request with a risk note for each removed action, without changing IAM. An IAM role app-worker · 3 policies attached 90 days of last-accessed data what the role actually called 5 permissions unused each with a risk note: high, medium, low A pull request to trim them JSON, Terraform, CloudFormation diffs
The sample: app-worker loses 5 permissions it has not used in 90 days. IAM is never changed; you merge.

How it decides

  • Removes only with evidence: a service unused in the window loses all its actions; an explicit action IAM tracks at action level and that went unused goes.
  • Keeps wildcards in a used service, Action: "*", NotAction and every Deny; for those it suggests the actions actually used instead.
  • AWS managed policies cannot be edited: it says to detach one and attach a customer managed document it writes.
  • Risk per removal: high for rare-but-critical actions (restore, failover, secret rotation, certificate renewal, iam:PassRole, deploy and scaling paths, break-glass); medium when the role is younger than the window; low otherwise.
  • Not covered yet: resource-level narrowing, permission boundaries and SCPs. Only the JSON patch applies to your repo file; the Terraform and CloudFormation diffs are renderings to copy from.

How to run it

  1. Install the CLI from PyPI. The dawnfix package (version 0.5.0, Python 3.11 or later) holds every Python tool. To build from source instead, clone dawnfix/dawnfix and run make install in its leastpriv/ folder:
    python3 -m venv .venv
    .venv/bin/pip install dawnfix==0.5.0
  2. Sign in to AWS, open the repo that holds the role's policy, then:
    .venv/bin/leastpriv role app-worker --days 90 --policy-file app=iam/app.json
    # -> leastpriv-out/pr.md, report.json, app.patch (git apply), *.diff
    It writes the PR body and the patch. You open the PR yourself, after review.
  3. Or use it from your coding agent: paste prompts/leastpriv.md. The agent runs the trim, shows the risk table and the patch, and opens the PR only when you say yes.

The IAM policy it needs

IAM and Access Analyzer reads. iam:GenerateServiceLastAccessedDetails starts a report job and changes no IAM entity (AWS's IAMReadOnlyAccess grants it too); access-analyzer:GenerateFindingRecommendation is deliberately left out. This is leastpriv/iam/leastpriv-read-only-policy.json, verbatim; the CLI refuses any call outside it before the request is built:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "DawnfixLeastprivReadOnly",
      "Effect": "Allow",
      "Action": [
        "access-analyzer:GetFindingV2",
        "access-analyzer:ListAnalyzers",
        "access-analyzer:ListFindingsV2",
        "iam:GenerateServiceLastAccessedDetails",
        "iam:GetPolicy",
        "iam:GetPolicyVersion",
        "iam:GetRole",
        "iam:GetRolePolicy",
        "iam:GetServiceLastAccessedDetails",
        "iam:ListAttachedRolePolicies",
        "iam:ListRolePolicies"
      ],
      "Resource": "*"
    }
  ]
}

IAM read access is sensitive in itself: give this to a separate role you assume only for the run.