<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.4.1">Jekyll</generator><link href="https://blog2.kuhi.to/feed.xml" rel="self" type="application/atom+xml" /><link href="https://blog2.kuhi.to/" rel="alternate" type="text/html" /><updated>2026-11-17T21:13:36+00:00</updated><id>https://blog2.kuhi.to/feed.xml</id><title type="html">yakuhito’s blog</title><subtitle>HackTheBox walkthroughs, CTF writeups and other cybersecurity stuff.</subtitle><entry><title type="html">warp.green ERC-20 Bridge - Post-Mortem</title><link href="https://blog2.kuhi.to/warpdotgreen-erc20bridge-post-mortem" rel="alternate" type="text/html" title="warp.green ERC-20 Bridge - Post-Mortem" /><published>2026-10-01T00:00:00+00:00</published><updated>2026-10-01T00:00:00+00:00</updated><id>https://blog2.kuhi.to/warpdotgreen-erc20bridge-postmortem</id><content type="html" xml:base="https://blog2.kuhi.to/warpdotgreen-erc20bridge-post-mortem"><![CDATA[<p><strong>TL;DR</strong>: On August 23, 2026, warp.green’s ERC-20 Bridge application was drained of almost all USDC. The funds have been replenished as part of an agreement with Chia Network, Inc., and the protocol will resume in October 2026 after the fix is validated. After a thorough investigation, we were unable to link the attacker’s wallets to a real identity.</p>

<h2 id="the-bug">The Bug</h2>

<p>The bug was located <a href="https://github.com/warpdotgreen/cli/blob/master/puzzles/wrapped_assets/cat_burner.clsp#L11">in the Chia-side warped (wrapped) ERC-20 CAT burner puzzle</a>, which failed to assert that the TAIL of the CAT being burned is a <a href="https://github.com/warpdotgreen/cli/blob/master/puzzles/wrapped_assets/wrapped_tail.clsp">wrapped TAIL</a>. While the wrapped TAIL asserts the right inner puzzle is used when burning, a custom TAIL could be forged to bypass that constraint. An attacker used a custom TAIL of <code class="language-plaintext highlighter-rouge">(q)</code> (equivalent to <code class="language-plaintext highlighter-rouge">(q . ())</code>, a program that always succeeds and returns no conditions) to generate two messages that looked like warped USDC had been burned. From there, the underlying messaging protocol worked normally, and once enough confirmations had passed, the attacker relayed the messages to Base and Ethereum, draining the ERC20Bridge contracts.</p>

<h2 id="security">Security</h2>

<p>We’ve always regarded security as a priority, and as a result of continuous effort. For the protocol, security issues could arise from two main sources, validators and code.</p>

<p>To minimize the risk of validator key compromise, a frequent issue seen in many similar protocols, validators have been chosen as known teams in the Chia community with an ability to maintain highly secure operations. Everything the protocol does is locked by a 6-of-10 multisig, with sensitive operations (such as updating contract/puzzle implementations) using a cold-key multisig as opposed to the hot multisig employed for messages relays. To combat key loss, all validators sign an attestation every 4 weeks containing the header hash of a recent Chia block, thus proving they still have access to their cold keys.</p>

<p>We’ve also worked towards minimizing code risk. Chia Network, Inc. has reviewed our Chialisp puzzles before launch, and our Solidity contracts have gone through audits from Hacken and <a href="https://github.com/Zellic/publications/blob/master/warpdotgreen-cli%20-%20Zellic%20Audit%20Report.pdf">Zellic</a>. We <a href="https://docs.warp.green/developers/introduction">documented the protocol in detail</a> and established a clear way to <a href="https://github.com/warpdotgreen/cli/blob/master/SECURITY.md">report security vulnerabilities</a>. While efforts have been made to arrange a second Chialisp side audit with Chia Network, Inc.’s support, the plan has been repeatedly delayed due to outside circumstances, and the protocol has instead been kept in Beta until the incident. Additionally, we have received two reports from Chia Network, Inc. generated by their custom in-house AI security harness/scanner, on 23 April 2026 (4 months before the incident) and 5 June 2026 (&lt;3 months before the incident). Each report was screened immediately (within minutes) for high-impact findings and then read in full within 24 hours. Neither flagged this bug or anything in the same class.</p>

<h2 id="forensics">Forensics</h2>

<p>During the forensics investigation immediately following the attack, we have mapped the flow of funds that allowed the exploit to take place. We have since confirmed this data with multiple external collaborators, and are making it public for transparency and in the hope that more eyes will be more likely to catch opsec errors.</p>

<p>Initial funds were traced to the Monero (XMR) blockchain, which makes further forensics difficult due to its fundamental measures to hide recipient/sender addresses and transaction amounts. From there, funds were bridged through wagyu[.]xyz to <a href="https://arbiscan.io/address/0x1C1536B0cAD378071C439ADA3f520650EAb4B31e">an Arbitrum address</a>, and, later, to <a href="https://etherscan.io/address/0x5D629E63f3BDDfA24A980Eaa17F7Ec4c7bD60BFA">the main Ethereum address</a> via the Across protocol. Using Mayan Finance, the <a href="https://basescan.org/address/0x5D629E63f3BDDfA24A980Eaa17F7Ec4c7bD60BFA">same address</a> was funded on Base, where it swapped some of its assets to warped Chia (wXCH). From there, the address used the bridge normally to send 1 wXCH to fund a <a href="https://www.spacescan.io/address/xch1edcn7z6rx00awpdfwzqkmmqvpg5x4rnjaqcyfnk06lx7m73xw7vqn2lhtz">Chia address</a>, from which both drains were performed. Soon after the drains, all funds were converted to ETH and bridged to Ethereum, likely to prevent freezing based on reports from our team. The funds have since been transferred to Tornado Cash in several batches.</p>

