Manifesto

Description

This is an easy challenge, except... it's written in Clojure. Can you find your way through all of these parentheses and come out victorious? - @aelmo

Source: https://master-platform-bucket.s3.amazonaws.com/challenges/cd6be806-1412-4aa9-9108-ef0ac3ea2f0c/public.ziparrow-up-right

Source

Dockerfile:

FROM clojure:lein-alpine

WORKDIR /app

COPY project.clj .
RUN lein deps

COPY src/ src/
COPY resources/ resources/

ENV CLOJURE_PORT 80
ENV FLAG '0xL4ugh{this_is_a_fake_flag}'

EXPOSE 80

ENTRYPOINT ["lein", "run"]

project.clj:

Solution

From Dockerfile we know that flag lives in Environment and we have to leak it somehow.

Clojurearrow-up-right syntax is somewhat hell, so before trying to read it it's better to get visual feeling which will make understanding a bit more easeir.

Manifesto.png

Main page has some dummy data

/login requires credentials

/gists requires authorization

Lisp in 100 Secondsarrow-up-rightLearn X in Y minutesarrow-up-right -> Where X=Clojurearrow-up-right

There's only single user admin and password is uuid4 which can never be guessed.

Main page has Redirect Vulnerability, we can trigger XSS but not sure if it's useful anyhow.

XSS PoC: https://7ab6a925e26832ee212cfea2a4fa8eb2.chal.ctf.ae/?prefer=light&redirect=javascript:alert(1)arrow-up-right

Following line is vulnerable to Mass Assignment vulnerability; It's not only updating prefer, but any key inside session.

https://7ab6a925e26832ee212cfea2a4fa8eb2.chal.ctf.ae/?prefer=light&username=adminarrow-up-right

Manifesto-1.png

Now we are admin, so what?... 💭

This is starting to smell like SSTI, so I started playing around with common payloads. It doesn't like {{7*7}} or like just {{ANYTHING}} and dies right away with exception. Then I tried ${{7*7}} but that only outputs $ and nothing else.

Manifesto-2.png

Parser used by the application -> Selmerarrow-up-right: A fast, Django inspired template system in Clojure.

gists.html template:

ANN: NEVER use clojure.core/read or read-string for reading untrusted dataarrow-up-right -> https://clojuredocs.org/clojure.core/readarrow-up-right

Manifesto-3.png

It doesn't like the PoC given above, but its definitely evaluating our code!

Manifesto-4.png

To read Environment Variable in clojure you use #=(System/getenv "FLAG"), but for some reason it wasn't working?....

To read files in 1 command we can use slurparrow-up-right

Dump environment manually #=(slurp "/proc/self/environ")

Manifesto-5.png
circle-check

Other payloads submitted (taken from Discord):

https://clojure.org/reference/java_interoparrow-up-right

Last updated