<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0"><channel><title><![CDATA[Arsen]]></title><description><![CDATA[Blockchain Security Engineer]]></description><link>https://newsletter.arsen.ac</link><image><url>https://substackcdn.com/image/fetch/$s_!z8Le!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e72176b-3097-4ef8-a795-78904f93495b_256x256.png</url><title>Arsen</title><link>https://newsletter.arsen.ac</link></image><generator>Substack</generator><lastBuildDate>Wed, 30 Sep 2026 22:44:49 GMT</lastBuildDate><atom:link href="https://newsletter.arsen.ac/feed" rel="self" type="application/rss+xml"/><copyright><![CDATA[Arsen. Web3 Security]]></copyright><language><![CDATA[en]]></language><webMaster><![CDATA[arsen@substack.com]]></webMaster><itunes:owner><itunes:email><![CDATA[arsen@substack.com]]></itunes:email><itunes:name><![CDATA[Arsen]]></itunes:name></itunes:owner><itunes:author><![CDATA[Arsen]]></itunes:author><googleplay:owner><![CDATA[arsen@substack.com]]></googleplay:owner><googleplay:email><![CDATA[arsen@substack.com]]></googleplay:email><googleplay:author><![CDATA[Arsen]]></googleplay:author><itunes:block><![CDATA[Yes]]></itunes:block><item><title><![CDATA[How to hack a Bitcoin light client?]]></title><description><![CDATA[Three merkle proofs verify the structure. The fourth check is a substring search on a field the miner fills in by hand.]]></description><link>https://newsletter.arsen.ac/p/the-proof-the-miner-writes-himself</link><guid isPermaLink="false">https://newsletter.arsen.ac/p/the-proof-the-miner-writes-himself</guid><dc:creator><![CDATA[Arsen]]></dc:creator><pubDate>Mon, 07 Sep 2026 16:02:29 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/918cc5af-773b-467e-af10-c5482af5dd98_974x530.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The light client verifies one merkle proof before it accepts a block.</p><p>That proof is correct.</p><p>The value it then goes looking for is one the submitter computed himself.</p><p>And it goes looking for it with a text search.</p><p>Quick refresh so we&#8217;re on the same page.</p><p>Some chains don&#8217;t mine their own blocks.</p><p>Dogecoin is one.</p><p>Miners point their hardware at Litecoin, and the same work counts for both chains at once.</p><p>That&#8217;s merged mining, and it&#8217;s a good deal.</p><p>One machine, two rewards, no extra electricity.</p><p>The proof has to live somewhere, and it lives on the parent chain:</p><ul><li><p> Every block starts with a coinbase, the transaction that pays the miner.</p></li><li><p>The coinbase has a field with no consensus meaning at all. Free space.</p></li><li><p>The child chain&#8217;s commitment gets written into that free space.</p></li><li><p>Whoever mines the parent block writes that field. By hand. Anything they want.</p></li></ul><p>Three words you&#8217;ll need:</p><ul><li><p> <strong>Coinbase</strong> - the first transaction in a block. Pays the miner.</p></li><li><p><strong>script_sig</strong> - the free-space field inside it.</p></li><li><p><strong>chain_root</strong> - the commitment that says which child block this work belongs to.</p></li></ul><p>Now the light client.</p><p>You review the aux path and it looks like the strongest code in the file.</p><p>Merkle tooling everywhere.</p><p>Four steps, one after another.</p><p><strong>Step one:</strong> this parent block hasn&#8217;t been used before.</p><p><strong>Step two:</strong> the coinbase transaction is proven into the parent block&#8217;s merkle root. That one is real.</p><p><strong>Step three:</strong> a chain_root is computed. Not verified. Computed, out of the child block hash, a chain id, and a merkle proof.</p><p>All three of those come from whoever is submitting.</p><p>&#8220;It&#8217;s covered in merkle proofs. What could go wrong?&#8221;</p><p>Read step four.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!gY3d!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4ff178d-d1c7-4cd3-95e4-f37895bbba06_902x598.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!gY3d!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4ff178d-d1c7-4cd3-95e4-f37895bbba06_902x598.png 424w, https://substackcdn.com/image/fetch/$s_!gY3d!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4ff178d-d1c7-4cd3-95e4-f37895bbba06_902x598.png 848w, https://substackcdn.com/image/fetch/$s_!gY3d!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4ff178d-d1c7-4cd3-95e4-f37895bbba06_902x598.png 1272w, https://substackcdn.com/image/fetch/$s_!gY3d!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4ff178d-d1c7-4cd3-95e4-f37895bbba06_902x598.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!gY3d!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4ff178d-d1c7-4cd3-95e4-f37895bbba06_902x598.png" width="902" height="598" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b4ff178d-d1c7-4cd3-95e4-f37895bbba06_902x598.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:598,&quot;width&quot;:902,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:107864,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://defendor.substack.com/i/213018700?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4ff178d-d1c7-4cd3-95e4-f37895bbba06_902x598.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!gY3d!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4ff178d-d1c7-4cd3-95e4-f37895bbba06_902x598.png 424w, https://substackcdn.com/image/fetch/$s_!gY3d!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4ff178d-d1c7-4cd3-95e4-f37895bbba06_902x598.png 848w, https://substackcdn.com/image/fetch/$s_!gY3d!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4ff178d-d1c7-4cd3-95e4-f37895bbba06_902x598.png 1272w, https://substackcdn.com/image/fetch/$s_!gY3d!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4ff178d-d1c7-4cd3-95e4-f37895bbba06_902x598.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image buttonBase-GK1x3M"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg" class="icon-noB79L"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image buttonBase-GK1x3M"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2 icon-noB79L"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><code>.contains()</code>.</p><p>Step two proves structure. Step three derives a number out of attacker input. Step four searches for that number.</p><p>Only one of the four is a check.</p><p>It renders the script to a hex string and asks whether the derived root appears somewhere inside it.</p><p>Somewhere.</p><p>Not at the offset the format specifies. Not once. Not after the marker bytes that say the merged mining section starts here.</p><p>Anywhere in the string is a pass.</p><p>And the field it searches is the one field on the parent chain that a miner fills in freely.</p><p>The attack is not complicated:</p><ul><li><p>miner writes their own chain_root into script_sig</p></li><li><p>writes the honest one in after it</p></li><li><p>both are present in the hex</p></li><li><p><code>.contains()</code> finds whichever it is asked about</p></li><li><p>the same parent block now attests to two different child blocks</p></li><li><p>the light client accepts the one it was handed</p></li></ul><p>The merged mining format exists to stop exactly this.</p><p>There are marker bytes, a position rule, a size and a nonce, and a requirement that the commitment appear once.</p><p>None of that is checked here.</p><p>The format was replaced by a substring search.</p><p>There&#8217;s a second problem in the same line, pointing at the same cause.</p><p><code>.to_hex_string()</code> and <code>.to_string()</code> are two renderings by two different types.</p><p>Bitcoin stores hashes little endian.</p><p>Display prints them the other way round.</p><p>So an honest submitter, handing over correct data in the byte order the chain actually uses, fails this check.</p><p>The search is wrong in both directions. It admits what it shouldn&#8217;t, and it rejects what it should take.</p><p>When you audit a commitment check, ask:</p><ul><li><p>Is this comparing bytes, or comparing strings that describe bytes?</p></li><li><p>Does the format specify a position, and is the position enforced?</p></li><li><p>Can the field appear twice? What happens if it does?</p></li><li><p>Who writes the field being searched? If the answer is a miner, it is attacker input.</p></li><li><p>Are the two sides of the comparison the same type, rendered the same way?</p></li></ul><p>Most reviews check whether the value is there.</p><blockquote><p>Finding a value is not the same as validating where it sits.</p></blockquote><p>The usual version of this finding is a missing check.</p><p>Something absent, you grep for it, you find the gap.</p><p>Here the check is present, and it runs, and it passes for the honest case in every test.</p><p>It is the wrong kind of check, and the wrong kind of check looks exactly like the right kind until someone writes a second value into the same field.</p><blockquote><p>Root cause: a structural commitment verified by substring search.</p></blockquote><p>Two fixes.</p><ol><li><p>Parse the script instead of searching it. Find the marker, read the commitment at the offset the format defines, reject the block if it appears more than once.</p></li><li><p>Compare bytes to bytes. The hex round trip is what let two different orderings look comparable in the first place.</p></li></ol><p>The fix that shipped was neither. Access control, so only the relayer can submit blocks.</p><p>That closes the door. It doesn&#8217;t fix the lock.</p><div><hr></div><p>Arsen</p>]]></content:encoded></item><item><title><![CDATA[How to get wrecked via Solana RPC.]]></title><description><![CDATA[An off-chain service asked the chain how an account was created. Anyone could change the answer for one lamport.]]></description><link>https://newsletter.arsen.ac/p/how-to-get-wrecked-via-solana-rpc</link><guid isPermaLink="false">https://newsletter.arsen.ac/p/how-to-get-wrecked-via-solana-rpc</guid><dc:creator><![CDATA[Arsen]]></dc:creator><pubDate>Mon, 31 Aug 2026 16:03:30 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/6b806986-328b-4d95-ad26-de7836b91a2a_970x537.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The service pulls every account the program owns, no filter, and figures out the rest later.</p><p>The service needs to know how an account was created.</p><p>The account is real.</p><p>Its history is real.</p><p>It still reads the wrong transaction out of it.</p><p>Quick refresh so we&#8217;re on the same page.</p><blockquote><p><strong>On Solana an account stores state.</strong></p></blockquote><p>Current state, nothing else.</p><p>It doesn&#8217;t store how it got there.</p><p>No created_at, no origin field, nothing that says which transaction made it.</p><p>That&#8217;s a good design. Accounts stay small and cheap.</p><p>But if you want the creation transaction, you ask an RPC node for the address history.</p><p>The tradeoff this bug lives on:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!wpFq!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff376cc28-b8ec-406c-9031-98b93fce8f0e_2314x762.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!wpFq!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff376cc28-b8ec-406c-9031-98b93fce8f0e_2314x762.png 424w, https://substackcdn.com/image/fetch/$s_!wpFq!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff376cc28-b8ec-406c-9031-98b93fce8f0e_2314x762.png 848w, https://substackcdn.com/image/fetch/$s_!wpFq!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff376cc28-b8ec-406c-9031-98b93fce8f0e_2314x762.png 1272w, https://substackcdn.com/image/fetch/$s_!wpFq!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff376cc28-b8ec-406c-9031-98b93fce8f0e_2314x762.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!wpFq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff376cc28-b8ec-406c-9031-98b93fce8f0e_2314x762.png" width="728" height="239.5" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f376cc28-b8ec-406c-9031-98b93fce8f0e_2314x762.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;normal&quot;,&quot;height&quot;:479,&quot;width&quot;:1456,&quot;resizeWidth&quot;:728,&quot;bytes&quot;:398576,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://defendor.substack.com/i/212825463?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff376cc28-b8ec-406c-9031-98b93fce8f0e_2314x762.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:&quot;center&quot;,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!wpFq!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff376cc28-b8ec-406c-9031-98b93fce8f0e_2314x762.png 424w, https://substackcdn.com/image/fetch/$s_!wpFq!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff376cc28-b8ec-406c-9031-98b93fce8f0e_2314x762.png 848w, https://substackcdn.com/image/fetch/$s_!wpFq!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff376cc28-b8ec-406c-9031-98b93fce8f0e_2314x762.png 1272w, https://substackcdn.com/image/fetch/$s_!wpFq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff376cc28-b8ec-406c-9031-98b93fce8f0e_2314x762.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Three words you&#8217;ll need:</p><ul><li><p><strong>PDA</strong> - the account the program creates for each request.</p></li><li><p><strong>Signature</strong> - the ID of a transaction.</p></li><li><p><strong>Backfill</strong> - the catch-up path. Service was down, now it re-reads what it missed.</p></li></ul><p>Now the service.</p><p>The on-chain program was clean.</p><p>Zero findings there.</p><p>So you&#8217;re in the off-chain part. Rust, RPC calls, plumbing.</p><p><strong>First pass</strong>: does it parse the account correctly? It does.</p><p><strong>Second pass</strong>: retries, error handling, deserialization. All fine.</p><p>You never ask: what does this RPC actually promise about order?</p><p>And who else can write into what it returns?</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Ym0_!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2d597092-ea10-4f5f-8f8b-010abeff9ff4_798x364.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Ym0_!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2d597092-ea10-4f5f-8f8b-010abeff9ff4_798x364.png 424w, https://substackcdn.com/image/fetch/$s_!Ym0_!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2d597092-ea10-4f5f-8f8b-010abeff9ff4_798x364.png 848w, https://substackcdn.com/image/fetch/$s_!Ym0_!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2d597092-ea10-4f5f-8f8b-010abeff9ff4_798x364.png 1272w, https://substackcdn.com/image/fetch/$s_!Ym0_!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2d597092-ea10-4f5f-8f8b-010abeff9ff4_798x364.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Ym0_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2d597092-ea10-4f5f-8f8b-010abeff9ff4_798x364.png" width="798" height="364" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2d597092-ea10-4f5f-8f8b-010abeff9ff4_798x364.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:364,&quot;width&quot;:798,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:65588,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://defendor.substack.com/i/212825463?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2d597092-ea10-4f5f-8f8b-010abeff9ff4_798x364.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Ym0_!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2d597092-ea10-4f5f-8f8b-010abeff9ff4_798x364.png 424w, https://substackcdn.com/image/fetch/$s_!Ym0_!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2d597092-ea10-4f5f-8f8b-010abeff9ff4_798x364.png 848w, https://substackcdn.com/image/fetch/$s_!Ym0_!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2d597092-ea10-4f5f-8f8b-010abeff9ff4_798x364.png 1272w, https://substackcdn.com/image/fetch/$s_!Ym0_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2d597092-ea10-4f5f-8f8b-010abeff9ff4_798x364.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image buttonBase-GK1x3M"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg" class="icon-noB79L"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image buttonBase-GK1x3M"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2 icon-noB79L"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><code>.first()</code>. That&#8217;s the whole bug.</p><p>And it runs once per account, inside the sweep.</p><p>Here&#8217;s the interesting part.</p><p>There are two ways this service learns about a request.</p><p><strong>Live path: a websocket event arrives and the signature is inside it.</strong></p><p>The service parses that one transaction, and it&#8217;s correct by construction.</p><p>Nobody picked the signature. It was handed over.</p><p>Backfill path: no event.</p><p><em><strong>So the service asks for every account the program owns, then asks each account for its signatures, then takes the first one, then calls the same parsing function as the live path.</strong></em></p><p>&#8220;Same function at the end. What could go wrong?&#8221;</p><p>The live path never had to choose.</p><p>The backfill path invented a lookup, and it identifies the creation transaction by position in a list.</p><blockquote><p>Position in a list that strangers can push to.</p></blockquote><p>The attack is not complicated:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!6QJM!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc595d751-690f-4ed3-bed1-4dffa29350c4_2392x1098.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!6QJM!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc595d751-690f-4ed3-bed1-4dffa29350c4_2392x1098.png 424w, https://substackcdn.com/image/fetch/$s_!6QJM!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc595d751-690f-4ed3-bed1-4dffa29350c4_2392x1098.png 848w, https://substackcdn.com/image/fetch/$s_!6QJM!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc595d751-690f-4ed3-bed1-4dffa29350c4_2392x1098.png 1272w, https://substackcdn.com/image/fetch/$s_!6QJM!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc595d751-690f-4ed3-bed1-4dffa29350c4_2392x1098.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!6QJM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc595d751-690f-4ed3-bed1-4dffa29350c4_2392x1098.png" width="1456" height="668" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c595d751-690f-4ed3-bed1-4dffa29350c4_2392x1098.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:668,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:497456,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://defendor.substack.com/i/212825463?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc595d751-690f-4ed3-bed1-4dffa29350c4_2392x1098.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!6QJM!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc595d751-690f-4ed3-bed1-4dffa29350c4_2392x1098.png 424w, https://substackcdn.com/image/fetch/$s_!6QJM!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc595d751-690f-4ed3-bed1-4dffa29350c4_2392x1098.png 848w, https://substackcdn.com/image/fetch/$s_!6QJM!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc595d751-690f-4ed3-bed1-4dffa29350c4_2392x1098.png 1272w, https://substackcdn.com/image/fetch/$s_!6QJM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc595d751-690f-4ed3-bed1-4dffa29350c4_2392x1098.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image buttonBase-GK1x3M"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg" class="icon-noB79L"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image buttonBase-GK1x3M"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2 icon-noB79L"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Who pays for it: the catch-up path itself.</p><p>It&#8217;s a denial of service on backfill, not one stuck request.</p><p>Everything that was waiting to be caught up keeps waiting.</p><p>The attacker spends one lamport for that.</p><p>When you audit any off-chain service that reads chain state, check:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!dXqn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c7f7a50-5470-454e-b9f9-f57b4f6a2ed7_2452x832.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!dXqn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c7f7a50-5470-454e-b9f9-f57b4f6a2ed7_2452x832.png 424w, https://substackcdn.com/image/fetch/$s_!dXqn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c7f7a50-5470-454e-b9f9-f57b4f6a2ed7_2452x832.png 848w, https://substackcdn.com/image/fetch/$s_!dXqn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c7f7a50-5470-454e-b9f9-f57b4f6a2ed7_2452x832.png 1272w, https://substackcdn.com/image/fetch/$s_!dXqn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c7f7a50-5470-454e-b9f9-f57b4f6a2ed7_2452x832.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!dXqn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c7f7a50-5470-454e-b9f9-f57b4f6a2ed7_2452x832.png" width="1456" height="494" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5c7f7a50-5470-454e-b9f9-f57b4f6a2ed7_2452x832.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:494,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:459341,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://defendor.substack.com/i/212825463?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c7f7a50-5470-454e-b9f9-f57b4f6a2ed7_2452x832.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!dXqn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c7f7a50-5470-454e-b9f9-f57b4f6a2ed7_2452x832.png 424w, https://substackcdn.com/image/fetch/$s_!dXqn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c7f7a50-5470-454e-b9f9-f57b4f6a2ed7_2452x832.png 848w, https://substackcdn.com/image/fetch/$s_!dXqn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c7f7a50-5470-454e-b9f9-f57b4f6a2ed7_2452x832.png 1272w, https://substackcdn.com/image/fetch/$s_!dXqn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c7f7a50-5470-454e-b9f9-f57b4f6a2ed7_2452x832.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image buttonBase-GK1x3M"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg" class="icon-noB79L"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image buttonBase-GK1x3M"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2 icon-noB79L"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>The model worth keeping:</p><blockquote><p>The account tells you its state. It never tells you its story.</p></blockquote><p>And the story is a list strangers can write to.</p><p>Everyone knows not to trust user input.</p><p>Almost nobody counts a transaction history as user input.</p><p>But that&#8217;s what it is.</p><p>It&#8217;s not the account&#8217;s own data. It&#8217;s a list a node keeps about an address, and the address is public, so the list is open.</p><p>Root cause, one line:</p><blockquote><p><em><strong>Off-chain identity taken from position in a list anyone can append to.</strong></em></p></blockquote><p>Two fixes.</p><ol><li><p>Use <code>.last()</code> instead of <code>.first()</code>. Fixes the order, and it holds until someone spams the address - <code>getSignaturesForAddress</code> returns 1000 signatures max, so <code>.last()</code> is the oldest of that page, not the oldest ever.</p></li><li><p>Stop reading history at all. Put the access mode directly in the PDA, so the state answers the question and there is no signature scan left to attack.</p></li></ol><p>The team went with the second one. Design review, program changed, the whole traversal deleted.</p><div><hr></div><p>Arsen</p>]]></content:encoded></item><item><title><![CDATA[How Correct Code Loses Money]]></title><description><![CDATA[Every function did exactly what it was written to do.]]></description><link>https://newsletter.arsen.ac/p/how-correct-code-loses-money</link><guid isPermaLink="false">https://newsletter.arsen.ac/p/how-correct-code-loses-money</guid><dc:creator><![CDATA[Arsen]]></dc:creator><pubDate>Fri, 21 Aug 2026 18:01:42 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/1a5928dd-991d-465a-8de4-3839a29d853e_648x353.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The trader owed $600 in fees.</p><p>He had $250 left to pay them with.</p><p>The protocol took the $250, marked the bill settled, then paid him $450 on top.</p><p>He should have walked away with $100.</p><p>He walked away with $450.</p><p>Quick refresh so we&#8217;re on the same page.</p><p>A perp lets you hold a leveraged long or short with no expiry date.</p><p>You post collateral, the protocol marks profit and loss against it, and you sit there forever.</p><p>Forever is the problem.</p><p>Nothing drags a perp&#8217;s price back to spot the way an expiry does.</p><p>So perps use funding, a steady payment between the two sides:</p><p>&#8226; Longs crowded &#8594; longs pay shorts. </p><p>&#8226; Shorts crowded &#8594; shorts pay longs. </p><p>&#8226; It flips whenever the crowd flips.</p><p>So funding is sometimes money you owe, and sometimes money you&#8217;re owed.</p><p>Four words you&#8217;ll need:</p><p>&#8226; <strong>Margin</strong> - the collateral you posted. Fees come out of it. </p><p>&#8226; <strong>PnL</strong> - profit and loss, applied to margin before anything else. </p><p>&#8226; <strong>Funding income</strong> - funding owed to you, when you&#8217;re on the paid side. </p><p>&#8226; <strong>Liquidation check</strong> - the function that decides if you can stay open.</p><p>Now the close path.</p><p>First pass: you read the settlement code. Every line does what it says.</p><p>Second pass: you read the liquidation check.</p><p>Also fine. Deliberate, correct, even commented.</p><p>Both files pass review. Separately.</p><p>You never ask whether the two of them are counting the same money.</p><p>&#8220;It&#8217;s a fee deduction. What could go wrong?&#8221;</p><p>Read it in order.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Sfke!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4e7d59b-e35e-462d-b3aa-b4d32be7b500_675x389.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Sfke!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4e7d59b-e35e-462d-b3aa-b4d32be7b500_675x389.png 424w, https://substackcdn.com/image/fetch/$s_!Sfke!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4e7d59b-e35e-462d-b3aa-b4d32be7b500_675x389.png 848w, https://substackcdn.com/image/fetch/$s_!Sfke!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4e7d59b-e35e-462d-b3aa-b4d32be7b500_675x389.png 1272w, https://substackcdn.com/image/fetch/$s_!Sfke!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4e7d59b-e35e-462d-b3aa-b4d32be7b500_675x389.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Sfke!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4e7d59b-e35e-462d-b3aa-b4d32be7b500_675x389.png" width="675" height="389" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a4e7d59b-e35e-462d-b3aa-b4d32be7b500_675x389.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:389,&quot;width&quot;:675,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:64019,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://defendor.substack.com/i/211570896?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4e7d59b-e35e-462d-b3aa-b4d32be7b500_675x389.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Sfke!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4e7d59b-e35e-462d-b3aa-b4d32be7b500_675x389.png 424w, https://substackcdn.com/image/fetch/$s_!Sfke!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4e7d59b-e35e-462d-b3aa-b4d32be7b500_675x389.png 848w, https://substackcdn.com/image/fetch/$s_!Sfke!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4e7d59b-e35e-462d-b3aa-b4d32be7b500_675x389.png 1272w, https://substackcdn.com/image/fetch/$s_!Sfke!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4e7d59b-e35e-462d-b3aa-b4d32be7b500_675x389.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image buttonBase-GK1x3M"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg" class="icon-noB79L"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image buttonBase-GK1x3M"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2 icon-noB79L"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><p>The clamp on line 2 is the whole thing.</p><p>Fees can only take what&#8217;s there.</p><p>A $600 bill against $250 collects $250, and the other $350 is never written down anywhere.</p><p>Nothing carries it forward. Nothing nets it against what comes next.</p><p>And what comes next is that last line. The full funding payment, landing after the books already closed.</p><p>Now the liquidation check, same protocol.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!1hnd!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8337ed8c-2677-4345-a9a0-8cae069df527_830x382.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!1hnd!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8337ed8c-2677-4345-a9a0-8cae069df527_830x382.png 424w, https://substackcdn.com/image/fetch/$s_!1hnd!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8337ed8c-2677-4345-a9a0-8cae069df527_830x382.png 848w, https://substackcdn.com/image/fetch/$s_!1hnd!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8337ed8c-2677-4345-a9a0-8cae069df527_830x382.png 1272w, https://substackcdn.com/image/fetch/$s_!1hnd!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8337ed8c-2677-4345-a9a0-8cae069df527_830x382.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!1hnd!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8337ed8c-2677-4345-a9a0-8cae069df527_830x382.png" width="830" height="382" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8337ed8c-2677-4345-a9a0-8cae069df527_830x382.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:382,&quot;width&quot;:830,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:67961,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://defendor.substack.com/i/211570896?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8337ed8c-2677-4345-a9a0-8cae069df527_830x382.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!1hnd!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8337ed8c-2677-4345-a9a0-8cae069df527_830x382.png 424w, https://substackcdn.com/image/fetch/$s_!1hnd!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8337ed8c-2677-4345-a9a0-8cae069df527_830x382.png 848w, https://substackcdn.com/image/fetch/$s_!1hnd!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8337ed8c-2677-4345-a9a0-8cae069df527_830x382.png 1272w, https://substackcdn.com/image/fetch/$s_!1hnd!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8337ed8c-2677-4345-a9a0-8cae069df527_830x382.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image buttonBase-GK1x3M"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg" class="icon-noB79L"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image buttonBase-GK1x3M"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2 icon-noB79L"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Look at that middle branch.</p><p>Fees exceed margin, the trader is receiving funding, and the check subtracts the shortfall from funding income and keeps going.</p><p>There&#8217;s even a comment on it.</p><p>Somebody sat down, thought about exactly the case where fees run past collateral while funding is owed to the trader, decided funding should absorb it, and wrote that down.</p><p>Then the settlement path was written as if that conversation never happened.</p><p>Walk the numbers.</p><p>Margin after PnL is $250.</p><p>Fees owed are $600.</p><p>Funding owed to the trader is $450.</p><p>Settlement clamps to $250, takes it, moves on.</p><p>The $350 remainder isn&#8217;t deferred. It isn&#8217;t netted. It&#8217;s gone.</p><p>Then funding credits on its own line. The full $450.</p><p>$450 out, where $100 was correct.</p><p>The gap is whichever is smaller: the funding they&#8217;re owed, or the fees that went uncollected.</p><blockquote><p>A clamp that stops an underflow also forgives the difference.</p></blockquote><p>The clamp itself is correct. Without it the split runs past the balance and the transaction aborts.</p><p>The solvency branch is correct too.</p><p>If someone owes you $450, you&#8217;re not insolvent over a $350 gap.</p><p>And the same ordering repeats across every exit path the protocol has.</p><p>Three call sites agreeing reads like a decision.</p><p>Consistency isn&#8217;t correctness.</p><p>Here is the whole thing as one close:</p><p>No flash loan. No oracle. No reentrancy.</p><p>You close a position at the moment funding is paying you and your fees have already eaten your collateral.</p><p>And it repeats. Every close that meets those two conditions.</p><p>The money comes out of the LP pool.</p><p>Depositors pay the funding, and they eat the fees the protocol never collected.</p><p>When you audit a settlement path, check:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Cn62!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa5a6f98-7d84-4199-a25c-9ac118a242f3_2828x866.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Cn62!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa5a6f98-7d84-4199-a25c-9ac118a242f3_2828x866.png 424w, https://substackcdn.com/image/fetch/$s_!Cn62!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa5a6f98-7d84-4199-a25c-9ac118a242f3_2828x866.png 848w, https://substackcdn.com/image/fetch/$s_!Cn62!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa5a6f98-7d84-4199-a25c-9ac118a242f3_2828x866.png 1272w, https://substackcdn.com/image/fetch/$s_!Cn62!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa5a6f98-7d84-4199-a25c-9ac118a242f3_2828x866.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Cn62!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa5a6f98-7d84-4199-a25c-9ac118a242f3_2828x866.png" width="1456" height="446" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fa5a6f98-7d84-4199-a25c-9ac118a242f3_2828x866.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:446,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:469834,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://defendor.substack.com/i/211570896?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa5a6f98-7d84-4199-a25c-9ac118a242f3_2828x866.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Cn62!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa5a6f98-7d84-4199-a25c-9ac118a242f3_2828x866.png 424w, https://substackcdn.com/image/fetch/$s_!Cn62!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa5a6f98-7d84-4199-a25c-9ac118a242f3_2828x866.png 848w, https://substackcdn.com/image/fetch/$s_!Cn62!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa5a6f98-7d84-4199-a25c-9ac118a242f3_2828x866.png 1272w, https://substackcdn.com/image/fetch/$s_!Cn62!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa5a6f98-7d84-4199-a25c-9ac118a242f3_2828x866.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image buttonBase-GK1x3M"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg" class="icon-noB79L"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image buttonBase-GK1x3M"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2 icon-noB79L"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Most auditors check that each function is correct on its own.</p><blockquote><p>Few check that two functions share the same model of what money is.</p></blockquote><p>This isn&#8217;t a missing check, and that&#8217;s exactly why it survives.</p><p>The usual version of this finding is &#8220;fee not charged&#8221; or &#8220;wrong account authorised&#8221;.</p><p>Something is absent, you grep for it, you find it.</p><p>Here nothing is absent.</p><p>Fees are charged. The cap is deliberate.</p><p>The solvency model is deliberate, correct, and commented.</p><p>The bug lives between two files that were each reviewed on a different day.</p><blockquote><p>Root cause: settlement clamps then credits, solvency sums then compares.</p></blockquote><p>Two fixes.</p><ol><li><p>Do the arithmetic once. Margin, funding, fees, one number at the end, and clamp that number instead of the fee line.</p></li><li><p>Make the liquidation check call that same function, so the two can&#8217;t drift apart again.</p></li></ol><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!a6h3!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80cc86ad-78fe-4727-91e0-c0415153b655_778x456.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!a6h3!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80cc86ad-78fe-4727-91e0-c0415153b655_778x456.png 424w, https://substackcdn.com/image/fetch/$s_!a6h3!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80cc86ad-78fe-4727-91e0-c0415153b655_778x456.png 848w, https://substackcdn.com/image/fetch/$s_!a6h3!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80cc86ad-78fe-4727-91e0-c0415153b655_778x456.png 1272w, https://substackcdn.com/image/fetch/$s_!a6h3!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80cc86ad-78fe-4727-91e0-c0415153b655_778x456.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!a6h3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80cc86ad-78fe-4727-91e0-c0415153b655_778x456.png" width="778" height="456" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/80cc86ad-78fe-4727-91e0-c0415153b655_778x456.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:456,&quot;width&quot;:778,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:83942,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://defendor.substack.com/i/211570896?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80cc86ad-78fe-4727-91e0-c0415153b655_778x456.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!a6h3!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80cc86ad-78fe-4727-91e0-c0415153b655_778x456.png 424w, https://substackcdn.com/image/fetch/$s_!a6h3!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80cc86ad-78fe-4727-91e0-c0415153b655_778x456.png 848w, https://substackcdn.com/image/fetch/$s_!a6h3!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80cc86ad-78fe-4727-91e0-c0415153b655_778x456.png 1272w, https://substackcdn.com/image/fetch/$s_!a6h3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80cc86ad-78fe-4727-91e0-c0415153b655_778x456.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image buttonBase-GK1x3M"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg" class="icon-noB79L"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image buttonBase-GK1x3M"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2 icon-noB79L"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>The second one is what stops it coming back.</p><div><hr></div><p>Arsen</p>]]></content:encoded></item><item><title><![CDATA[Ignore 85% of the code if you want critical bugs]]></title><description><![CDATA[New codebase? The question must be:
How do I find the 5% of code that can kill the protocol?]]></description><link>https://newsletter.arsen.ac/p/ignore-85-of-the-code-if-you-want</link><guid isPermaLink="false">https://newsletter.arsen.ac/p/ignore-85-of-the-code-if-you-want</guid><dc:creator><![CDATA[Arsen]]></dc:creator><pubDate>Sun, 08 Feb 2026 14:50:06 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/e739eb28-8aca-497d-8710-faa72c5bc69d_652x357.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>New codebase?</p><p>Easy to drown in files, lines, and edge cases.</p><p>You try to read everything and end up understanding nothing deeply.</p><p>So the real questions are:</p><ul><li><p>How do I find the most critical flows?</p></li><li><p>How do I focus most of my time there?</p></li></ul><p>Senior auditors ask the same thing in one line:</p><blockquote><p><strong>How do I find the 5% of code that can kill the protocol?</strong></p></blockquote><p>You don&#8217;t always need to audit the whole codebase.<br>Most of the time, you need to spot a few key flows and attack them hard.</p><p>This email shows you how I do that.</p><h3>The real truth</h3><blockquote><p>This is a skill, not a magic.</p></blockquote><p>It comes from practice and from understanding how a system works.</p><p>There&#8217;s no magic tool that tags &#8220;<strong>critical flow</strong>&#8221; for you.</p><p>But you can train a simple model in your head:</p><ol><li><p>Find the core flows.</p></li><li><p>Think like an attacker around those flows only.</p></li></ol><h3>Step 1 &#8212; Build a simple mental map</h3><p>First, answer one question:</p><blockquote><p><strong>&#8220;What are the 2&#8211;3 main things this protocol lets users do?&#8221;</strong></p></blockquote><p>In contests or private audits, that often happens on a short kick-off call.<br>Devs walk you through:</p><ul><li><p>What the system does</p></li><li><p>Who the main actors are</p></li><li><p>How &#8220;normal&#8221; behavior looks like</p></li><li><p>Which invariants must always hold</p></li></ul><p>You won&#8217;t get deep understanding here.<br>But you&#8217;ll understand where value and trust move. That&#8217;s enough for the <strong>Initial Discovery Phase</strong>.</p><p>If there&#8217;s no call, recreate it yourself:</p><ol><li><p>Read the docs</p></li><li><p>Feed them into AI</p></li><li><p>Scan the codebase</p></li><li><p>Ask AI targeted questions and verify answers against code</p></li></ol><p>You&#8217;re not hunting bugs yet.<br>You&#8217;re just mapping the territory.</p><h3>Step 2 &#8212; Abstract the critical flows</h3><p>Once you know what the system does, move to <strong>logic flow abstraction</strong>.</p><p>List out:</p><ul><li><p>Main actors (user, admin, LP, liquidator, relayer, etc.)</p></li><li><p>Where real money or sensitive state moves</p></li><li><p>The few public functions everything depends on</p></li></ul><p>Pick one/two main flows:</p><ul><li><p>Deposit</p></li><li><p>Withdrawal</p></li><li><p>Swap</p></li><li><p>Position update</p></li><li><p>Bridge transfer</p></li></ul><p>Follow that flow end-to-end in code.</p><p>Ask:</p><ul><li><p>Who can call this?</p></li><li><p>What can they control?</p></li><li><p>What state does it touch?</p></li><li><p>What must never happen here?</p></li></ul><h3>Step 3 &#8212; Mark the files that matter</h3><p>At this point, you don&#8217;t need the whole repo.<br>You need the subset that touches your chosen flows.</p><p>Mark those files. Ignore the rest.</p><p>Here&#8217;s the tool I use to mark files and jump between them fast:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ToEh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2aacb5bd-1833-4c0e-9304-a3422c3ee807_1550x642.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ToEh!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2aacb5bd-1833-4c0e-9304-a3422c3ee807_1550x642.png 424w, https://substackcdn.com/image/fetch/$s_!ToEh!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2aacb5bd-1833-4c0e-9304-a3422c3ee807_1550x642.png 848w, https://substackcdn.com/image/fetch/$s_!ToEh!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2aacb5bd-1833-4c0e-9304-a3422c3ee807_1550x642.png 1272w, https://substackcdn.com/image/fetch/$s_!ToEh!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2aacb5bd-1833-4c0e-9304-a3422c3ee807_1550x642.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ToEh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2aacb5bd-1833-4c0e-9304-a3422c3ee807_1550x642.png" width="1456" height="603" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2aacb5bd-1833-4c0e-9304-a3422c3ee807_1550x642.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:603,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!ToEh!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2aacb5bd-1833-4c0e-9304-a3422c3ee807_1550x642.png 424w, https://substackcdn.com/image/fetch/$s_!ToEh!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2aacb5bd-1833-4c0e-9304-a3422c3ee807_1550x642.png 848w, https://substackcdn.com/image/fetch/$s_!ToEh!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2aacb5bd-1833-4c0e-9304-a3422c3ee807_1550x642.png 1272w, https://substackcdn.com/image/fetch/$s_!ToEh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2aacb5bd-1833-4c0e-9304-a3422c3ee807_1550x642.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image buttonBase-GK1x3M"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg" class="icon-noB79L"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image buttonBase-GK1x3M"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2 icon-noB79L"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>When I return the next day, I jump straight back into the same &#8220;slice&#8221; of the system.</p><h3>Step 4 &#8212; Set up a thinking workspace</h3><p>Your IDE is for code.<br>You still need a place for thinking.</p><p>Somewhere to:</p><ul><li><p>Draw flows</p></li><li><p>Write invariants</p></li><li><p>List attack ideas</p></li><li><p>Capture &#8220;I don&#8217;t understand this yet&#8221; questions</p></li></ul><p>I use:</p><p><strong>Miro</strong> &#8212; for drawings and state diagrams:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!F_xA!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93400437-e97d-46be-af44-a1ecd9aeffd0_1700x1414.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!F_xA!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93400437-e97d-46be-af44-a1ecd9aeffd0_1700x1414.png 424w, https://substackcdn.com/image/fetch/$s_!F_xA!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93400437-e97d-46be-af44-a1ecd9aeffd0_1700x1414.png 848w, https://substackcdn.com/image/fetch/$s_!F_xA!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93400437-e97d-46be-af44-a1ecd9aeffd0_1700x1414.png 1272w, https://substackcdn.com/image/fetch/$s_!F_xA!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93400437-e97d-46be-af44-a1ecd9aeffd0_1700x1414.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!F_xA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93400437-e97d-46be-af44-a1ecd9aeffd0_1700x1414.png" width="1456" height="1211" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/93400437-e97d-46be-af44-a1ecd9aeffd0_1700x1414.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1211,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!F_xA!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93400437-e97d-46be-af44-a1ecd9aeffd0_1700x1414.png 424w, https://substackcdn.com/image/fetch/$s_!F_xA!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93400437-e97d-46be-af44-a1ecd9aeffd0_1700x1414.png 848w, https://substackcdn.com/image/fetch/$s_!F_xA!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93400437-e97d-46be-af44-a1ecd9aeffd0_1700x1414.png 1272w, https://substackcdn.com/image/fetch/$s_!F_xA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93400437-e97d-46be-af44-a1ecd9aeffd0_1700x1414.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image buttonBase-GK1x3M"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg" class="icon-noB79L"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image buttonBase-GK1x3M"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2 icon-noB79L"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>Notion</strong> &#8212; for text notes:</p><ul><li><p>What each actor can do</p></li><li><p>What must always hold true</p></li><li><p>Where value enters and leaves</p></li><li><p>Which assumptions I haven&#8217;t tested yet</p></li></ul><p>I revisit these notes often.<br>Bugs usually hide where my notes are vague.</p><p>Here&#8217;s my own notes structure:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!JxQw!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85dc9a03-eb79-4410-8481-712a913a7607_1600x754.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!JxQw!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85dc9a03-eb79-4410-8481-712a913a7607_1600x754.png 424w, https://substackcdn.com/image/fetch/$s_!JxQw!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85dc9a03-eb79-4410-8481-712a913a7607_1600x754.png 848w, https://substackcdn.com/image/fetch/$s_!JxQw!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85dc9a03-eb79-4410-8481-712a913a7607_1600x754.png 1272w, https://substackcdn.com/image/fetch/$s_!JxQw!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85dc9a03-eb79-4410-8481-712a913a7607_1600x754.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!JxQw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85dc9a03-eb79-4410-8481-712a913a7607_1600x754.png" width="1456" height="686" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/85dc9a03-eb79-4410-8481-712a913a7607_1600x754.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:686,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!JxQw!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85dc9a03-eb79-4410-8481-712a913a7607_1600x754.png 424w, https://substackcdn.com/image/fetch/$s_!JxQw!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85dc9a03-eb79-4410-8481-712a913a7607_1600x754.png 848w, https://substackcdn.com/image/fetch/$s_!JxQw!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85dc9a03-eb79-4410-8481-712a913a7607_1600x754.png 1272w, https://substackcdn.com/image/fetch/$s_!JxQw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85dc9a03-eb79-4410-8481-712a913a7607_1600x754.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image buttonBase-GK1x3M"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg" class="icon-noB79L"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image buttonBase-GK1x3M"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2 icon-noB79L"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Better and clear notes = better bugs.</p><h3>Case study &#8212; Raydium CLMM</h3><p>Here&#8217;s how all this plays out in a real protocol.</p><p><strong><a href="https://immunefi.com/blog/bug-fix-reviews/raydium-tick-manipulation-bugfix-review/">Raydium&#8217;s CLMM</a></strong> uses a default tick range for its pools.<br>Storing all ticks is too expensive, so it limits the active range.</p><p>If you want to deposit outside that range, you pass an <strong>extension account</strong> with extra ticks.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!x5tu!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc17e5ea7-f3a5-43aa-9c14-6a18a5d6d4d5_1524x742.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!x5tu!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc17e5ea7-f3a5-43aa-9c14-6a18a5d6d4d5_1524x742.png 424w, https://substackcdn.com/image/fetch/$s_!x5tu!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc17e5ea7-f3a5-43aa-9c14-6a18a5d6d4d5_1524x742.png 848w, https://substackcdn.com/image/fetch/$s_!x5tu!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc17e5ea7-f3a5-43aa-9c14-6a18a5d6d4d5_1524x742.png 1272w, https://substackcdn.com/image/fetch/$s_!x5tu!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc17e5ea7-f3a5-43aa-9c14-6a18a5d6d4d5_1524x742.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!x5tu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc17e5ea7-f3a5-43aa-9c14-6a18a5d6d4d5_1524x742.png" width="1456" height="709" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c17e5ea7-f3a5-43aa-9c14-6a18a5d6d4d5_1524x742.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:709,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!x5tu!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc17e5ea7-f3a5-43aa-9c14-6a18a5d6d4d5_1524x742.png 424w, https://substackcdn.com/image/fetch/$s_!x5tu!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc17e5ea7-f3a5-43aa-9c14-6a18a5d6d4d5_1524x742.png 848w, https://substackcdn.com/image/fetch/$s_!x5tu!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc17e5ea7-f3a5-43aa-9c14-6a18a5d6d4d5_1524x742.png 1272w, https://substackcdn.com/image/fetch/$s_!x5tu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc17e5ea7-f3a5-43aa-9c14-6a18a5d6d4d5_1524x742.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image buttonBase-GK1x3M"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg" class="icon-noB79L"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image buttonBase-GK1x3M"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2 icon-noB79L"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>That idea is fine.<br>The problem was validation.</p><p>The program didn&#8217;t verify that the &#8220;extra ticks&#8221; account belonged to the correct pool.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!gxSO!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4faecb19-9f3c-4948-95b8-c3b8f26e8aea_1069x348.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!gxSO!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4faecb19-9f3c-4948-95b8-c3b8f26e8aea_1069x348.png 424w, https://substackcdn.com/image/fetch/$s_!gxSO!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4faecb19-9f3c-4948-95b8-c3b8f26e8aea_1069x348.png 848w, https://substackcdn.com/image/fetch/$s_!gxSO!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4faecb19-9f3c-4948-95b8-c3b8f26e8aea_1069x348.png 1272w, https://substackcdn.com/image/fetch/$s_!gxSO!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4faecb19-9f3c-4948-95b8-c3b8f26e8aea_1069x348.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!gxSO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4faecb19-9f3c-4948-95b8-c3b8f26e8aea_1069x348.png" width="1069" height="348" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4faecb19-9f3c-4948-95b8-c3b8f26e8aea_1069x348.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:348,&quot;width&quot;:1069,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!gxSO!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4faecb19-9f3c-4948-95b8-c3b8f26e8aea_1069x348.png 424w, https://substackcdn.com/image/fetch/$s_!gxSO!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4faecb19-9f3c-4948-95b8-c3b8f26e8aea_1069x348.png 848w, https://substackcdn.com/image/fetch/$s_!gxSO!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4faecb19-9f3c-4948-95b8-c3b8f26e8aea_1069x348.png 1272w, https://substackcdn.com/image/fetch/$s_!gxSO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4faecb19-9f3c-4948-95b8-c3b8f26e8aea_1069x348.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image buttonBase-GK1x3M"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg" class="icon-noB79L"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image buttonBase-GK1x3M"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2 icon-noB79L"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>That one oversight let an attacker:</p><ol><li><p>Create their own pool</p></li><li><p>Forge an &#8220;extra ticks&#8221; account for it</p></li><li><p>Pass it to a victim pool</p></li></ol><blockquote><p><strong>By doing that, they could flip tick state in the victim pool.</strong><br><strong>And that state persisted.</strong></p></blockquote><p>Later swaps used the tampered tick, so liquidity accounting broke.</p><p>With a specific sequence of swaps + tick flips, the attacker inflated liquidity and withdrew more tokens than they should have.</p><p>Attacker didn&#8217;t brute-force the whole repo.</p><p>Attacker picked one flow &#8212; <strong>ticks handling</strong></p><h3>The real lesson</h3><p>Complex bugs rarely show up when you first look.</p><p>You might follow one flow for weeks.<br>And sometimes you find nothing.</p><p>But this process scales:</p><ul><li><p>Build a simple map</p></li><li><p>Abstract a few critical flows</p></li><li><p>Mark the contracts that matter</p></li><li><p>Go deep there and ignore everything else</p></li></ul><p>That&#8217;s how you move from:</p><p>&#8220;I&#8217;m lost in this repo.&#8221;</p><p>to:</p><p>&#8220;I know exactly which flows can kill this thing.&#8221;</p>]]></content:encoded></item></channel></rss>