<p>Because the initial transaction to Chia used the ‘Welcome kits’ feature of the bridge, which pays the transaction fee required to finish the bridging operation for eligible new accounts on Chia, we were able to recover the attacker’s public IP, as well as several browser fingerprints, on the day of the exploit. Unfortunately, further investigation revealed the IP belonged to Mullvad VPN, a VPN provider with a no-logs policy. The browser fingerprints are also too general to be used to determine additional details about the attacker. We have confirmed the pattern seen in the attack - melting ‘fake’ CATs to trigger the ERC-20 bridge contract to release tokens - does not appear to have been used before.</p>

<h2 id="timeline">Timeline</h2>

<p>This section contains the reconstructed timeline of major events. Times are UTC+3 (Romania), and all events take place in the year 2026.</p>

<ul>
  <li>Aug 23 07:52 - An attacker sent a malicious message draining 85,000 USDC to Base.</li>
  <li>08:07 - The message is relayed, and the attacker receives 85,000 USDC.</li>
  <li>08:20 - The same actor sends a 2nd message draining 8,000 USDC to Ethereum.</li>
  <li>08:34 - The 2nd message is relayed successfully.</li>
  <li>08:50 (approx.) - The lead validator, yakuhito, notices the two messages and starts investigating.</li>
  <li>09:00 - A notice reporting suspicious transactions and asking validators to pause message signing is sent on a private &amp; secure validator chat.</li>
  <li>09:05 - A war room is created with jde5011, dns, maxim_goods, Rigidity, and Acevail.</li>
  <li>10:12 - We <a href="https://x.com/warpdotgreen/status/2091423295971242371?s=20">publicly post</a> that we have identified 2 suspicious transactions.</li>
  <li>10:15 - The Chia-side bundle that drained 85,000 USDC on Base is isolated.</li>
  <li>11:07 - Initial attack path is decoded, and effort goes into ensuring the other major application that uses the messaging protocol, the CAT Bridge, is unaffected. The CAT Bridge holds &gt;50% of total protocol TVL, so ensuring the funds are safe is a priority.</li>
  <li>11:44 - Validators are updated that an exploit was confirmed, that the damage appears limited to 93,000 USDC (the CAT Bridge is safe), and that a war room is investigating the incident.</li>
  <li>12:14 - SEAL 911 is contacted to help with incident response. They are a team of volunteers with extensive incident response experience.</li>
  <li>12:30 - We <a href="https://x.com/warpdotgreen/status/2091457988351406403?s=20">publicly post</a> that we have confirmed the malicious transactions were part of an exploit of our protocol.</li>
  <li>12:42 - SEAL 911 recommends that we wait for 1-2 days before sending an on-chain message to the attacker. They also advise us to use this time to search for opsec errors in all attacker-related activity.</li>
  <li>13:20 - Attack reconstruction reveals that the attacker used the ‘Welcome kits’ feature of the bridge. The service’s server logs reveal an IP address, which, upon further investigation, is unfortunately determined to belong to Mullvad VPN.</li>
  <li>17:09 - A validator suggests we should post a more direct announcement that active wUSDC/wUSDC.b offers should be cancelled as soon as possible.</li>
  <li>17:24 - Under jde5011’s earlier guidance, a complaint is filed with FBI’s Internet Crime Complaint Center (IC3) about this incident.</li>
  <li>17:25 - The announcement that open offers should be cancelled <a href="https://x.com/dexie_space/status/2091531974678594045">is posted</a> by dexie and re-tweeted by the official protocol account.</li>
  <li>For the remainder of the day and up until 01:00 the next day (approx.), the forensics investigation continues. Logs of various services and sites are analyzed to uncover more information about the attacker. We isolate 4 User-Agent headers connected to the IP address discovered earlier, but they are not specific enough to help isolate other traffic. Reviewing all service activity over the past days does not lead to more information about the attacker.</li>
  <li>Aug 24 07:54 - We started discussing viable paths for recovery in the war room.</li>
  <li>09:18 - We have <a href="https://x.com/warpdotgreen/status/2091772015598325920?s=20">publicly posted</a> that the bug used in the exploit has been identified, and that we found no other malicious transactions using a similar mechanism.</li>
  <li>15:59 - The final draft for an on-chain message to be sent to the attacker is ready.</li>
  <li>17:33 - We <a href="https://x.com/warpdotgreen/status/2091896746393711059">publicly announce</a> that we have sent an on-chain message to the attacker.</li>
  <li>Aug 25 16:19 - We <a href="https://x.com/warpdotgreen/status/2092240527345234382?s=20">publicly notify</a> users that the attacker sent some of the funds to Tornado Cash. This is an early indication they will not accept our offer of returning 90% of the funds in exchange for us considering their drains to be a whitehat rescue operation.</li>
  <li>Aug 26 19:51 - We <a href="https://x.com/warpdotgreen/status/2092656278317289478?s=20">publicly post</a> a clarification about the current situation following the concern of a few community members, which raised the issue of earlier messages not being direct enough.</li>
  <li>Aug 27 21:34 - We <a href="https://x.com/warpdotgreen/status/2093044571764666586?s=20">publicly announce</a> that we’re working on an agreement with Chia Network, Inc. to make users whole.</li>
  <li>Sep 24 10:23 - We <a href="https://x.com/warpdotgreen/status/2102994609056145759?s=20">publicly announce</a> that the agreement has been finalized and signed. As part of this agreement, missing ERC20Bridge funds were replenished on-chain, repegging wUSDC/wUSDC.b.</li>
