FlagYard CTFWeb
SupportFlow
Two "only the first item in the request is authorized" bugs chained together:
- Competition
FlagYard CTF
- Category
- WebMedium
- Source status
- Source-documented · not platform-verified
- Document
- PDF edition3 min read
Brief
The challenge
- Category
- WEB
- Difficulty
- Medium
- Target
http://ccf80c38b3fdbc86d316666f06621acc.playat.flagyard.com- Credentials
analyst@acme.local/support123
SupportFlow recently rolled out a new real-time ticket experience. One of our internal teams says customers occasionally receive updates they shouldn't be seeing. Can you figure out what is happening?
TL;DR
Two "only the first item in the request is authorized" bugs chained together:
WebSocket
/wssubscribe authorizes only the first subscription on a connection. Subscribe to a ticket you own, then subscribe to another org'sticket_9001on the same socket — it is accepted and replays that ticket's messages and attachment id.POST /api/attachments/batch-previewauthorizes only the first attachment in the batch. Put an attachment you own first, then the privateatt_private_9001id, and the response leaks the private attachment's content — which contains the flag.
01
Recon
Logging in returns a signed session cookie whose payload is just v1|user_analyst|org_acme|analyst|<exp> (base64 + HMAC). The user is an analyst in org_acme and the inbox only shows two tickets (ticket_1001, ticket_1002), yet /api/me reports latestTicketSequence: 9001 — a strong hint there is a high-numbered ticket we aren't meant to see.
/static/app.js shows the "real-time" design:
Open a ticket → open
ws://host/ws→ send{"action":"subscribe","channel":"ticket","ticketId":...}.On a successful subscribe the server replays the ticket's history (message bodies +
attachment_addedevents) down the socket.Attachment previews come from
POST /api/attachments/batch-previewwith a list of{id, operation:"preview"}.
Direct access to the hidden ticket is blocked:
GET /api/tickets/ticket_9001 -> 403 {"error":"forbidden"}ws subscribe ticketId=ticket_9001 (fresh socket) -> {"error":"forbidden"}POST batch-preview id=att_private_9001 -> 403 {"error":"forbidden"}ticket_9001 exists but belongs to another org (forbidden, distinct from the not_found returned for non-existent ids). ticketId is validated against [A-Za-z0-9_-]{1,64}, so path tricks, whitespace and case changes all fail.
02
Bug #1 — per-connection WebSocket auth
The subscribe authorization is checked once per connection, not per message. On a fresh socket ticket_9001 is forbidden, but if you first subscribe to a ticket you legitimately own, the connection is considered authorized and every later subscribe is accepted:
SEND {"action":"subscribe","channel":"ticket","ticketId":"ticket_1001"} # owned -> OKRECV {"event":"subscribed","ticketId":"ticket_1001"} + its replaySEND {"action":"subscribe","channel":"ticket","ticketId":"ticket_9001"} # other orgRECV {"event":"subscribed","ticketId":"ticket_9001"}RECV {"event":"message","message":{"author":"Operations","body":"Please keep this escalation restricted to internal operations.",...}}RECV {"event":"message","message":{"author":"Support","body":"Diagnostic data attached.",...}}RECV {"event":"attachment_added","attachment":{"filename":"support-escalation.txt","id":"att_private_9001"}}This is exactly the "customers occasionally receive updates they shouldn't be seeing" behaviour from the brief. It leaks the private attachment id att_private_9001, but the WS event only carries the filename, not the content.
Solve script
exploit.py chains both bugs: log in, leak the private attachment id over the WebSocket, then read its content through the batch-preview IDOR.
python exploit.pyFlag
Flag
FlagY{f70fbc00a81404b4ff2a343a2e0e0d36}
Source-documented · not platform-verified
Takeaways
Authorize every item in a batch/stream, not just the first one. Both the WebSocket subscribe loop and the attachment batch handler checked access once and then trusted the rest.
A per-connection "is this user allowed?" flag is not the same as a per-resource check — long-lived sockets must re-authorize each subscription.
When one leak only exposes an identifier (here an attachment id), look for a second endpoint that turns that identifier into data.