Glacier CTF 2026: Frozen Query
| Challenge Author | EmberZero |
| Solving Team | KITCTF |
| Category | web |
The challenge
The Glacier Avalanche Service moved its bulletins to the shiny new HTTP QUERY method from RFC 10008. Thanks to the edge cache, the summit auditor’s reports are served faster than ever.
Only auditors may read the summit bulletin. Right?
The challenge also includes the server’s source code.
Setting up local testing
I built a quick testing environment early on so I could test and debug the challenge more easilly. This proved to be invaluable, so here are my patches for anyone whom may want to follow along. You can also download a modified version of the challange archive if you so please to.
Set up local testing
@@ -1,6 +1,6 @@
#!/bin/sh
-export PATH="/.venv/bin:$PATH"
-export FLAG=$(cat /flag.txt)
+export PATH="./.venv/bin:$PATH"
+export FLAG=$(cat ./flag.txt)
export AUDIT_TOKEN=$(head -c 32 /dev/urandom | od -An -tx1 | tr -d ' \n')
-python3 /app/backend.py &
-exec python3 /app/app.py
+python3 ./src/backend.py &
+exec python3 ./src/app.py
I think something on my host might’ve taken up port 8000, or this was just an
issue with how I re-ran the challenge. Either way, I changed src/backend.py’s
port:
@@ -12,7 +12,7 @@
from flask import Flask, Response, abort, jsonify, request
from waitress import serve
-BACKEND = "http://127.0.0.1:8000"
+BACKEND = "http://127.0.0.1:8901"
AUDIT_TOKEN = os.environ["AUDIT_TOKEN"]
MAX_BODY = 16 * 1024
MAX_CODINGS = 3
@@ -12,7 +12,7 @@
from flask import Flask, Response, abort, jsonify, request
from waitress import serve
-BACKEND = "http://127.0.0.1:8000"
+BACKEND = "http://127.0.0.1:8901"
AUDIT_TOKEN = os.environ["AUDIT_TOKEN"]
MAX_BODY = 16 * 1024
MAX_CODINGS = 3
$ python3 -m venv .venv
$ source .venv/bin/activate
$ pip install -r requirements.txt
These patches let me run the challenge locally, without Docker, by just entering
the directory I extracted the source code to and executing ./entrypoint.sh
(note: you don’t need to be in the venv you just set up for this to work).
I quickly learned that, when I quit the challenge, backend.py kept running and
taking up port 8901 so I had to manually kill it (lsof -i :8901, then
kill the PID that comes up). I guess that’s what I get for not setting up
a Docker container.
Reconnaissance
The (frontend) server allows visitors to send queries with a nice user
interface. Here, the challenge authors helpfully put a default query:
{"region": "ridge", "fields": ["level", "note"]}. When we use it, we get back
something along the lines of:
HTTP 200
X-Cache: HIT
Cache-Control: public, max-age=30
Date: Fri, 20 Nov 2026 19:44:00 GMT
{"level":3,"note":"Considerable. Wind slabs on north aspects.","region":"ridge","window":null}A quick look at backend.py tells us where the data is comming from:
|
|
We found the flag! Let’s modify the default query to
{"region": "summit", "fields": ["level", "flag"]} and get it!
HTTP 403
X-Cache: -
Cache-Control: -
Date: Sun, 22 Nov 2026 11:46:16 GMT
{"error":"blocked by glacier-edge"}Well, it was woth a try.
Looking at app.py, a Flask app, we could spot a few interesting function names
such as waf_allows(body, encoding), a few functions for some sort of cache and
a long function called bulletin(), which handels QUERY1
requests to /api/bulletin. Being by far the longest handler, we assumed it
played a major role in the challenge. The same script also has an
auditor_loop() function that repeatedly connects to the frontend server to
send a request. We’ll get to the auditor part in a bit.
Here are the first few lines of bulletin():
|
|
is_auditor() turned out to be rather simple. It just checks for the auth
token, but we modified it for the time being to always return True, bypassing
the block we saw before. Think of this as “okay, but what if we (hypothetically)
bypassed all the security checks in the frontend server?” We fired the query
again and got this:
HTTP 403
X-Cache: MISS
Cache-Control: no-store
Date: Fri, 20 Nov 2026 19:56:39 GMT
{"error":"auditors only"}Notice how the error messege is completely different from the previous one. In
fact, the string auditors only doesn’t appear in app.py at all and comes
from the backend instead:
|
|
So the situation is as follows:
- The flag is stored in
backend.pyand can be queried for with{"region": "summit", "fields": ["level", "flag"]}, but this request requires an authentication token that we don’t have. - We need to submit this query through a frontend server which does additional checks, preventing us from even reaching the backend with such a query in the first place.
Cache poisoning, except the other way around
Remember the auditor? We realized its requests might get caught in the cache,
so we took a closer look. Concerningly, Cache-Control was set to
no-cache, so we were worried our newly formed cache theory would be
short-lived. Two snippets matter here. With key being the cache key the
function derived, here is how the script queries the cache:
|
|
And if it queries the backend, this is how it caches the response:
|
|
Note: During the CTF, I was too hyperfixated on the last two line of the
snippet. It is only now when I am creating this writeup that I notice the
comment that claims “authenticated responses are only shared when marked
public.” That’s just not what happens: sharable is always set when the auditor
makes the request because the Authorization header is set and that’s
sufficient.
As it turned out, Cache-Control being set to no-cache prevents cache
lookups. It doesn’t prevent cache writes, though, so all we were missing for an
attack on the cache was a way to replicate the cache keys. By now, I probably
owe you the full auditor_loop() code:
|
|
And a couple of lines above it is the code that generates the cache keys:
|
|
It turned out the cache key is actually super predictable and depends entirely
on parameters anyone can set: We just needed to use our own clock to derive the
data part and match the Content-Type and Accept headers. There is just one
tiny major problem: The WAF needs to allow our request, and the WAF looks like
this:
|
|
Yet we need to get our request through with the blocklist being this
("flag", "summit").
Squeezing hard enough
We eventually came to realize that the kind of thing we were looking for was a
difference in what waf_allows checks and what decode_content produces, so we
took a good look at decode_content, too.
|
|
It looked like decode_content doesn’t care about the encoding being gzip at
all but waf_allows does. If, say, another encoding caused waf_allows to not
gunzip body, it would miss the disallowed word. decode_content will still
call gunzip (since there is still an encoding), letting us smuggle the
payload. Then, we read parse_codings.
|
|
Appart from flexing the author’s Python skills, this function restricts the
encodings to only gzip. Also, we’re only allowed MAX_CODINGS (which is 3)
encodings. We considered what would happen if we supplied an empty header, which
is allowed, but eventually we remembered decode_content would also stup
gunzipping since it looped over the encodings.
Hold up, what happens if the server sees multiple gunzip encodings? The WAF
still unzips once, but parse_codings does it as often as we tell it
to2.
The exploit
To get the flag, we need to fetch it from the cache, where the auditor puts it
every five seconds. A QUERY request that looks similiar to the request the
auditor makes will be enough, even without authentication. The WAF would
normally catch such a request but we gzip it twice so the WAF only gets
through the first layer. parse_codings will reconstruct the request we wanted,
though, meaning the cache keys match and we get the flag from the frontend.
Python implementation
This took me 43 minutes to write and you will appreciate it:
|
|
$ ./exploit.py
{"flag":"gctf{QU3RY_c4ch3_k3y5_mu5t_c0v3r_th3_wh0l3_r3qu35t}","level":5,"note":"Extreme. Station closed to the public.","region":"summit","window":59840375}
Takeaways
so here’s what I learned:
- Set up local testing early, it can help a lot.
- Always interact with the target system legitimately before you read the code. I tried it the other way around and it did not go well.
- The challenge description and the landing page hinted at where to look and while we did find the vulnerability with no major dead ends, we probably woul’ve found it faster if we took our time to read.