</ul>

<h2 id="moving-forward">Moving Forward</h2>

<p>We have evaluated multiple potential solutions to continue operations. As we would like to keep asset identifiers unchanged and avoid a re-deployment, we have opted for an off-chain fix. Validator software will be updated to perform additional validation on all transactions before signing. As part of these changes:</p>
<ul>
  <li>Only messages for supported applications, which can be fully validated, will be considered for signing.</li>
  <li>App-specific checks will run before a message is signed.</li>
  <li>A special message will be able to halt all validation immediately.</li>
</ul>

<p>We will use the learnings from this incident, as well as those from the <a href="https://blog.kuhi.to/tibetswap-v2-post-mortem">TibetSwap incident</a>, which happened in the same week, to further secure our protocol moving forward.</p>

<p>These changes have been made available for public review <a href="https://github.com/warpdotgreen/cli/pull/26">here</a> at the time this post-mortem was published. The code patch will be public for at least one week before being merged in order to allow for open review by the broader Chia community. Contributors who have already offered to help will also be asked to review the code during this window. After confirming the fixes, validators will update their software to the updated version, and the protocol will resume after a supermajority of validators has adopted the fix. We expect warp.green to be fully operational in October 2026.</p>

<h2 id="thanks">Thanks</h2>

<p>We would like to thank the following people for assistance in the war room created shortly after the hack:</p>
<ul>
  <li>Justin England (jde5011 - VP of Security at Chia Network, Inc.)</li>
  <li>dns (founder of <a href="https://dexie.space/">dexie.space</a>; initial advisor of the project &amp; validator)</li>
  <li>Bram Vollebregt (maxim_goods - Senior Security Engineer at Chia Network, Inc.)</li>
  <li>Brandon Haggstrom (Rigidity - creator of Sage wallet &amp; chia-wallet-sdk; Software Engineer at Chia Network, Inc.)</li>
  <li>Andreas Greimel (Acevail - founder of <a href="https://mintgarden.io/">MintGarden</a>; initial advisor of the project)</li>
</ul>

<p>Additionally, we would like to thank more parties for assistance in incident response and the ensuing forensics investigation, including:</p>
<ul>
  <li><a href="https://github.com/security-alliance/seal-911">SEAL 911</a></li>
  <li><a href="https://x.com/nftprofetmaster">nftprofetmaster</a></li>
</ul>

