All challenges

Spring Cloud Function SpEL injection

webmedium300pts

Spring Cloud Function SpEL injection

CVE-2022-22963 is a remote code execution bug in Spring Cloud Function 3.1.6 / 3.2.2 and earlier. With the function-web support on the classpath, the app exposes /functionRouter, which reads the spring.cloud.function.routing-expression request header and evaluates it as a Spring Expression Language expression against an unsandboxed context. An attacker who sets that header controls arbitrary Java calls.

How to reach it

Run the challenge locally with its docker-compose. The flagger sidecar writes your per-run flag to /flag/flag.txt before the app starts. The app speaks HTTP on port 8080, and the vulnerable endpoint is POST /functionRouter. An expression that resolves to a plain string is treated as a function name, so returning the flag directly will not work; an expression that throws surfaces its exception message in the response. Build from there.

Run this challenge

Spin it up locally with Docker. The flagger sidecar fetches a per-run flag into a shared volume, then the challenge container boots and reads it.

compose.yml
services:
  flagger:
    image: matejbasic/rootcause-flagger:1.0
    environment:
      ROOTCAUSE_API_URL: https://root-cause-api.matejbasic.com
      ROOTCAUSE_API_KEY: ${ROOTCAUSE_API_KEY}
      ROOTCAUSE_CHALLENGE: spring-cloud-function-spel
      FLAG_PATH: /flag/flag.txt
    volumes:
      - flag:/flag
  challenge:
    image: matejbasic/cve-2022-22963:1.0
    depends_on:
      flagger:
        condition: service_completed_successfully
    environment:
      FLAG_PATH: /flag/flag.txt
    volumes:
      - flag:/flag
    ports:
      - "8080:8080"
volumes:
  flag:
one-line CLI
rootcause start spring-cloud-function-spel

The rootcause CLI does all of this in one command. Running a challenge needs your API key, which you generate in your profile.