h4ckc0n 2026 writeup (h4ckmarket)

Part of my h4ckc0n 2026 writeups. I played solo and finished first.


Go home or Win big! (Go home).
Earn 30,000 to buy the flag you get 2,000 every 40mins btw?
Rules:
- The markets would be resolved by admins. Markets whose solutions cannot be resolved within the time bounds of h4ckc0n are left unresolved and NO refund of credits would be given.
- Hope you enjoy the chall!

h4ckmarket was a live prediction market shared by every team. Each team started with $10,000 of play money, and the flag appeared in your wallet once your equity reached the target: $100,000 at launch, lowered to $30,000 near the end. I reached it at 15:11 UTC, 19 minutes before the event closed, with a lot of help from another team.

Flag: d4rk{wh0_s41d_g4mb1in8}


Setup

  • A token site exchanges your CTFd access token for a market token (<teamId>.<secret>).
  • The portal is a React single-page app with a REST API and a WebSocket feed. The client bundle lists every route, error code and message type.
  • GET /api/config is public and shows the rules: start with $10,000, flag at $100,000, at least $3,000 to create a market, prices from 1¢ to 99¢, $1 for each winning share, and 50¢ a share if a market is voided.
  • When equity crosses the target, the server sends the flag as wallet.flag on your team's WebSocket channel.

How the market works

  • Each market is a YES/NO question with an order book. BUY_YES at p¢ holds p¢ per share. SELL_YES at p¢ holds (100 − p)¢ per share, so selling YES shares you do not own gives you NO shares.
  • Any team can create a market with a question, rules, a close time and at least $3,000 of seed money. The seed money buys YES+NO pairs at $1 a pair, and the creator's orders sell both YES and NO at 51¢ a share. The creator cannot cancel these orders.
  • Equity is free cash + held cash + positions at cost. Buying never changes equity. Selling a position above its cost adds the profit to equity at once. Otherwise money only moves when an admin settles the market by hand as YES, NO or void.
  • Positions offset each other. A BUY_YES first closes any NO shares you hold, and a SELL_YES first closes your YES shares.

Looking for a bug

At first $100,000 looked unreachable by trading, so I looked for an accounting bug. I tested invalid quantities and prices, double cancels, trading against my own orders, simultaneous requests, idempotency keys, admin routes, and the session cookie's HMAC key against wordlists. Nothing broke.

Every YES+NO pair costs $1 to create and pays out $1 in total at settlement. So a team's equity can only grow by taking money from other teams.

Strategy: buy certain outcomes and resell them

Many teams created test markets with rules such as "Resolves YES." to try the engine. Each of these markets sold its certain side at 51¢ through the seed orders. Buying that side earns about 49¢ a share, but only after an admin settles the market.

Reselling was faster. Other teams' bots paid 85–97¢ for shares in markets that were certain to resolve YES. So the loop was:

  1. Watch the WebSocket for market_created.
  2. If the rules say an unconditional "Resolves YES/NO", buy the whole certain side at 51¢ within a second.
  3. List the shares right away at several prices (for example 50% at 95¢, 30% at 97¢, 20% at 98¢).

The first round made $1,750 in a few minutes. I turned it into a bot, sweeper.mjs, with one WebSocket connection, strict regexes on the rules text, a spending cap per market, a cash reserve for the next seed, and rate limiting. It also wrote the flag to disk if wallet.flag ever appeared.

The bot needed changes as the event went on:

  • The portal went down at 05:22 UTC and came back around 08:00 on a new host with every wallet reset. The $15,600 from the first run was gone, as it was for every team.
  • The organizers announced that vague or gibberish markets would be voided with no refund. After that, the bot paid more than the seed price only when the question was a plain sentence.
  • Admin settlement fell behind. At one point 46 markets were closed but not settled, so reselling mattered more than waiting.

By 10:00 UTC my equity was $22,000, first on the leaderboard. Two things then set me back. Fewer seeds were worth buying as creators changed tactics, and I lost a $3,060 bet that no new challenge would come out by 12:30 UTC, because the final wave arrived.

The endgame

Around 14:00 UTC the organizers lowered the target to $30,000, although /api/config still showed 100,000. At 14:30 my equity was about $19,500, about $10,000 short with an hour left.

Team Skebob offered to send me credits, and I would send them back after reaching the target. A transfer through the order book works like this:

  1. I create a market whose answer is certain to be NO: "Will this market resolve NO? (answer is NO)".
  2. I place SELL_YES @99. That gives me NO shares at 1¢ each.
  3. Skebob buys YES at 99¢, a side that is certain to lose.
  4. My NO shares count at cost (1¢) until settlement. To turn them into cash right away, I place BUY_YES @1, which closes my NO shares at 99¢ when someone sells into it. Other teams' bots did that within seconds. Each share gives +98¢ at once, with no admin needed.

With the transfer, plus the sweeper's last seed buys and resales, my equity reached $30,021.33 at 15:11 UTC. The server config still said $100,000 and no wallet.flag arrived, so an admin (paramveer504) sent me the flag by hand in Discord.

Paying it back (and failing)

I planned to return Skebob's credits with the same trick in reverse: a new market with my shares offered at 1¢ for Skebob to buy. Other teams' bots took those 1¢ offers within seconds, before Skebob could, and then trading closed for good. The credits never went back.

The fix is simple: the receiver places the bid first, and the sender then sells into it. Then no cheap offer sits on the open book for bots to take.

Skebob, thank you. I could not have reached the target without you, and I am sorry I could not return the credits.

Lessons

  • Read the accounting before planning a strategy. "Equity at cost" decided everything: buying does nothing, selling above cost adds the profit at once, and settlement needs an admin.
  • In a shared market, the other players are the edge. The profit came from other teams' test markets and from bots that paid 95¢ for certain outcomes.
  • Expect the platform to change. A full reset, a new rule on voids, a new target, and top-ups that never came all happened during one event.
  • Bots watch every open order book. Never post an underpriced order and hope the intended team gets it first.


More from this event: recap · WhoAmI · h4ckmarket