<p>Lastly, we would like to thank all parties contributing to make the protocol secure, and specifically to <a href="https://www.chia.net/">Chia Network, Inc.</a> for their additional support to make users whole.</p>]]></content><author><name>twitter:yakuhito</name></author><category term="blog" /><summary type="html"><![CDATA[TL;DR: On August 23, 2026, warp.green’s ERC-20 Bridge application was drained of almost all USDC. The funds have been replenished as part of an agreement with Chia Network, Inc., and the protocol will resume in October 2026 after the fix is validated. After a thorough investigation, we were unable to link the attacker’s wallets to a real identity.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blog2.kuhi.to/images/warpdotgreen.png" /><media:content medium="image" url="https://blog2.kuhi.to/images/warpdotgreen.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">So Long, and Thanks for All the Trades</title><link href="https://blog2.kuhi.to/so-long-and-thanks-for-all-the-trades" rel="alternate" type="text/html" title="So Long, and Thanks for All the Trades" /><published>2026-09-10T00:00:00+00:00</published><updated>2026-09-10T00:00:00+00:00</updated><id>https://blog2.kuhi.to/so-long-and-thanks-for-all-the-trades</id><content type="html" xml:base="https://blog2.kuhi.to/so-long-and-thanks-for-all-the-trades"><![CDATA[<p>TibetSwap will not be re-launching. It’s not a decision I’ve made lightly. While considering it, thinking about the journey so far brought me immense joy. So I would like to share TibetSwap’s history with you first.</p>

<h2 id="tibetswap-through-the-years">TibetSwap Through the Years</h2>

<p>In 2023, the Chia ecosystem was still young - <a href="https://dexie.space/markets">dexie</a> just launched, and no decentralized apps existed. In fact, the community was debating whether they could exist at all. As I recall, well over half of the messages I was reading on the topic said decentralized apps simply couldn’t exist because Chialisp was too complex to support them.</p>

<p>I know the argument doesn’t sound believable in retrospect - at that time, though, it did. Chia Network, Inc. (CNI) was supporting a path to an AMM by collaborating with Hashgreen, a fairly large (at some point, 20+ people) MIT-based team with many PhD students. Still, in 16 months, there was no (public) indication an AMM was anywhere close to being released.</p>

<p>That’s where TibetSwap came in. I had been working on an RPC provider for Chia (which would power TibetSwap for a long time until being replaced by Coinset) for multiple months, and I knew just enough to realize that a Turing-complete language <em>must</em> allow an AMM to exist. So I started reading the reference node code and released blockchain primitives to teach myself on-chain programming - it was so early that no docs were available for Chia.</p>

<p>After a few months, on March 2, 2023, I released the <code class="language-plaintext highlighter-rouge">tibet</code> repository to the <a href="https://x.com/TibetSwap/status/1631194967845773312?s=20">public</a> (<a href="https://x.com/TibetSwap/status/1631458383047061505?s=20">2nd link</a>). As you can probably tell from <a href="https://x.com/yakuhito/status/1631195527374331906?s=20">this thread</a>, I was proud and genuinely excited for the project - I’d managed to write code for something a lot of people deemed impossible out of my freshman dorm, after all.</p>

<p>I then reached out to all the CNI engineers I could find to ask them to review the code. That went much better than I’d expected - some of them looked over the architecture and made many useful suggestions. Along with others helping in the early days, they’re still in the <a href="https://github.com/yakuhito/tibet#special-thanks">Special Thanks section</a> of the main repository.</p>

<p>After all the improvements were in, TibetSwap went on testnet CLI-only. The UI was later <a href="https://x.com/TibetSwap/status/1648140008581394432?s=20">released on April 18, 2023</a>, and mainnet was launched <a href="https://x.com/TibetSwap/status/1650532624711163905?s=20">just 6 days after</a>.</p>

<p>As you can imagine, my eyes were glued to the screen over the next few days. I was watching and improving everything as we reached <a href="https://x.com/TibetSwap/status/1651257564137672704?s=20">over 1,800 XCH</a> (around $75,000 at the time) in just 2 days.</p>

<p>And then, luck had it that Ken (<a href="https://x.com/fizpawiz">@fizpawiz</a>) was there. He started reviewing the code a bit later than other engineers, but was still extremely thorough. He had been coming up with possible attacks repeatedly. Each time, I would reply why the attack wasn’t possible. Until, for one of them, I realized <a href="https://x.com/TibetSwap/status/1651349956060667906?s=20">it was</a>.</p>

<p>That event is well documented in the <a href="https://blog.kuhi.to/tibetswap-v1-post-mortem">post-mortem</a> that was released soon after, but I cannot overstate how grateful I am for people that decide to responsibly disclose bugs that are found (later, <a href="https://x.com/Ealrann">@Ealrann</a> and <a href="https://x.com/splitXCH">@splitXCH</a> helped the project in similar ways - more on that below). Exploits are bad for the project, the community behind it, and the creators - and I would not wish one upon anyone.</p>

<p>Even after a big setback, the work continued. I started creating more detailed resources, seeking additional reviews (shout out to BramV - maxim_goods), and TibetSwap got its own community-funded bug bounty pot. On May 14, 2023, <a href="https://x.com/TibetSwap/status/1657793225036550144?s=20">Toucan987 ‘formally’ joined the team</a> to help with UI/UX, which was by far my biggest weakness. One day later, <a href="https://x.com/TibetSwap/status/1658129000324292608?s=20">v2 launched</a> on mainnet.</p>

<p>On September 18, 2023, we <a href="https://x.com/TibetSwap/status/1703736826178220449?s=20">reached</a> what I call the “wallet peak.” We always believed an ecosystem is stronger together, and supporting all 5 wallets that were available at the time was a strong commitment to that idea. This was at a time when the other competing AMM was only supporting one (their) wallet.</p>

<p>On September 28, 2023, we launched the <a href="https://x.com/TibetSwap/status/1707320395400089949?s=20">current UI</a>, which I believe (and hope) the community has come to love since then. This came as a result of the incredible work of <a href="https://x.com/Toucan987">@Toucan987</a>, and I find myself appreciating it even today.</p>

<p>A fairly big pause of public communication followed. It wasn’t that we stopped working - in fact, quite the opposite. I had been working on the new version of TibetSwap, which I would come to refer to as v2.5. As I later mentioned <a href="https://blog.fireacademy.io/p/programmable-coins">in this post</a>, this version didn’t see the light of day because I realized just how much better v3 could be (over the already-existing v2.5, which I would say was a big leap). I talked more about v3 at <a href="https://youtu.be/5EyAoQfhXaQ">Chia Toronto 2025</a>, and how that led to game-changing primitives for dApps (action layer &amp; slots).</p>

<p>On December 23, 2024, <a href="https://x.com/TibetSwap/status/1870992361389781217?s=20">Sage support</a> was released. Even though it was late to the wallet game, we were early believers in the project - and, indeed, Sage is now probably the most widely used wallet in the community.</p>

<p>Around the same time, we made the then-optional 0.7% developer fee on swaps mandatory. The fee had not been significant until then, and it had never come close to paying for hosting costs. After the change, fees did begin to accumulate and made their way to the community as bounties, thank-yous, and tips for many reviews of new projects. To this day, I don’t think I’ve personally kept or cashed out any XCH from dev fees.</p>

<p>On February 28, 2025, TibetSwap finally allowed projects to automatically deploy new pairs <a href="https://github.com/Yakuhito/tibet-ui/commit/bb8e7df4e2fec3d96c8a859cc8921d6c363503a0">through the website</a>. Until then, they could only do that through a CLI interface, which meant I helped over 99% of the projects deploy their pairs - that’s about 185 deployments in total. I liked the process because it got me talking to an important part of the community, the CAT issuers themselves. For this reason, I only created the ‘Deploy’ page when I was forced to by the latest wave of new CATs, which had me dropping my work so often that I could barely get anything done for a week - a good problem to have! I kept checking newly deployed projects up until recently, though.</p>

<p>On March 16, 2025, the public CNI filing was released, <a href="https://x.com/TibetSwap/status/1901312681488843017?s=20">and it mentioned TibetSwap!</a> Reading “The leading automated market maker (AMM) on the Chia blockchain is TibetSwap, which uses funds from liquidity providers to allow anyone to trade XCH and digital assets” was one of my proudest moments, and I’ve been using “leading AMM” to refer to TibetSwap since.</p>

<p>On September 22, 2025, we opened up the design of <a href="https://x.com/TibetSwap/status/1969928604743279100?s=20">partial offers</a> to the public, built in (our first) collaboration with CNI. Soon after, on October 4, we also launched <a href="https://x.com/TibetSwap/status/1974337575688286571?s=20">rCAT-XCH pairs</a>.</p>

<p>Recently, on August 25, 2026, we were fortunate that another community member (<a href="https://x.com/Ealrann">@Ealrann</a>) <a href="https://x.com/TibetSwap/status/2092014706009518333?s=20">found a weakness</a> in TibetSwap first and disclosed it ethically. 3 years, 3 months, and 23 days after I rescued the <a href="https://x.com/yakuhito/status/1653284545964421120?s=20">relatively small amount stuck in v1</a>, I conducted another rescue and recovered the funds liquidity providers had in v2. More information can be found in the post-mortem posted <a href="https://blog.kuhi.to/tibetswap-v2-post-mortem">here</a>. I also wanted to thank <a href="https://x.com/splitXCH">@splitXCH</a> for finding another weakness in the design on August 28 and ethically disclosing it.</p>

<h2 id="where-we-are-now">Where We Are Now</h2>

<p>The week of August 23, with its warp.green hack, the CircuitDAO one, and many other disclosed vulnerabilities was a sign the blockchain landscape is changing very fast. Models have gotten very good at spotting bugs, managing to find them in codebases carefully reviewed by many good auditors (and also scanned with the previous generation). This raises the already high standards needed to run blockchain applications.</p>

<p>After much thinking, I’ve reached the conclusion that continuing to run TibetSwap responsibly, in this new era, would require much more effort than I can easily give the project. It would not be responsible of me, or fair to you, to simply relaunch and keep running the servers with a hands-off approach. I’ve also been fortunate enough to have many doors open elsewhere, making the opportunity cost very high.</p>

<p>To me, blockchain is powerful exactly because a motivated person can ship software that will go on to process millions in volume. I’m very proud of how far TibetSwap has come. It has been a true privilege to build and run it, and to be an active part of this amazing community.</p>

<p>So, once again, a heartfelt thank you to all of you.</p>

<p>yakuhito, over.</p>]]></content><author><name>twitter:yakuhito</name></author><category term="blog" /><summary type="html"><![CDATA[TibetSwap will not be re-launching. It’s not a decision I’ve made lightly. While considering it, thinking about the journey so far brought me immense joy. So I would like to share TibetSwap’s history with you first.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blog2.kuhi.to/images/tibetswap.jpg" /><media:content medium="image" url="https://blog2.kuhi.to/images/tibetswap.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">TibetSwap V2 - Post-Mortem</title><link href="https://blog2.kuhi.to/tibetswap-v2-post-mortem" rel="alternate" type="text/html" title="TibetSwap V2 - Post-Mortem" /><published>2026-09-10T00:00:00+00:00</published><updated>2026-09-10T00:00:00+00:00</updated><id>https://blog2.kuhi.to/tibetswap-v2-postmortem</id><content type="html" xml:base="https://blog2.kuhi.to/tibetswap-v2-post-mortem"><![CDATA[<p>On August 24, 2026, we confirmed a critical bug in the TibetSwap v2 puzzles. The bug was ethically disclosed by <a href="https://x.com/Ealrann">Aurélien Mora (Eal)</a>. Nearly all protocol funds were recovered the same night. A small remainder was taken by a third party and returned two days later. This post covers the bug, the rescue operation, what our security process did and did not catch, and what happens next.</p>

<h2 id="the-bug">The Bug</h2>

<p>The core issue was located in <a href="https://github.com/Yakuhito/tibet/blob/8ef8796f9c7a3959f0f9e1b40aa64755352212df/clsp/swap.clsp#L40-L44">swap.clsp</a>. The puzzle correctly required one reserve to increase and the other to decrease, but it never required the user-supplied input amount to be positive.</p>

<p>In Uniswap v1/v2 math, a negative amount describes the reversed trade. It is the equivalent of saying, “I will give you -1 SBX if you give me -1 XCH” instead of, “I will give you 1 XCH if you give me 1 SBX.” However, the sign of the 0.7% trade fee is also reversed. Repeated against the same pair (and aided by flash loans), this drains the reserves, as the trading fee gives more value to the party conducting the swap than what was put in. The fix is to add a <code class="language-plaintext highlighter-rouge">(&gt; amount 0)</code> assertion in the swap path for both standard and rCAT pairs.</p>

<h2 id="security">Security</h2>

<p>TibetSwap is a fully on-chain, decentralized protocol. Because the protocol cannot be paused or upgraded, security was treated as a priority from early testnet onward. After a bug was <a href="https://blog.kuhi.to/tibetswap-v1-post-mortem">responsibly disclosed in v1</a>, the v2 code was reviewed by the researcher who reported it. We also opened a community-funded security pot for bounty payouts and published extra documentation on the architecture of Chia’s first AMM.</p>

<p>I personally asked every Chialisp reviewer in the community I could reach to look at the code. The last full human review took place on 5-14 May 2023, when Bram went through the Chialisp and the drivers after the v1 incident.</p>

<p>We received two review reports from Chia Network, Inc. generated by their custom in-house AI security harness/scanner. The first one was received 4 months before the incident, on 23 April 2026. The second one was received less than 3 months before the incident, on 5 June 2026, after improvements were made to the system. Each report was screened immediately (within minutes) for high-impact findings and then read in full. Neither flagged this bug or anything in the same class.</p>

<h2 id="bundle-security">Bundle Security</h2>

<p>The rescue presented a tricky decision. Eal had already used an AI-generated proof of concept on one mainnet pair. However, having been entirely AI-generated, the code could prove to be unreliable. It worked once, and we were ultimately not comfortable pointing it at the rest of the TVL. Speed mattered, as the drain transaction was already visible on mainnet. At the same time, accuracy also mattered, as a bad spend could brick funds and thus prevent any eventual return to the rightful owners.</p>

<p>We took a cautious path that could still move quickly. We built a rescue tool from scratch, informed by Eal’s proof of concept, with two independent safety layers. First, each bundle included a security coin. That coin asserted the intended spends and destinations, blocking a third party from using replace-by-fee to redirect the funds. This pattern is extensively used by <a href="https://www.warp.green/">warp.green</a>, the <a href="https://rewards.fireacademy.io/">reward distributor</a>, and <a href="https://www.xchandles.com/">XCHandles</a>. It has been previously discussed with ecosystem contributors, and helpers were already integrated (by yakuhito) into <code class="language-plaintext highlighter-rouge">chia-wallet-sdk</code>. Second, Sage was used to create offers that would be used to request the rescued funds. While security coins partly depend on the underlying drivers to fully secure a bundle, the Sage offer logic was an independent check that has been thoroughly tested by now. Together, these checks gave us confidence that a broadcast bundle would deliver funds only to the recovery wallets.</p>

<p>Implementing the new tool was only possible because we had a significant part of driver code developed for an unreleased aggregator. This code was already able to parse and spend TibetSwap v2 pairs and had working simulator tests. The final tool was also tested through unit tests, full simulator runs, as well as rescues on smaller TVL pairs before being used on the biggest pairs of the protocol.</p>

<h2 id="timeline">Timeline</h2>

<p>This section contains the reconstructed timeline of major events. Times are UTC+3 (Romania). The rescue was complex, so this section is longer than that of a typical post-mortem.</p>

<ul>
  <li>24 August 2026, 17:56 UTC+3 - Eal messaged me (yakuhito) on Discord, describing a bug found by Daybreak Blue (OpenAI’s cybersecurity initiative model) with only one prompt. He mentioned that he does not know Chialisp well enough to validate it, but was able to use the AI-generated PoC code to remove all the liquidity of an XCH-PIZZA pair.</li>
  <li>18:06 - I acknowledged the message and started analyzing the TibetSwap code.</li>
  <li>18:11 - Eal clarified that he used the PoC on the mainnet XCH-PIZZA pair, sending an explorer link. I quickly confirmed the reserves were indeed drained on-chain, and paused the analytics service.</li>
  <li>18:13 - A war room was created with <a href="https://keybase.io/maxim_goods">maxim_goods</a> (Bram - Senior Security Engineer at Chia Network, Inc.) and <a href="https://keybase.io/jde5011">jde5011</a> (Justin - VP of Security at Chia Network, Inc.). They have extensive experience and have previously assisted with the v1 vulnerability.</li>
  <li>18:18 - I asked Eal if we can upgrade to Keybase.</li>
  <li>18:20 - I confirmed Eal’s account on Keybase and a separate group with him, Bram, and Justin was created.</li>
  <li>18:26 - Common understanding: bug was found with only one prompt to <code class="language-plaintext highlighter-rouge">gpt-daybreak-blue-latest</code>, which Eal prompted after the recent warp[.]green incident. Justin recommended we follow the course of action that “makes sense from a stewardship perspective.” We agreed that asking users to withdraw everything publicly would draw a lot of attention.</li>
  <li>18:32 - Bram pointed out that the exploit is visible on mainnet due to the XCH-PIZZA drain, so the time to conduct a white hat rescue is very limited. I confirmed the core exploit worked on paper. Code from TibetSwap’s unreleased trade aggregator can be used as a base for a Rust-based rescue tool.</li>
  <li>18:36 - Eal sent the PoC code he used. The conversation moved to the war room to coordinate rescue.</li>
  <li>18:56 - General-purpose models refused to help build a rescue tool due to safety concerns. Bram suggested using GLM-5.2 and Kimi K2, which did not refuse any prompts.</li>
  <li>19:02 - Development of the rescue tool had started. Given the time-sensitive nature of the operation, we adopted (at Bram’s suggestion) a hard deadline of 3 hours. If the rescue tool was not ready by then, Eal’s PoC code would be used to rescue funds.</li>
  <li>19:17 - Parallel to the rescue tool development process, I started developing a monitoring tool that would alert me in the case of incoming attacks on TibetSwap at Bram’s suggestion.</li>
  <li>19:36 - The monitoring tool went online, and I started setting up the PoC code.</li>
  <li>19:56 - The PoC code setup was finished. If any pair was drained, I was ready to use the PoC at a moment’s notice to recover as many assets as possible.</li>
  <li>20:08 - The preliminary rescue tool was ready, and I started establishing validation criteria. The tool would be run on a simulator mirroring the current protocol state. It would be tested on one pair only, then as many pairs as possible at a time. Validation would target low-TVL pairs until we were very confident the rescue tool worked - after all, we would prioritize pairs with high TVL.</li>
  <li>20:34 - A first-pass human &amp; AI-assisted review of the rescue tool was done. A 2nd layer of security would be added through offers. rCAT support was postponed, as all rCAT pairs contained &lt;1% of the TVL at risk (~1123 XCH). More reviews and simulator testing were planned.</li>
  <li>21:50 - A rescue transaction on a single pair was successfully confirmed on mainnet.</li>
  <li>22:03 - First confirmation of a multi-pair rescue.</li>
  <li>22:13 - Multiple confirmations that the multi-pair rescue worked. We were confident the rescue tool worked.</li>
  <li>22:15 - After final checks, the first high-value-pair bundle was in the mempool. We had gone from the first report to the first high-TVL rescue transaction in under 4 hours and 20 minutes.</li>
  <li>22:16 - We confirmed that &gt;$160,000 out of the $200,000 TVL had been rescued through the first transaction through multiple avenues. The rescue process would continue for all pairs, ordered by TVL.</li>
  <li>22:31 - I updated Eal that over 80% of the funds at risk had been rescued. I also thanked him for reporting the vulnerability.</li>
  <li>22:45 - Over 216 out of 367 pairs were rescued, and rCAT support was in progress.</li>
  <li>23:36 - Rescue operation continued to progress. A draft for a post on X was ready.</li>
  <li>25 August 2026, 01:07 - A different strategy was used for rCAT pairs. The funds from all but one had been recovered. I was working on rescuing the last pair, which needed a different transaction structure given its very low fee.</li>
  <li>01:22 - We <a href="https://x.com/TibetSwap/status/2092014706009518333">posted</a> that we believed all 367 pairs had been rescued in under 7 hours and 30 minutes after the initial report.</li>
  <li>03:04 - An on-chain check revealed that funds corresponding to 28 pairs had not landed in our recovery wallets. About 151.8 XCH plus the paired tokens, under 0.2% of TVL and roughly $500, had gone to <code class="language-plaintext highlighter-rouge">xch152qs7dx8q47udq8tyzljju60kkyuhvww2htczaj4fz32u4pa38ksqy9ap8</code>. I flagged the address for investigation.</li>
  <li>18:45 - I confirmed the address was not one of mine. Eal had also just confirmed it was not his. The working theory is that someone replayed the method from a public rescue spend and drained pairs we had not yet swept. A forensic investigation began.</li>
  <li>26 August 2026, 13:55 - We <a href="https://x.com/TibetSwap/status/2092566512527704179">announced the finding on X</a>. I intended to cover the 151.8 XCH side of the loss using previously obtained dev fees.</li>
  <li>17:23 - The unknown address returned the funds in full, which we <a href="https://x.com/TibetSwap/status/2092619049343586704">announced here</a>. The ongoing forensic investigation, which had already advanced quite far, was stopped.</li>
</ul>

<h2 id="moving-forward">Moving Forward</h2>

<p>Current AI model capability means on-chain projects have to spend more effort on security than the last few years required. Given our experiences, we believe at least the following items should be considered:</p>

<ul>
  <li><strong>Regular AI audits</strong>, both done by 3rd parties and performed in-house using the latest models. Projects should re-audit as soon as a new capable model is available. This means watching new model releases and getting into as many vetted defensive-access programs as possible.</li>
  <li><strong>Well-advertised bug bounty programs</strong>, which security researchers can easily find should they identify a bug first. Terms should be public, and the process should ideally run through a third party.</li>
  <li><strong>Monitoring</strong> to quickly notify the team of live exploit attempts.</li>
</ul>

<p>We <a href="https://x.com/TibetSwap/status/2097993691633713553?s=20">have announced</a> a plan to distribute recovered funds at the same time as this post. Pending any change of plans, all funds should be returned to their owners by September 19, 2026.</p>

<p>Following this incident, TibetSwap will not be re-launching on Chia at this time. A reflection and a record of the history of the protocol can be found <a href="https://blog.kuhi.to/so-long-and-thanks-for-all-the-trades">here</a>.</p>

<p>After the rescue, <a href="https://x.com/splitXCH">splitXCH</a> shared Fable 5 security scans, one of which found a separate issue in the TibetSwap code. It was not exploited, and it will be described in a note inside the <a href="https://github.com/yakuhito/tibet">tibet</a> repository. I thank him for his help.</p>

<p>The tibet repository will soon be updated with a note that includes a link to this post, a description of the known vulnerabilities in the code, and fix suggestions. Following this update, all tibet-related repositories will be archived.</p>

<h2 id="thanks">Thanks</h2>

<p>A massive thank you to <a href="https://x.com/Ealrann">Aurélien Mora</a> for not only thinking to audit the code for the good of the community, but also responsibly disclosing it. Until October 1st, donations will be collected to add to the security-pot XCH and the latest batch of dev fees for the bounty. I hope the community’s thanks, and the bounty we put together, make it obvious that reporting bugs this way is the right way to go.</p>

<p>Second, thank you to Justin and Bram, as well as the broader Chia Network, Inc., for always being there during hard moments like these.</p>

<p>Lastly, thank you to the community, which has once again shown unwavering support when it mattered most. Thank you.</p>

<p>yakuhito, over.</p>]]></content><author><name>twitter:yakuhito</name></author><category term="blog" /><summary type="html"><![CDATA[On August 24, 2026, we confirmed a critical bug in the TibetSwap v2 puzzles. The bug was ethically disclosed by Aurélien Mora (Eal). Nearly all protocol funds were recovered the same night. A small remainder was taken by a third party and returned two days later. This post covers the bug, the rescue operation, what our security process did and did not catch, and what happens next.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blog2.kuhi.to/images/tibetswap.jpg" /><media:content medium="image" url="https://blog2.kuhi.to/images/tibetswap.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Programmable Coins</title><link href="https://blog2.kuhi.to/programmable-coins/" rel="alternate" type="text/html" title="Programmable Coins" /><published>2026-07-24T00:00:00+00:00</published><updated>2026-07-24T00:00:00+00:00</updated><id>https://blog2.kuhi.to/programmable-coins</id><content type="html" xml:base="https://blog2.kuhi.to/programmable-coins/"><![CDATA[]]></content><author><name>twitter:yakuhito</name></author><category term="fireacademy" /><summary type="html"><![CDATA[]]></summary></entry><entry><title type="html">A dApp Developer’s Perspective on Rue v. Chialisp</title><link href="https://blog2.kuhi.to/a-dapp-developers-perspective-on-rue-vs-chialisp/" rel="alternate" type="text/html" title="A dApp Developer’s Perspective on Rue v. Chialisp" /><published>2026-02-19T00:00:00+00:00</published><updated>2026-02-19T00:00:00+00:00</updated><id>https://blog2.kuhi.to/a-dapp-developers-perspective-on-rue-vs-chialisp</id><content type="html" xml:base="https://blog2.kuhi.to/a-dapp-developers-perspective-on-rue-vs-chialisp/"><![CDATA[]]></content><author><name>twitter:yakuhito</name></author><category term="fireacademy" /><summary type="html"><![CDATA[]]></summary></entry><entry><title type="html">How Low CAT Precision Can Become an Issue</title><link href="https://blog2.kuhi.to/too-discrete-to-handle/" rel="alternate" type="text/html" title="How Low CAT Precision Can Become an Issue" /><published>2025-09-03T00:00:00+00:00</published><updated>2025-09-03T00:00:00+00:00</updated><id>https://blog2.kuhi.to/too-discrete-to-handle</id><content type="html" xml:base="https://blog2.kuhi.to/too-discrete-to-handle/"><![CDATA[]]></content><author><name>twitter:yakuhito</name></author><category term="fireacademy" /><summary type="html"><![CDATA[]]></summary></entry><entry><title type="html">Reward Distributors 101</title><link href="https://blog2.kuhi.to/reward-distributors-101/" rel="alternate" type="text/html" title="Reward Distributors 101" /><published>2025-07-24T00:00:00+00:00</published><updated>2025-07-24T00:00:00+00:00</updated><id>https://blog2.kuhi.to/reward-distributors-101</id><content type="html" xml:base="https://blog2.kuhi.to/reward-distributors-101/"><![CDATA[]]></content><author><name>twitter:yakuhito</name></author><category term="fireacademy" /><summary type="html"><![CDATA[]]></summary></entry><entry><title type="html">Top 3 Vulnerabilities I Found in the CircuitDAO Codebase</title><link href="https://blog2.kuhi.to/top-3-vulnerabilities/" rel="alternate" type="text/html" title="Top 3 Vulnerabilities I Found in the CircuitDAO Codebase" /><published>2025-07-23T00:00:00+00:00</published><updated>2025-07-23T00:00:00+00:00</updated><id>https://blog2.kuhi.to/top-3-vulnerabilities</id><content type="html" xml:base="https://blog2.kuhi.to/top-3-vulnerabilities/"><![CDATA[]]></content><author><name>twitter:yakuhito</name></author><category term="fireacademy" /><summary type="html"><![CDATA[]]></summary></entry><entry><title type="html">Announcing CATalog and XCHandles</title><link href="https://blog2.kuhi.to/announcing-catalog-and-xchandles/" rel="alternate" type="text/html" title="Announcing CATalog and XCHandles" /><published>2024-12-23T00:00:00+00:00</published><updated>2024-12-23T00:00:00+00:00</updated><id>https://blog2.kuhi.to/announcing-catalog-and-xchandles</id><content type="html" xml:base="https://blog2.kuhi.to/announcing-catalog-and-xchandles/"><![CDATA[]]></content><author><name>twitter:yakuhito</name></author><category term="fireacademy" /><summary type="html"><![CDATA[]]></summary></entry><entry><title type="html">Solving the Problem of Uniqueness</title><link href="https://blog2.kuhi.to/solving-the-problem-of-uniqueness/" rel="alternate" type="text/html" title="Solving the Problem of Uniqueness" /><published>2024-12-22T00:00:00+00:00</published><updated>2024-12-22T00:00:00+00:00</updated><id>https://blog2.kuhi.to/solving-the-problem-of-uniqueness</id><content type="html" xml:base="https://blog2.kuhi.to/solving-the-problem-of-uniqueness/"><![CDATA[]]></content><author><name>twitter:yakuhito</name></author><category term="fireacademy" /><summary type="html"><![CDATA[]]></summary></entry></feed>