Demo library › Chapter 3
Rules IAM cannot write
An unencrypted SQS queue and AdministratorAccess on a deployment role. IAM can say who may call CreateQueue and AttachRolePolicy; Cloud Workload Security decides on what the call actually asks for.
The problem
"Pipelines may create queues, but only encrypted ones." "Pipelines may attach policies to roles, but never AdministratorAccess." Both sound like IAM, and neither is something IAM expresses cleanly: there is no condition key for whether a new SQS queue is encrypted, and stopping one managed policy means permission boundaries on every role a pipeline might create.
Cloud Workload Security reads the request body, so the rule is written about what the call asks for, in a language built for policy.
Lands with: cloud security engineers who have tried to express these in IAM, SCPs or permission boundaries
Before you start
- Guardrails in CI/CD run, or at least acme-infra open with a green last pipeline.
infrastructure.jsonhas"encrypted": trueandReadOnlyAccess.
Run it
An unencrypted queue
| Do | Say |
|---|---|
Edit infrastructure.json: set aws.orders_queue.encrypted to false. Commit as Turn off queue encryption - debugging. | Someone is debugging and turns off encryption on the orders queue. IAM sees a SetQueueAttributes call from a principal that's allowed to make it. |
| Open the new pipeline's deploy-aws job. | Blocked. CWS read the attributes in the request - SqsManagedSseEnabled false, no KMS key - and refused it. |
Whybackground, if you are asked
aws-sqs-encryption-required. Its filter only selects SQS traffic, so the Rego runs only where it matters. The rule allows either SQS-managed encryption or a KMS key, and applies to CreateQueue as well as SetQueueAttributes - a new unencrypted queue is refused the same way.
Administrator access
| Do | Say |
|---|---|
Edit infrastructure.json: set aws.deploy_role.managed_policy to arn:aws:iam::aws:policy/AdministratorAccess, and encrypted back to true. Commit as Give the deploy role what it needs. | The classic shortcut. The deploy role keeps failing on permissions, so someone gives it everything. |
| Open deploy-aws. | The queue change went through - it's encrypted again - and the AdministratorAccess attachment was blocked. Same pipeline, same credentials, decided per call. |
Set the policy back to ReadOnlyAccess and commit. | And the safe version goes through. |
Whybackground, if you are asked
aws-iam-no-admin refuses the AdministratorAccess managed policy on any AttachRolePolicy, AttachUserPolicy or AttachGroupPolicy, and inline policies that allow every action on every resource. IAM is a query-protocol API, so the request is form-encoded - the helper module decodes it, which is why the policy can be four lines.
Show the rule
| Do | Say |
|---|---|
| Open Policies and expand aws-sqs-encryption-required. | This is the whole rule. Rego, from the Open Policy Agent project - the same language Kivera used, and the same as Kubernetes admission control. Version it, review it, test it. |
Whybackground, if you are asked
Every policy in this lab is unit-tested with opa test, against requests both as the proxy classifies them and as raw HTTP. The tests ship with the lab in vm/policies/tests.
What the audience should see
- A blocked SetQueueAttributes with SSE off.
- In one run, an allowed SetQueueAttributes and a blocked AttachRolePolicy.
- The Rego that made each decision.
Where the evidence is
Proxy decisions, filtered by eye to ci-pipeline: the denied SetQueueAttributes and AttachRolePolicy.
Known limitations
The emulator implements IAM and SQS well enough for these calls, but it is not AWS: role trust policies and permission boundaries are not enforced there. CWS's decision does not depend on any of that - it is made before the request reaches the emulator.
Part of: Guardrails for every pipeline