The lab
One Ubuntu VM and one Cloudflare account. Terraform configures Cloudflare; the VM runs everything else in Docker. Nothing here talks to AWS.
What runs where
| Component | What it is | Where |
|---|---|---|
| CWS proxy | The cws-proxy package from Cloudflare's APT repository, in a container. Loads deployment - every 30 seconds. | VM, cws-proxy:8080 |
| AWS Emulator | AWS's own local emulator of the AWS APIs, generated from the same models as the SDKs. In memory. | VM, internal only |
| aws-edge | Presents a certificate for *.amazonaws.com and forwards to the emulator. | VM, internal only |
| Lab DNS | Answers every *.amazonaws.com name with aws-edge's address. | VM, internal only |
| Git server + runner | This lab runs GitLab with a docker-executor runner: acme/acme-infra, with jobs on the lab network. Setup picks GitLab on a VM with 8 GB of RAM or more, and Gitea with its Actions runner on a smaller one - the demo is the same. | VM, |
| Exfiltration test | Node and the AWS SDK for JavaScript, unmodified. | VM, |
| This guide | A public, assets-only Worker, deployed from the VM with this lab's lab.json - nothing secret in it. | Workers, |
| cloudflared | Cloudflare Tunnel: the only way in to the exfiltration test and the git server, both behind Access. | VM, outbound only |
| CWS configuration | Deployment, policy sets, policies, workloads, Rego module and metadata, domain ACL, Basic Auth credentials. | Cloudflare account, by Terraform |
How AWS is emulated - and why it matters
The CWS proxy classifies a request by its destination. It knows s3.us-east-1.amazonaws.com; it does not
know 172.30.0.10:9297, and a request to a host it does not recognise is passed through untouched. So
pointing the AWS CLI at the emulator with AWS_ENDPOINT_URL, as the emulator's docs suggest, would make
every demo here meaningless.
Instead, every client calls AWS exactly as it would in production, and the lab redirects it underneath:
- The lab's DNS answers every
*.amazonaws.comname with the address of aws-edge. - aws-edge presents a certificate for those names, signed by the lab's own Lab AWS Emulator CA.
- It forwards to the emulator, which runs with signature checks off because the Host header has changed.
- Clients trust one bundle: the system roots, the CWS proxy's CA and the Lab AWS CA - so the same client works through CWS or straight to "AWS".
The result: the requests the proxy sees are byte-for-byte what it would see in front of real AWS.
The proxy, the policies and the Cloudflare API calls are the real product against a real account. The AWS responses come from the AWS Emulator, which AWS publishes and measures against real AWS. CWS makes its decision before the request reaches either, so the emulator cannot change what CWS does.
How the proxy gets into the path
A CI job and the exfiltration test both use the standard HTTPS_PROXY variable and trust the proxy's
CA - the pattern the CWS docs describe for CI/CD runners and application hosts. Nothing else changes: no SDK
plugin, no code change.
variables:
HTTPS_PROXY: "http://ci-pipeline:${CWS_PROXY_PASS}@cws-proxy:8080"
AWS_CA_BUNDLE: /certs/lab-trust.pem
In production the variable is not the control. Egress from the runners is limited to the proxy - with Gateway, a
firewall or a security group - so a job that drops the variable reaches nothing; and the deployment's domain ACL
limits the proxy to cloud API hostnames. The demo's CWS_BYPASS switch exists only to show the before.
The resources
| S3 | SQS | SNS | Kinesis | DynamoDB | |
|---|---|---|---|---|---|
| Acme's own - approved | acme-corp-data | acme-orders | acme-alerts | acme-clickstream | acme-customers |
| The attacker's - outside the perimeter | exfil-drop-bucket | exfil-drop-queue | exfil-drop-topic | exfil-drop-stream | exfil-drop-table |
The data perimeter's approved list: acme-corp-data, acme-website-assets, acme-orders, acme-alerts, acme-clickstream, acme-customers. acme-website-assets is created by the pipeline.
All in the emulator's single AWS account, 000000000000. Seeded by the exfiltration test whenever they are missing, so an emulator restart heals itself.
acme-infra
| infrastructure.json | Safe | Unsafe | Blocked by |
|---|---|---|---|
aws.website_bucket.public | false | true | aws-s3-no-public-buckets |
aws.orders_queue.encrypted | true | false | aws-sqs-encryption-required |
aws.deploy_role.managed_policy | …/ReadOnlyAccess | …/AdministratorAccess | aws-iam-no-admin |
cloudflare.assets_bucket.public | false | true | cf-r2-no-public-access |
cloudflare.origin_record.proxied | true | false | cf-dns-proxied-only |
CI/CD variables on the project: CWS_PROXY_PASS (masked), CF_API_TOKEN (masked),
CF_ACCOUNT_ID, CF_ZONE_ID, CF_ZONE_NAME, example AWS keys, and
CWS_BYPASS.
Proxy identities
| Basic Auth identity | Used by |
|---|---|
ci-pipeline | CI jobs in acme/acme-infra, on GitLab or Gitea |
workstation | The exfiltration test, and cws-lab shell on the VM |
Known differences from production
- The emulator keeps state in memory: a restart empties it.
sudo cws-lab reset --emulatordoes that on purpose. - The attacker's resources share the emulator's one account with Acme's, so the perimeter is by resource name rather than account.
- The emulator accepts SNS subscriptions but does not deliver to them.
- Anything the emulator has not implemented returns 501 - none of the operations in these demos.
Open the exfiltration test's Lab page for the same details from inside the app.