write a web CTF, focused on initial access, that has as part of the initial chain a CPU vuln, like side channel or something like that, it should be a extreme difficulty CTF, the web in general should have a long chain with things like XXE, and side channel just a little part of it, it should be at least googlectf level]
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Title: “0xDECAFBAD: The Last Espresso”
Difficulty: Extreme (GoogleCTF / Plaid++ tier)
Theme: You are a red-team operator hired to steal the secret recipe of “0xDECAFBAD”, a boutique coffee start-up whose beans are rumored to be roasted with a side-channel resistant RNG. The only public surface is a shiny VueJS web store. Everything else is air-gapped, except for a single out-of-band vCPU feature that leaks state across SMT siblings.
Goal: From unauthenticated visitor → root on the orchestration k8s → exfil the final recipe (flag) from a cold-store bucket that is never mounted except during a single 200 ms window when a side-channel proof-of-concept fires inside an enclave.
0. Attack Surface Overview
Host
Tech
Purpose
shop.0xdecafbad.io
Nuxt3 + GraphQL gateway
Public storefront
api.0xdecafbad.io
Apollo/Node → Java Spring
GraphQL → REST translation layer
files.0xdecafbad.io
Java/Spring “DocStore” micro-service
Handles user uploads, signed URLs
cache.0xdecafbad.io
Redis 7 w/ RedisJSON
Shared cache, unix-socket only
enclave.0xdecafbad.io
SGX2 enclave, Rust + Fortanix
Generates coupon HMACs, runs constant-time ECDSA
git.0xdecafbad.io
Gitea 1.21 (internal)
CI pushes images to registry
k8s-ctrl.0xdecafbad.io
Kubernetes 1.29, Talos
Orchestrates everything, OIDC auth
1. Recon & Public Bugs
1.1 GraphQL Introspection (intentionally left on)
Query reveals:
graphql
type Coupon {
code: String!
discount: Int!
sig: String! # ECDSA r||s over (code||discount)
}
mutation generateCoupon(seed: String!) : Coupon
The seed is passed straight into the SGX enclave via AF_UNIX.
and hard-coded OIDC client secret gitea-oauth|shop|decaf|shop.
2. OAuth Dance → Gitea SSRF → Metadata Endpoint
Use the leaked secret to complete OIDC code flow, grab id_token, hit Gitea’s /api/v1/user/signing-key which accepts a kid parameter that is fetched with Go’s http.Get without validation.
Host a malicious JWK set on your server, claim alg: none, kid points to http://169.254.169.254/computeMetadata/v1/instance/service-accounts/default/token → GCP metadata SSRF → steal Gitea’s workload identity token.
With that token push a new .drone.yml to the public mirror repo that exports the Docker build cache as a tar.
The tar contains an intermediate layer with:
code
/beans/roaster.so # Rust crate that will be injected into enclave
The crate exports #[no_mangle] pub extern "C" fn get_random() -> u64 that reads the Time-Stamp Counter twice and xors the delta with a cache-line eviction pattern.
This is the first side-channel primitive – it leaks 4 bits of SGX enclave entropy per call via cache-timing.
3. DocStore XXE → Redis SSRF → Internal GraphQL
DocStore uses Apache POI to convert docx → pdf. Upload a docx with:
xml
<!DOCTYPE x [ <!ENTITY % remote SYSTEM "http://cache.0xdecafbad.io:6379/">
%remote; ]>
Redis speaks inline protocol, so the entity expansion issues:
code
EVAL "redis.call('SET','x','y')" 0
but also returns protocol errors that are reflected in the conversion log.
By sending a crafted Redis command we can overwrite the Apollo gateway’s schema cache key (apollo:schema:shop) with a new introspection that adds:
graphql
directive @auth(role: String!) on FIELD_DEFINITION
type Query { debugEnv: String! @auth(role: "admin") }
The gateway trusts the cache, so the new field appears. debugEnv is implemented in Spring as:
The cluster accepts tokens signed by Gitea’s OIDC because the apiserver --oidc-issuer-url was pointed at git.0xdecafbad.io.
We already control Gitea’s signing key (step 2).
Forge a id_token with:
Use kubectl with that token.
We are now inside the enclave pod, but the container is locked down:
no CAP_SYS_PTRACE, no exec, seccomp filter on perf_event_open, and the binary is in an SGX enclave.
5. SGX Enclave Micro-Architectural Leak
The enclave runs constant-time ECDSA signing for coupon codes.
It uses a Montgomery ladder, but the Rust crate we injected (step 2) is dynamically linked via LD_PRELOAD (because the CI build copied it to /usr/local/lib/roaster.so and the entrypoint script does export LD_PRELOAD=roaster.so for “performance”).
The crate registers a constructor that:
Schedules itself on the same physical core as the enclave thread (using sched_setaffinity).
Uses Prime+Probe on the L1-d set indexed by PC & 0x3F to monitor the ladder’s conditional code path.
Sends 4 bits per signature over a covert channel: CPU frequency scaling (via powercap sysfs) – 0 = 2.4 GHz, 1 = 2.5 GHz.
The parent k8s node exports node_cpu_frequency_hz via Prometheus. We can read it from the metrics endpoint (http://10.42.0.1:9100/metrics) with our service-account token.
Collect ~512 signatures (GraphQL mutation loop) → recover 256-bit ECDSA nonce k via lattice attack (HNP-160).
With two signatures that reuse k we can recover the enclave’s private key.
6. Forge Coupon → RCE on Cache Pod
The coupon code is a Java serialized object inside Redis:
java
class Coupon implements Serializable {
String code;
int discount;
String sig; // ECDSA(code||discount)
}
We can now forge valid signatures.
Craft a coupon with discount = 1337 and append a Java gadget chain (CommonsBeanutils + TemplatesImpl) inside the code field.
The DocStore service deserializes the coupon when a user applies it → RCE as system_u:system_r:container_t in the cache pod.
7. Escape to Node – cgroups v1 release_agent
The cache pod is still inside a container.
The node uses cgroups v1 and the container’s memory cgroup is writable.
Overwrite /sys/fs/cgroup/memory/release_agent with:
code
/var/lib/roast.sh
and trigger OOM.
The host kernel executes our script as root on the node.
8. Cold-store Window – Side-channel Trigger
The recipe flag is stored in a LUKS-encrypted bucket mounted only when the enclave proves it has generated a coupon with a magic seed (0xBAAAAAAD).
We can forge that proof (step 6).
The mount is performed by a systemd unit that:
Uses the enclave’s ECDSA key to sign a TPM PCR quote.
Decrypts the LUKS key from TPM NVram.
Mounts /dev/sdc1 to /mnt/cold-store for exactly 200 ms, then unmounts and shreds the key.
But our node compromise lets us pause the systemd unit (systemctl edit --full cold-store-mount.service) and insert:
bash
taskset -c 3 /usr/local/bin/leak &
where leak is a small ELF that:
Runs on the same physical core as the enclave (hyper-thread 3).
Uses PortSmash-style leakage: the enclave’s Montgomery ladder leaks 1 bit per nonce bit via port-contention (Port 0 vs Port 1).
Transmits the 256-bit LUKS master key as Morse in CPU turbo-boost duty-cycle (visible via turbostat).
Capture the key, decrypt /dev/sdc1, read recipe.txt.
PortSmash on enclave → leak LUKS key → cold-store mount → flag
10. Hints (for CTF organizers)
The frequency covert channel produces visible spikes in Prometheus; graphing rate(node_cpu_frequency_hz[1m]) shows the 4-bit pattern.
The PortSmash binary is only 120 bytes; contestants can write it by hand once they realize the enclave thread is pinned to core 3.
The Java gadget chain is CommonsBeanutils1 but the server uses an old Commons-collections 3.2.2 that removed InvokerTransformer; contestants must find CommonsBeanutils + TemplatesImpl instead.
The DocStore XXE is blind; errors are returned only in the PDF conversion log, accessible via another GraphQL mutation convertStatus(id) which requires the upload UUID.