Skip to content

fix: avoid IAM inline policy temp file collision on concurrent scope creation#195

Merged
fedemaleh merged 1 commit into
betafrom
fix/iam-role-concurrent-tmp-collision
Jul 2, 2026
Merged

fix: avoid IAM inline policy temp file collision on concurrent scope creation#195
fedemaleh merged 1 commit into
betafrom
fix/iam-role-concurrent-tmp-collision

Conversation

@fedemaleh

Copy link
Copy Markdown
Collaborator

Summary

k8s/scope/iam/create_role wrote inline policy documents to a fixed path /tmp/inline-policy-$i.json, keyed only by the policy index. When multiple scopes were created concurrently on the same agent, distinct create_role runs overwrote each other's file between the echo and the aws iam put-role-policy call — sending the wrong policy JSON to IAM.

The fix moves the temp file into $OUTPUT_DIR, the per-command sandbox the agent already provides (and which the script already uses for trust-policy.json), eliminating the race without PIDs, mktemp, or locks.

Changes

  • k8s/scope/iam/create_role: /tmp/inline-policy-$i.json$OUTPUT_DIR/inline-policy-$i.json
  • k8s/scope/tests/iam/create_role.bats: new regression test asserting the --policy-document path is under $OUTPUT_DIR and never /tmp
  • CHANGELOG.md: unreleased entry

Test plan

@fedemaleh
fedemaleh merged commit 83063b8 into beta Jul 2, 2026
3 checks passed
@fedemaleh
fedemaleh deleted the fix/iam-role-concurrent-tmp-collision branch July 2, 2026 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants