<?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:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Bozhidar Bonev on Medium]]></title>
        <description><![CDATA[Stories by Bozhidar Bonev on Medium]]></description>
        <link>https://medium.com/@bozhidarbonev?source=rss-38a0052b4bdb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ItHCj2sVMEScPljSCEmsjQ.jpeg</url>
            <title>Stories by Bozhidar Bonev on Medium</title>
            <link>https://medium.com/@bozhidarbonev?source=rss-38a0052b4bdb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 12:43:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bozhidarbonev/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[SOAS VI — The money-changers who can neither be expelled from temple nor rewarded: Part II]]></title>
            <link>https://coinsbench.com/soas-vi-the-money-changers-who-can-neither-be-expelled-from-temple-nor-rewarded-part-ii-552fa7b761f8?source=rss-38a0052b4bdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/552fa7b761f8</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[web3-security]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Bozhidar Bonev]]></dc:creator>
            <pubDate>Sun, 22 Nov 2026 19:56:01 GMT</pubDate>
            <atom:updated>2026-11-22T19:56:01.467Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>SOAS VI — The money-changers who can neither be expelled from temple nor rewarded: Part II</strong></h3><blockquote>Part of the series — “Snail On A Slope”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AYnsiu8TGEBekXBhrZhknQ.png" /></figure><h3>Introduction</h3><p>In the previous part we walked into the temple and found out that the money-changers can’t be expelled. Cross chain borrows could be opened but not repaid because the two routers disagreed on what the borrower’s debt is and one of them asked the wrong question. This time nobody is locked anywhere but there is still something off, the offerings go to the wrong table.</p><h4>Liquidity Mining</h4><p>Many protocols pay their users in their own internal token for both supplying and borrowing in order to stimulate whenever each of them is needed. In our case this happens with the TITHE token, which is distributed to borrowers as rewards to incentivize the borrowing side. The mechanism we have is the following:</p><ul><li>The market has an emission speed, x tokens per second</li><li>A reward index, which is global, increases over time using the formula <strong><em>speed * time elapsed / total debt</em></strong>, so in simple words it means “tokens per unit debt”</li><li>Users have checkpoints of their last settlement</li><li>When settling a user, they receive <strong><em>their debt * (index now — last checkpoint)</em></strong>, and the checkpoint moves forward</li></ul><p>Two important points to keep in mind are that the emission is split pro rata over the debt of the market and that the amount of the reward depends on the user’s debt.</p><h3>Understanding the Protocol</h3><p><strong>Our dummy protocol consists of five contracts:</strong></p><ul><li><em>LedgerStorage</em></li><li><em>MarketPool</em></li><li><em>HomeRouter</em></li><li><em>BridgeRouter</em></li><li><em>MockEndpoint</em></li></ul><p>I am not going to paste or explain them in detail, you can quickly refresh your memory by looking at the first part of the article. We are just going to explore the parts regarding the rewards generation and distribution here.</p><p>The <em>MarketPool </em>is the keeper of the reward index and emission speed, as well as the calculations for the pro rata split. Basically, when the index updates, the emission is divided by the total principle borrowed for the particular market.</p><pre>    function updateBorrowRewardIndex() public {<br>        uint256 dt = block.timestamp - rewardTimestamp;<br>        if (dt == 0) return;<br>        rewardTimestamp = block.timestamp;<br>        if (totalPrincipal == 0 || borrowRewardSpeed == 0) return;<br>        borrowRewardIndex += (dt * borrowRewardSpeed * 1e36) / totalPrincipal;<br>    }</pre><p>The <em>LedgerStorage </em>keeps the user’s accrued rewards and checkpoint and is used to read the user’s debt. It is also the place where the records for the cross chain borrows live:</p><ul><li><em>ouboundLoans</em> — the loan viewed from the collateral side</li><li><em>foreignbackedLoans</em> — the loan viewed from the funds side</li></ul><p>The reward logic reads the user’s debt by calling <em>_rewardBearingDebt()</em>, which sums two numbers:</p><ul><li>The user’s same chain debt</li><li>The user’s cross chain debt that started on this (current) chain</li></ul><p>The second one seems a perfectly reasonable thing to check as it answers the question on how much debt the collateral here has to cover. This is an important thing to keep in mind as we go on, we will need it later.</p><pre>    function settleBorrowerTithe(<br>        address market,<br>        address borrower<br>    ) external onlyAuthorized {<br>        MarketPool m = MarketPool(market);<br>        m.updateBorrowRewardIndex();<br>        uint256 marketIndex = m.borrowRewardIndex();<br><br>        uint256 userIndex = titheBorrowerIndex[market][borrower];<br>        titheBorrowerIndex[market][borrower] = marketIndex;<br>        if (userIndex == 0) userIndex = TITHE_INITIAL_INDEX;<br><br>        uint256 deltaIndex = marketIndex - userIndex;<br>        uint256 borrowerAmount = (_rewardBearingDebt(borrower, market) * 1e18) /<br>            m.borrowIndex();<br><br>        titheAccrued[borrower] += (borrowerAmount * deltaIndex) / 1e36;<br>    }<br><br>    function debtStartedHere(address borrower, address market) public view returns (uint256 debt) {<br>        address token = underlyingOf[market];<br>        uint256 index = MarketPool(market).borrowIndex();<br><br>        Loan[] memory outbound = outboundLoans[borrower][token];<br>        for (uint256 i = 0; i &lt; outbound.length; i++) {<br>            if (outbound[i].srcEid == currentEid) {<br>                debt += (outbound[i].principal * index) / outbound[i].borrowIndex;<br>            }<br>        }<br>    }<br><br>    function _rewardBearingDebt(address borrower, address market) internal view virtual returns (uint256) {<br>        return debtStartedHere(borrower, market) + sameChainDebt(borrower, market);<br>    }</pre><p><em>HomeRouter </em>pays the accrued rewards through <em>claimTithe()</em> but only if there are enough tokens, otherwise it keeps an IOU on the books.</p><pre>    function claimTithe(address[] calldata holders, address market) external {<br>        for (uint256 i = 0; i &lt; holders.length; i++) {<br>            ledger.settleBorrowerTithe(market, holders[i]);<br><br>            uint256 accrued = ledger.titheAccrued(holders[i]);<br>            // pay only if the router actually holds enough TITHE, otherwise leave it accrued<br>            if (accrued &gt; 0 &amp;&amp; accrued &lt;= tithe.balanceOf(address(this))) {<br>                tithe.transfer(holders[i], accrued);<br>                ledger.setTitheAccrued(holders[i], 0);<br>            }<br>        }<br>    }</pre><p>The other contracts are not interesting for this article so we are going to just skip them.</p><h4>How And Why Is The Reward Settled On Both Chains?</h4><p>A cross chain loan is recorded on both chains, so they both need to freshen up the rewards for the users before changing any records, no matter if it is for issuing a new loan or repaying an existing one. Each chain has its own <em>MarketPool</em>, reward index, accrued rewards record and TITHE balance. When settling on chain A, the user is credited with the rewards based on chain A’s emission and nothing more. The same happens on chain B. A normal settlement looks like this:</p><p><strong>-&gt; BridgeRouter/HomeRouter</strong><em><br> </em>|<em><br> </em>|<em> settleBorrowerTithe()<br> </em>|<br><strong> -&gt;</strong> <strong>LedgerStorage</strong><br> |<em><br> </em>|<em> updateBorrowRewardIndex()<br> </em>|<br> <strong>-&gt;</strong> <strong>MarketPool</strong><em><br> |<br> </em>|<em> _rewardBearingDebt()<br> </em>|<br> <strong>-&gt;</strong> <strong>LedgerStorage</strong><br> <em>|<br> | titheAccrued[borrower]+=</em> <em>their</em> <em>debt * (index now — last checkpoint)<br> </em>|<em><br></em><strong><em> </em>-&gt;</strong> <strong>Returns</strong></p><p><strong>Example:</strong></p><ul><li>Market emits 1 TITHE token per second, which makes 86 400 per day</li><li>If Alice is the only one with debt for that day on that chain, she gets the whole 86 400</li><li>If Alice and Bob each have $5000 debt on that chain, each gets 43 200, as what is paid out can never be more than what is emitted and the split is over the total debt, which is the denominator of the index (you can see it in <em>MarketPool.updateBorrowRewardIndex()</em>)</li></ul><h3>Anatomy Of The Second Attack — Money-changers can’t be rewarded</h3><p>Spoiler alert! We don’t have an attack, just a bug, but do not underestimate it.</p><p>Looking at the calculation of a user’s rewards, as we already said, the denominator of the reward index is the total debt that was lent out of this chain’s market, so the numerator for the reward calculation, logically, has to be the user’s debt that came out of this market from this chain, no matter where the collateral lives. Let’s explore <em>_rewardBearingDebt()</em> function more closely:</p><pre>    function _rewardBearingDebt(address borrower, address market) internal view virtual returns (uint256) {<br>        return debtStartedHere(borrower, market) + sameChainDebt(borrower, market);<br>    }<br><br>    function sameChainDebt(<br>        address borrower,<br>        address market<br>    ) public view returns (uint256) {<br>        BorrowMarketState memory s = borrowBalance[borrower][market];<br>        if (s.borrowIndex == 0) return 0;<br>        return (s.amount * MarketPool(market).borrowIndex()) / s.borrowIndex;<br>    }<br><br>    function debtStartedHere(address borrower, address market) public view returns (uint256 debt) {<br>        address token = underlyingOf[market];<br>        uint256 index = MarketPool(market).borrowIndex();<br><br>        Loan[] memory outbound = outboundLoans[borrower][token];<br>        for (uint256 i = 0; i &lt; outbound.length; i++) {<br>            if (outbound[i].srcEid == currentEid) {<br>                debt += (outbound[i].principal * index) / outbound[i].borrowIndex;<br>            }<br>        }<br>    }</pre><p>Notice how it answers the wrong question? It calculates the debt that originates from this chain instead of the debt that originated from the other chain but was executed here. It does the wrong calculation on both chains in opposite ways. Let’s see two scenarios:</p><h4>The Borrower That Is Paid Nothing (Chain B debt)</h4><p><strong>Single Borrower:</strong></p><ul><li>Alice borrows cross chain $5000 on chain B with collateral on chain A</li><li>One day passes and 86 400 TITHE tokens are emitted over her $5000 as she is the only borrower</li><li><em>claimTithe()</em> is called for Alice on chain B where her debt is</li><li><em>LedgerStorage </em>calls <em>_rewardBearingDebt()</em> to calculate her debt but she has no same chain debt (on B) and has not initiated any debt (starting from B). She only has something recorded in <em>foreignbackedLoans </em>and nothing in <em>outboundLoans </em>so the function returns 0</li><li>Alice receives 0 TITHE</li></ul><p><strong>Multi Borrower:</strong></p><ul><li>Bob borrows $5000 on chain B with collateral on chain B, same chain borrow</li><li>Alice borrows again $5000 cross chain on B with collateral on chain A</li><li>One day passes and 86 400 TITHE tokens are emitted over $10 000</li><li>When claiming their rewards, Bob receives half of the share: 43 200 tokens as he has same chain debt, while Alice is again left with 0 and her half of the share is left stranded</li></ul><p>Now let’s see the opposing side.</p><h4>The Borrower That Is Paid For A Loan That Is Not There (Chain A debt)</h4><ul><li>Alice has supplied $10 000 collateral on chain A and borrows $5000 on chain A, same chain borrow</li><li>Bob has supplied $10 000 collateral on chain A and borrows $5000 on chain B, cross chain borrow</li><li>One day passes and 86 400 TITHE tokens are emitted (on chain A) over Alice’s $5000</li><li>Bob calls <em>claimTithe()</em> first and <em>_rewardBearingDebt()</em> reads <em>outboundLoans</em>, which returns a $5000 record with <em>srcEid == A</em>, so it counts it as debt in this market</li><li>Bob receives the 86 400 tokens</li><li>Alice then also calls <em>claimTithe()</em> and it says 86 400 as she also has $5000 record for same chain debt but there are no tokens to be transferred as Bob took them. Alice is left with an IOU that can’t be paid</li></ul><h3>Conclusion</h3><p>Who pays for these offerings in this buggy situation? Well, depends on the case, in the first case (Chain B debt), the borrower pays by losing the rewards that were promised by the protocol, in the second case (Chain A debt), the TITHE treasury and part of the borrowers pay, because the protocol has over promised rewards and the borrowers are effectively placed in a first come, first served queue. The lesson here for me is that there are multiple answers to be checked when asking “Whose debt is it and where is it exactly”, especially when working with cross chain operations. There’s always something fishy when working with rewards so I like to spend a good amount of time reasoning about what they try to achieve. Hope this was helpful to you too, ser.</p><p><strong><em>Full dummy protocol code &amp; tests can be found at:</em></strong></p><p><a href="https://github.com/BozhidarBonev/MediumArticlesCodeExamples/tree/master/SnailOnASlope/moneyChangers?source=post_page-----a23c8d3cc125-----------------------------------------">MediumArticlesCodeExamples/SnailOnASlope/moneyChangers at master · BozhidarBonev/MediumArticlesCodeExamples</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=552fa7b761f8" width="1" height="1" alt=""><hr><p><a href="https://coinsbench.com/soas-vi-the-money-changers-who-can-neither-be-expelled-from-temple-nor-rewarded-part-ii-552fa7b761f8">SOAS VI — The money-changers who can neither be expelled from temple nor rewarded: Part II</a> was originally published in <a href="https://coinsbench.com/">CoinsBench</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SOAS V1 — The money-changers who can neither be expelled from temple nor rewarded: Part 1]]></title>
            <link>https://coinsbench.com/soas-v1-the-money-changers-who-can-neither-be-expelled-from-temple-nor-rewarded-part-1-a23c8d3cc125?source=rss-38a0052b4bdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/a23c8d3cc125</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[web3-security]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Bozhidar Bonev]]></dc:creator>
            <pubDate>Fri, 06 Nov 2026 20:01:01 GMT</pubDate>
            <atom:updated>2026-11-06T20:01:01.851Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>SOAS VI — The money-changers who can neither be expelled from temple nor rewarded: Part I</strong></h3><blockquote>Part of the series — “Snail On A Slope”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AYnsiu8TGEBekXBhrZhknQ.png" /></figure><h3>Introduction</h3><p>Jesus famously expelled the money-changers, borrowers, lenders and all kinds of merchants from the temple, but what if he couldn’t? Logically, if you can’t beat them — join them, but what if rewarding them turned out to be impossible too?</p><p>A classic lending protocol allows suppliers to invest tokens into a pool and borrowers to take tokens out of that pool against a collateral that they have previously supplied, meanwhile keeping and calculating a borrow index to keep the mechanism balanced. Liquidations happen when the borrowed amount of a user exceeds the limit, set to the borrowing power of his collateral (say 75%).</p><p>All this lending, borrowing and liquidating happens with a simple restriction, it is on one chain only. What we are going to look at today is a cross chain lending (dummy) protocol that lets users supply collateral on chain A, which will be the guarantee, and take debt on chain B, which will be sent to the user on B. All this usually happens via LayerZero, which we have simplified to keep the focus on the bug, we are about to explore.</p><h3>Understanding the Protocol</h3><p>Our dummy protocol consists of five contracts and four of them are deployed once <strong>per chain</strong>:</p><ul><li><em>MarketPool</em></li><li><em>LedgerStorage</em></li><li><em>HomeRouter</em></li><li><em>BridgeRouter</em></li><li><em>MockEndpoint</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KVDK3PAc0T3AeP2fK5KDow.png" /></figure><p>For simplicity there is only one asset that the protocol works with — USDC (in e18 on both chains) and it is priced at $1 so no oracle is needed. Redeem and liquidate functions are not implemented for the dummy protocol as they are not relevant for the problem we are going to discuss. Lastly, the <em>MockEndpoint </em>is a very simplified LayerZero substitute so that we can simulate cross chain messaging.</p><p>The <em>MarketPool </em>is the pool of a chain, which holds its liquidity and tracks the total borrow (principal). This principal is updated with a borrow index, which grows with time.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e5c9f49fb2d0be6a93d0da86a086d043/href">https://medium.com/media/e5c9f49fb2d0be6a93d0da86a086d043/href</a></iframe><p>The <em>LedgerStorage </em>keeps track of users’ collateral, single and cross chain debt. Worth noting here is that cross chain debt leaves two records in two mappings. A funds request from chain A saves the requested funds amount in <em>outboundLoans </em>and when these funds are paid to the user on chain B, a debt record is saved for the amount in <em>foreignBackedLoans </em>on chain B. Both these mappings live inside <em>LedgerStorage</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2hcODmXMOfgLwK4TBeWPaA.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8d4c32fc63398b09bfd5a3f73639adf3/href">https://medium.com/media/8d4c32fc63398b09bfd5a3f73639adf3/href</a></iframe><p>The <em>HomeRouter </em>is the contract for same chain operations like supply, borrow and repay and is responsible for the moving of the funds for cross chain borrows.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5dda06204ea7ea0de48c56d2949dde03/href">https://medium.com/media/5dda06204ea7ea0de48c56d2949dde03/href</a></iframe><p>Finally, the <em>BridgeRouter </em>is the entry point for initiating cross chain borrows and repays as well as the cross chain messaging.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9ebd73606e771a090c5397edaad92cd3/href">https://medium.com/media/9ebd73606e771a090c5397edaad92cd3/href</a></iframe><p><strong>Looking at the code can be a bit confusing at first but when we follow the chain of execution it becomes clear:</strong></p><p><strong><em>Alice (chain A)</em></strong><em><br> |<br> </em>|<em> supply() — 10 000 USDC collateral giving 7500 borrowing power (75%)<br> </em>|<br> -&gt; HomeRouter (chain A)</p><p><strong><em>Alice (chain A)</em></strong><em><br> |<br> </em>|<em> startRemoteBorrow() — 5000 USDC on B<br> </em>|<br> -&gt; <strong>BridgeRouter (chain A)</strong><em><br> </em>|<em><br> </em>|<em> OpenRemoteBorrow message via send()<br> </em>|<br> -&gt; <strong>MockEndpoint</strong><br> |<br> | <em>_onOpenRemoteBorrow()<br> </em>|<br> -&gt; <strong>BridgeRouter (chain B)</strong><em><br> </em>|<em><br> </em>|<em> payOutRemoteBorrow()<br> </em>|<br> -&gt; <strong>HomeRouter (chain B)</strong><br> |<em><br> </em>|<em> release() — 5000 USDC on B is tranferred to Alice (wallet on B)<br> </em>|<br> -&gt; <strong>MarketPool (chain B)</strong><em><br> |<br> </em>|<em> returns to HomeRouter, which returns to _ onOpenRemoteBorrow()<br> </em>|<br> -&gt; <strong>BridgeRouter (chain B)</strong><br> <em>|<br> </em>|<em> Saves amount: 5000 to foreignBackedLoans mapping and<br> </em>| <em>BorrowConfirmed message via send()<br> |<br> </em>-&gt; <strong>MockEndpoint<br> </strong>|<br> | <em>_onBorrowConfirmed()<br> </em>|<br> -&gt; <strong>BridgeRouter (chain A)</strong><br> |<br> | <em>save amount: 5000 to outboundLoans mapping<br> </em>|<br> -&gt; <strong>End</strong></p><p>Alice has 10 000 tokens as collateral on chain A, 5000 tokens as debt on chain B. Chain B has <em>foreignBackedLoans </em>record of the 5000 and Chain A has <em>outboundLoans </em>record of the 5000. Now let’s follow the repayment, which has to happen in reverse:</p><p><strong><em>Alice (chain B)</em></strong><em><br> |<br> </em>|<em> repayRemoteBorrow() — 5000<br> </em>|<br> -&gt; <strong>BridgeRouter (chain B)</strong><em><br> </em>|<em><br> </em>|<em> takeRemoteRepayment() — 5000 tokens are taken from Alice<br> </em>|<br> -&gt; <strong>HomeRouter (chain B)<br> </strong>|<br> | <em>returns to repayRemoteBorrow()<br> </em>|<br> -&gt; <strong>BridgeRouter (chain B)</strong><em><br> </em>|<em><br> </em>|<em> Reduces/removes amount: 5000 from foreignBackedLoans mapping and<br> </em>| <em>RepayNotice message via send()<br> </em>|<br> -&gt; <strong>MockEndpoint<br> </strong>|<em><br> </em>|<em> _onRepayNotice()<br> </em>|<br> -&gt; <strong>BridgeRouter (chain A)</strong><em><br> |<br> </em>|<em> Reduces/removes amount: 5000 from outboundLoans mapping<br> </em>|<br> -&gt; <strong>End</strong></p><p><strong>Now, after a more clear understanding of the dummy protocol I can list a few things that are simplified and may cause confusion in the code:</strong></p><ul><li>Every contract on chain A has a twin brother on chain B, the code knows which one it is by comparing with <em>currentEid</em></li><li>Two records are kept — <em>outboundLoans </em>&amp; <em>foreignBackedLoans</em> — so that a user only has a record in one of those on one chain, that way the contract knows on which side of the loan this chain stands</li><li><em>srcEid </em>and <em>destEid </em>are fixed per loan and show the collateral side and funds side. When collateral is on chain A — <em>src</em>Eid is chain A — therefore funds are taken on chain B — <em>destEid</em>, logically, is chain B</li><li><em>crossChainDebt() </em>function doesn’t allow a user to have both mappings populated, a simplification on our part, so no user can have cross chain loans on both chains (in both directions)</li><li>The borrow index is transferred with the loan data but each chain calculates the debt with its own index. This works in the dummy protocol because both markets on both chains have the same rate and start time.</li></ul><h3>Anatomy Of The First Attack — Money-changers can’t be expelled</h3><p>Sorry to disappoint, but there is no actual attack here, it is more of an implementation bug. When there is a cross chain borrow, as it is shown in the example above, the repayment has to be processed on the chain, which gave the funds — chain B in our example. The repayment process looks up the debts of the user, as <em>HomeRouter</em> calls the internal <strong><em>_debtToRepay()</em>:</strong></p><pre>    function _debtToRepay(<br>        address borrower,<br>        address market,<br>        bool isSameChain<br>    ) internal view virtual returns (uint256) {<br>        return<br>            isSameChain<br>                ? ledger.sameChainDebt(borrower, market)<br>                : ledger.crossChainDebt(borrower, market);<br>    }</pre><p>The <em>HomeRouter</em> has no way to know what kind of debt the user is repaying so it asks the right question to the storage based on the <em>isSameChain</em> boolean.</p><p>For a cross chain borrow, as it is for Alice’s case, the call lands on the <strong><em>crossChainDebt() </em></strong>in the ledger, which calculates the debt from the point of view of chain B:</p><pre>function crossChainDebt(<br>        address borrower,<br>        address market<br>    ) public view virtual returns (uint256) {<br>        ...<br>        if (outbound.length &gt; 0) {<br>            for (uint256 i = 0; i &lt; outbound.length; i++) {<br>                if (outbound[i].srcEid == currentEid) {<br>                    borrowedAmount +=<br>                        (outbound[i].principal * index) /<br>                        outbound[i].borrowIndex;<br>                }<br>            }<br>        } else {<br>            for (uint256 i = 0; i &lt; foreign.length; i++) {<br>                // count the record only when both the collateral chain and the funds chain are this one<br>                if (<br>                    foreign[i].destEid == currentEid &amp;&amp;<br>                    foreign[i].srcEid == currentEid<br>                ) {<br>                    borrowedAmount +=<br>                        (foreign[i].principal * index) /<br>                        foreign[i].borrowIndex;<br>                }<br>            }<br>        }<br>        return borrowedAmount;<br>    }</pre><p>The first branch, <strong><em>if(outbound.length &gt; 0)</em></strong>, works as expected, it calculates the debt that originated from collateral on the current chain, so <em>srcEid</em> has to be the <em>currentEid</em>. But the second branch, <strong><em>else</em></strong>, which runs when Alice wants to repay debt cross chain debt on chain B backed by collateral on chain A, fails. The branch loops the <em>foreignBackedLoans</em> mapping records and searches for one that has a <em>srcEid</em> and <em>destEid</em> equal to the <em>currentEid</em>, but a cross chain loan by definition has as source one chain and as destination another. Alice repays currently on chain B so <em>destEid</em> matches the <em>currentEid</em> but <em>srcEid</em> is chain A. In this way the loop runs and rejects all the cross chain borrows, returning 0 as the <em>borrowedAmount</em>, which later reverts in <em>HomeRouter</em> as the code says that there is no borrowed money to repay.</p><p><strong>The sequence of the bug:</strong></p><ul><li>LPs have supplied liquidity on both chains A and B</li><li>Alice supplies $10 000 on chain A</li><li>Alice calls BridgeRouter.startRemoteBorrow() on chain A for $5000 and receives $5000 on chain B</li><li>30 days pass with interest sitting at 5% a year so her debt becomes ~$5020</li><li>Alice calls BridgeRouter.repayRemoteBorrow() on chain B for the full $5020 amount</li><li>The call reverts with “Borrowed amount is 0”</li></ul><p>There is no possible path for success here as repaying the exact amount, repaying with <em>type(uint256).max</em>, repaying in portions or somebody else repaying on her behalf, all revert. The problem is not the whole function, for debt originating from the current chain <em>crossChainDebt()</em> answers perfectly the question “how much debt did this person initiate from this chain”. The bug is that the same function was reused to answer a different question — “how much was taken out of the pool” — and that question is about the <em>foreignBackedLoans</em> mapping, so it doesn’t really care where the collateral is, therefore no need for <em>srcEid</em> check.</p><p>The real cost here is that when the cross chain debt can’t be repaid, it will surely get liquidated, in a real protocol, somewhere along the way and the person who has taken the debt will suffer losses on his collateral that he did not deserve.</p><h3>Conclusion of Part I</h3><p>Not every protocol exposes a cool way to be exploited and it is not needed. Big problems lurk in small mistakes, the devil is in the details, as they say. Many times protocols specify invariants that should always hold but developers, and people in general, think in ways that usually have hidden assumptions that they themselves do not realize. Exactly identifying these unconscious mistakes is as rewarding and cool as writing a big exploit contract and attacking. In this part we saw how the money-changers can’t be expelled and in the next we are going to see why they can’t be rewarded either. Stay tuned!</p><p><strong><em>Full dummy protocol code &amp; tests can be found at:</em></strong></p><p><a href="https://github.com/BozhidarBonev/MediumArticlesCodeExamples/tree/master/SnailOnASlope/moneyChangers">MediumArticlesCodeExamples/SnailOnASlope/moneyChangers at master · BozhidarBonev/MediumArticlesCodeExamples</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a23c8d3cc125" width="1" height="1" alt=""><hr><p><a href="https://coinsbench.com/soas-v1-the-money-changers-who-can-neither-be-expelled-from-temple-nor-rewarded-part-1-a23c8d3cc125">SOAS V1 — The money-changers who can neither be expelled from temple nor rewarded: Part 1</a> was originally published in <a href="https://coinsbench.com/">CoinsBench</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SOAS V — 100 000 Chickens vs 1 T-Rex]]></title>
            <link>https://coinsbench.com/soas-v-100-000-chickens-vs-1-t-rex-8a98ee588ef9?source=rss-38a0052b4bdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a98ee588ef9</guid>
            <category><![CDATA[web3-security]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Bozhidar Bonev]]></dc:creator>
            <pubDate>Sat, 24 Oct 2026 22:06:01 GMT</pubDate>
            <atom:updated>2026-10-24T22:06:01.469Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>SOAS </strong>V<strong> — 100 000 Chickens vs 1 T-Rex</strong></h3><blockquote>Part of the series — “Snail On A Slope”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AYnsiu8TGEBekXBhrZhknQ.png" /></figure><h3>Introduction</h3><p>Remember that stupid “Epic Battle Simulator” game? Even if you don’t, there is a great chance you’ve seen one of those TikTok videos about 1 million spartan warriors vs 1000 US military troops or 100 000 chickens vs 1 T-Rex that make your brain rot as if you had just been lobotomized. The attack we are going to explore today is somewhat similar to that scenario but without injuring the brain part, and is one my favorite things to look for when hunting for vulnerabilities, because it is simple, often overlooked by developers and sometimes can be catastrophic.</p><p><strong>SPOILER ALERT: The chickens win</strong></p><p>If you are reading this article, you are most surely familiar with how stable coins work or at least have used them during swaps. Today we are going to look at one specific design of a stable coin and an attack on it that doesn’t require any external attacker contracts, price manipulations, flash loans or anything at all. Seems strange, but bear with me.</p><h3>Understanding the Protocol</h3><p>Bozhidar’s stable coin, or bUSD for short, is a simple stable protocol. Users can deposit supporting assets and the protocol mints them bUSD, which is priced by an oracle. The protocol diversifies the backing by holding a basket of different assets with good reputations, like USDC, USDT and more. This is needed because relying on only one asset is dangerous, as the single backing asset can lose value and then we lose the backing of our stable protocol, meaning that it becomes unhealthy. The mechanism to balance the basket are:</p><ul><li>Introducing a dynamic fee when minting so that no asset is over represented</li><li>Withdrawing returns a plethora of assets at their current proportions</li></ul><p>When minting, this mechanism has to decide if any of the assets in the backing is going over the needed proportions, and it does it through the usage of a ratio, which is defined by dividing the current existing value of the incoming asset, that already exists in the vault, by the total supply of bUSD, our stable coin. Just before taking the user’s deposit, the protocol calculates what this ratio will be after it has taken the new incoming amount of the backing asset and uses it to calculate the fee using a <strong>kinked curve:</strong></p><ul><li>There is a minimum flat fee for every deposit</li><li>The minimum fee is paid when the new ratio is below the optimal ratio</li><li>Between the optimal ratio and the kink the fee grows by slope0</li><li>After the kink the fee grows by the steeper slope1</li></ul><p>Nothing too unusual, kinked curves are relatively common. So now let’s see our dummy implementation that is trimmed down to just the essentials needed for exploring the attack. It has no burn path, no borrowing, access control or any of that fancy stuff real protocols have and therefore it consists of just three contracts and one library:</p><ul><li><em>MockERC20</em></li><li><em>MockOracle</em></li><li><em>DummyBVault</em></li><li><em>FeeLib</em></li></ul><p>Our <em>MockERC20 </em>contract is just a simple implementation of an ERC20 token like USDC, USDT, PYUSD, the backing tokens basically.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/922d4f02bbc256078abc0093273d8ef6/href">https://medium.com/media/922d4f02bbc256078abc0093273d8ef6/href</a></iframe><p>The <em>MockOracle </em>is the simplest of oracles, it is just a dumb price feed where everything is $1.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9f11f50a95d13c5ca6626d14eddf12c3/href">https://medium.com/media/9f11f50a95d13c5ca6626d14eddf12c3/href</a></iframe><p><em>FeeLib </em>is the lonely library of our protocol, which is only concerned with the kinked fee curve. It takes the basic fee data of the protocol and the after-deposit value of the ratio, performs the calculations and spits out the rate at which the fee, at the end, will be calculated.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ceeb4aabc30a092e76c994b795da7e50/href">https://medium.com/media/ceeb4aabc30a092e76c994b795da7e50/href</a></iframe><p>The main contract of this protocol is the <em>DummyBVault</em>, which is the bUSD token itself and the vault as well. The <em>mint()</em> function takes the users’ assets (USDC, USDT, PYUSD), mints bUSD to the users and after calculating the fee (in bUSD), sends it to an insurance fund address where it will be kept safe. <strong>The interesting part here is that the rate comes from the ratio after the mint and that it is applied to the whole amount of the mint/deposit.</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7497b16d481f2d4de1fc5f60f12d91d2/href">https://medium.com/media/7497b16d481f2d4de1fc5f60f12d91d2/href</a></iframe><h3>Anatomy Of The Attack</h3><p>The protocol settings for the fee are going to be defined as:</p><ul><li><em>0.5% minimum fee</em></li><li><em>1% slope0</em></li><li><em>10% slope1</em></li><li><em>85% kink</em></li><li><em>33% optimal ratio</em></li><li><em>The basket will start at 300 000 USDC, 300 000 USDT and 300 000 PYUSD so the total bUSD supply is 900 000</em></li></ul><p>The attacker in this protocol control only the amount of the deposit and how many times to deposit but it turns out to be crucial. Imagine our attacker is a whale with 2 million USDC interacting with our protocol:</p><ul><li>Attacker calls <em>mint()</em> with all the 2M USDC. The ratio is calculated as for after the mint so it is <strong><em>(300K + 2M) / (900K + 2M) = 79.3%</em></strong>. This means that he lands in the space between the optimal and kink, which makes the calculation of the rate to be <strong><em>0.5% + 1% * (79.3–33) / (85 -33) = 1.39%</em></strong> (rounded). This rate, as balded above, is now applied to all the 2M USDC and the fee turns out to be 27 811 bUSD (yes, the fee is taken as the internal stable coin)</li><li>Our attacker rewinds time back and this time decides not to supply the whole 2M tokens at once but split it into 20 chunks of 100 000 USDC each</li><li>The first chunk takes the ratio to 40% so the rate on it is about 0.63%. The second pushes it to 45% and the third to 49%, etc.</li><li>Now only the last chunk, the last 100 000 USDC, ends up at 79.3% ratio and pays the 1.39%</li><li>By separating the deposit, the whale got a total fee of 22 699 bUSD, which is 5111 bUSD less than before. He has the same asset and amount deposited into the same basket but saved 18.4% of the fee</li><li>Yes, the gas cost is more that way but it is negligible compared to the money saved from fees</li></ul><p>The more chunks the users split their deposits into the closer they can get to the most economic fee payment, although it is isn’t endless. For our whale example the numbers get flat at around 22 300 bUSD total fee:</p><pre>splits | total fee (bUSD)<br>1      | 27 811<br>2      | 25 717<br>5      | 23 868<br>10     | 23 109<br>20     | 22 699<br>50     | 22 443<br>100    | 22 356</pre><h3>Conclusion</h3><p>Well, first of all this, kind of attack works for the guys with the big bucks, no retailer will ever bother to do that as there is no significant gain (in this case saving) and there is no way to evade the fee as there is a minimum amount that has to be paid regardless of the situation, amount or anything else. There is no theft here and nobody loses funds but the mechanism that the kink fee serves, the penalty for over backing with a single asset, is broken as it can be more or less evaded. It was created to be a harsh balancer for the backing bucket of assets but when it is most needed, when the big bucks arrive, it turns into a cute puppy that causes but a minor discomfort.</p><p><strong>Full dummy protocol code &amp; tests can be found at:</strong></p><p><a href="https://github.com/BozhidarBonev/MediumArticlesCodeExamples/tree/master/SnailOnASlope/100kChickensVs1TRex">MediumArticlesCodeExamples/SnailOnASlope/100kChickensVs1TRex at master · BozhidarBonev/MediumArticlesCodeExamples</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a98ee588ef9" width="1" height="1" alt=""><hr><p><a href="https://coinsbench.com/soas-v-100-000-chickens-vs-1-t-rex-8a98ee588ef9">SOAS V — 100 000 Chickens vs 1 T-Rex</a> was originally published in <a href="https://coinsbench.com/">CoinsBench</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SOAS IV — Traffic On The Path To The Financial Forest]]></title>
            <link>https://coinsbench.com/soas-iv-traffic-on-the-path-to-the-financial-forest-7bbcbe1747b8?source=rss-38a0052b4bdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/7bbcbe1747b8</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[web3-security]]></category>
            <dc:creator><![CDATA[Bozhidar Bonev]]></dc:creator>
            <pubDate>Sat, 17 Oct 2026 21:26:01 GMT</pubDate>
            <atom:updated>2026-10-17T21:26:01.565Z</atom:updated>
            <content:encoded><![CDATA[<h3>SOAS IV — <strong>Traffic On The Path To The Financial Forest</strong></h3><blockquote>Part of the series — “Snail On A Slope”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AYnsiu8TGEBekXBhrZhknQ.png" /></figure><h3>Introduction</h3><p>Don’t you just hate it when there is so much traffic that you start questioning if you should even go home or just return to the office and sleep there? Maybe the best strategy is to rev the engine so hard that you are out of gas and just sleep in the car in order to be closer to the office in the morning. Today we are going to explore a somewhat similar situation that can arise on the path to the decentralized financial forest.</p><p>You already know what a perpetual is because you read the <a href="https://medium.com/coinsbench/soas-iii-hedge-sandwich-with-two-signed-prices-part-i-193791b1a149">Hedge Sandwich With Two Signed Prices</a> articles or you were just planning to read them before you continue further in this one because today we are going to explore a specific implementation of a perpetual protocol.</p><p>As usual users open long or short positions but this time the other side of the trade is taken by the liquidity pool, which is funded by LPs. In such cases they usually deposit two tokens in the pool and receive an LP token in exchange. In that way the users’ trades are settled against the pool so if a user profits from a position, the pool pays them and LPs lose and vice versa. LPs are basically the house against which the game happens and they take the risk. There are different ways such protocols mitigate the risk:</p><ul><li>By capping the size of the positions so that the pool can always afford to pay the winning positions</li><li>ADL (auto-deleverage) — closing some of the winning trades automatically when the pool is under considerable stress</li></ul><p>Such protocols try to not get to the edge of solvency so they try to keep the system constantly balanced by:</p><ul><li>Funding longs or short by fees, depending on which side is dominated currently</li><li>Giving worse execution prices to coming orders that will only worsen the existing imbalance</li></ul><p>Users can increase or decrease their position by using market or limit orders. The difference between them is that market order executes at current price while limit orders wait for a specific price to occur before executing.</p><p>We are now going to explore one such protocol, a dummy protocol, which is far simpler, of course, and is trimmed down to only the essentials needed for the attack explanation.</p><h3>Understanding the Protocol</h3><p>Our dummy protocol consists of four contracts and one library:</p><ul><li><em>MockERC20</em></li><li><em>Order</em></li><li><em>OrderHandler</em></li><li><em>OrderVault</em></li><li><em>MaliciousCallback</em></li></ul><p>Our <em>MockERC20 </em>contract is just a simple implementation of an ERC20 token like USDC, nothing fancy, nothing new.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bc4d32fce87c4183faa219c0a04d9f9e/href">https://medium.com/media/bc4d32fce87c4183faa219c0a04d9f9e/href</a></iframe><p>The <em>Order </em>library holds the needed data structures for checking the incoming order type and the incoming order properties.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/05219ccd5aa6c8f40ebec69d9145b839/href">https://medium.com/media/05219ccd5aa6c8f40ebec69d9145b839/href</a></iframe><p>The main contract in our dummy perpetual is the <em>OrderHandler</em>, which orchestrates the creation, execution, cancellation of orders as well as closing of the users’ positions and simulating swaps through external DEXs. Users create or in reality they can also increase their existing positions by calling <em>createIncreaseOrder() </em>at the end of which an event is emitted. The create function allows users to specify:</p><ul><li>a callback contract address so that protocols can use the perpetual and get called when their order is filled so they can continue their own logic</li><li>a swap path so that during the execution of the order the initial user’s collateral can be swapped to some other token</li><li>acceptable price limit because between the call of the function and the filling of the order the price can move</li></ul><p>An off-chain keeper keeps track of these newly created market increase orders and is the only one allowed to call <em>executeOrder() </em>supplying the current signed price from an oracle at the time of the execution. An internal <em>_executeOrder()</em> function is wrapped inside a try/catch logic so that if the fill of the order fails because of lack of liquidity or whatever, the keeper transaction doesn’t just revert but instead is canceled through <em>_cancelOrder()</em>. After both successful fill and cancellation of the order a callback to the user is executed, if such is needed at all, with two protections</p><ul><li>a specific cap on callback gas limit</li><li>a try/catch wrap so that a malicious callback can’t take down the keeper’s transaction</li></ul><p>At the very end of both paths the keeper is reimbursed for the gas. As for the other functions, in a nutshell, we have a <em>closePosition()</em> function, which closes the users’ positions and realizes gains/losses, and a <em>_simulateSwapPath()</em> function, which simulates an external swap because a user can supply collateral in the form of USDC but open a long perp on ETH so the collateral has to be swapped to the actual position token.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4437a916c25071f57c54b144819b2306/href">https://medium.com/media/4437a916c25071f57c54b144819b2306/href</a></iframe><p>The mini <em>OrderVault </em>we have is the place where the collateral and fees are kept and it also serves as the pool where LPs put their liquidity to fund the operations of the protocol. It is a dummy protocol after all, no need for complexity.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2c79de8c927ffdbfa33e69ae86e2b096/href">https://medium.com/media/2c79de8c927ffdbfa33e69ae86e2b096/href</a></iframe><p><strong>So a normal usage of the protocol looks like this:</strong></p><p><strong>User</strong><em><br> |<br> </em><strong>|</strong><em> createIncreaseOrder()<br> </em><strong>|<br> -&gt; OrderHandler</strong></p><p><strong>Keeper</strong><em><br> </em><strong>|</strong><em><br> </em><strong>|</strong><em> executeOrder()<br> </em><strong>|<br> -&gt; OrderHandler<br> |</strong><em><br> </em><strong>|</strong><em> _executeOrder() or _cancelOrder()<br> </em><strong>|<br> -&gt; OrderHandler</strong><em><br> |<br> </em><strong>|</strong><em> call callback<br> </em><strong>|<br> -&gt; CallbackContract<br> </strong><em>|<br> </em><strong>|</strong><em> return<br> </em><strong>|<br> -&gt; OrderHandler<br> </strong><em>|<br> </em><strong>|</strong><em> transferOut()<br> </em><strong>|<br> -&gt; OrderVault</strong></p><h3>Anatomy Of The Attack</h3><p>The attacker just as normal users controls three important parameters in our protocol:</p><ul><li>The callback contract</li><li>The gas budget of the callback</li><li>The length of the swap path</li></ul><p>So he can easily construct a contract with which to take advantage of those parameters and exploit the protocol.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c23b95f15654ee40f9e0461fb4fafd8d/href">https://medium.com/media/c23b95f15654ee40f9e0461fb4fafd8d/href</a></iframe><p><strong>And now we follow the attack sequence:</strong></p><ul><li>Attacker calls <em>createIncreaseOrder()</em> with a very long swap path and <em>MaliciousCallback </em>as his callback contract</li><li>Keeper sees the newly created order, gets a signed price and calls <em>executeOrder() </em>on-chain</li><li>Then swap executes consuming a lot of gas</li><li>Then the callback is called and it uses its own gas limit doing nothing useful but succeeds</li><li>The last pay of tokens to the keeper then has no gas left to execute and has no try/catch wrap of its own so it throws</li><li>The code jumps to the catch of the <em>executeOrder()</em>, which calls <em>_cancelOrder()</em> but has an identical shape to the internal <em>_executeOrder()</em></li><li><em>_cancelOrder()</em> also calls the callback, which exhausts the gas and the last pay of tokens to keeper fails</li><li>There are no more catch fields upwards so the whole transaction reverts, nothing gets saved or changed</li><li>The attacker can keep this state of his order for as long as he likes as the keeper continuously tries to execute. There is no cost as this comes to the expense of the keeper who spends gas trying to execute</li><li>When the market has moved and the price is now more favorable to the attacker, only then he calls <em>flipSwitch()</em> on his callback so no gas is expended and the keeper can successfully execute his order, but here is the catch, at the old price before the gas griefing. The protocol never asks if the price makes sense, it believes the keeper to supply a fresh, signed price</li><li>The order gets gets filled automatically and it is already a winning trade at which point the attacker can close it and profit without risking anything effectively turning a risky perpetual into a free option</li></ul><h3>Conclusion</h3><p>Three main points I want to conclude with:</p><ul><li>Neither callbacks, nor swaps are dangerous or inherently bad but they are a great recipe for a vulnerability when used inside a hard promise like “execute at current price or do no execute at all”</li><li>When auditing protocols we should always check for transactions, which can fail silently or fail too loudly</li><li>Always, I can’t stress this enough, we should always consider the user controlled parameters. As my father used to say, half of the solution to the task is already in the description of it</li></ul><p>The financial forest is messy, sly and sometimes the path to it is a bit too crowded with suspicious beasts but that makes it interesting and we, as security researchers, are not intrigued by plain, basic, vanilla places so we will keep learning and hunting. Until next time, ser.</p><p><strong><em>Full dummy protocol code &amp; tests can be found at:</em></strong></p><p><a href="https://github.com/BozhidarBonev/MediumArticlesCodeExamples/tree/master/SnailOnASlope/trafficOnThePathToTheFinancialForest">MediumArticlesCodeExamples/SnailOnASlope/trafficOnThePathToTheFinancialForest at master · BozhidarBonev/MediumArticlesCodeExamples</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7bbcbe1747b8" width="1" height="1" alt=""><hr><p><a href="https://coinsbench.com/soas-iv-traffic-on-the-path-to-the-financial-forest-7bbcbe1747b8">SOAS IV — Traffic On The Path To The Financial Forest</a> was originally published in <a href="https://coinsbench.com/">CoinsBench</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SOAS III — Hedge Sandwich with Two Signed Prices: Part I]]></title>
            <link>https://coinsbench.com/soas-iii-hedge-sandwich-with-two-signed-prices-part-i-193791b1a149?source=rss-38a0052b4bdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/193791b1a149</guid>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[web3-security]]></category>
            <dc:creator><![CDATA[Bozhidar Bonev]]></dc:creator>
            <pubDate>Sat, 03 Oct 2026 20:26:01 GMT</pubDate>
            <atom:updated>2026-10-03T20:26:01.644Z</atom:updated>
            <content:encoded><![CDATA[<h3>SOAS III — <strong>Hedge Sandwich with Two Signed Prices: Part </strong>I</h3><blockquote>Part of the series — “Snail On A Slope”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AYnsiu8TGEBekXBhrZhknQ.png" /></figure><h3>Introduction</h3><p>You probably expect to see a recipe for posh eggs and cheese sandwich sold at a ridiculously priced place but I would have to disappoint you, although a metaphor might work here, we are indeed going to see what went wrong in one kind of a kitchen, the decentralized finance one. So excuse my culinary clickbait and let’s get down to it. Let’s see what the eggs are made of, how did they break and at what cost.</p><p><strong>On Perpetual Contracts<br></strong>Not everyone is familiar with financial derivatives so I would like to give a brief and simple introduction to what a perpetual is. For those of you that do know, feel free to skip this part.</p><p>In traditional finance there are futures contracts. They offer people the chance to buy an underlying asset at a future price with an expiration date and once the date is reached, the deal has to be either settled or rolled into a new contract. The main problems that they have are twofold:</p><ul><li><em>The contracts expire</em></li><li><em>The buyer is tied to the underlying asset</em></li></ul><p>In order to solve these problems in the 90’s, financial institutions started the <strong><em>CFD</em>s — <em>contracts for difference</em></strong>. They have no expiry, can be traded with leverage and nobody necessarily has to even touch the underlying asset. The trader and the broker sign a contract that just follows the price of the real asset and pays the difference between the opening and the closing price but nobody actually buys or sells a real asset. <em>CFD </em>is the traditional finance instrument that most closely resembles the web3 alternative, which is called a perpetual contract. Perpetuals, like <em>CFD</em>s, have no expiration and usually but not necessarily use a funding mechanism to balance short and long position in order to anchor the derivative price to the real, spot price of the underlying asset. There are different ways to implement a perpetual though as some use order books, virtual <em>AMM</em>s or set LPs or the protocol itself as the counter party and hedge the exposure. There is no need to hold any asset and can also be traded with leverage. If it still doesn’t click, don’t worry, in the next section we are going to explore an example of a perpetual contract and its intricate workings.</p><h3>Understanding the Protocol</h3><p>Our dummy protocol consists of five contracts:</p><ul><li><em>MarginLedger</em></li><li><em>SpotPool</em></li><li><em>HedgingDealer</em></li><li><em>PerpEngine</em></li><li><em>PriceOracle</em></li></ul><p>The <em>MarginLedger </em>is the contract that tracks a single market’s positions of different users and their counterparts. It allows to deposit funds, which are recorded as their margin, settles trades when a user opens a new position with their available margin and allows users to withdraw their deposited funds. When interacting with a perpetual, a user first has to deposit some liquidity with which he plans to open a position, so this is, naturally, the contract that first comes into play, the first entrypoint.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fb6545818a160b4e0231cb0283a61088/href">https://medium.com/media/fb6545818a160b4e0231cb0283a61088/href</a></iframe><p>Then we have a <em>SpotPool </em>contract, which is just a minimal representation of an <em>AMM </em>through which swaps are executed. In a real world example this contract wouldn’t be needed as an external <em>AMM </em>can be used, like <em>PancakeSwap </em>or<strong> </strong><em>Uniswap</em>. The simple architecture is of a constant-product and has a base and quote tokens with their respective reserves. It allows for swapping between the two tokens as already mentioned and exposes a view function for the current spot price — quote per base.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/965fbc4d242d510b786487dadaf897e3/href">https://medium.com/media/965fbc4d242d510b786487dadaf897e3/href</a></iframe><p>The main goal of a dealer is to take the opposite side of user’s position. Imagine Alice wants to bet that ETH, at a current price of $2000, will go up. She deposits $500 into the protocol and uses leverage to open a 1 ETH long position or deposits the whole $2000, as leverage can be risky, we all know how cruel crypto markets can be. So she deposits $2000 and opens 1 ETH long perpetual position, the dealer has to take the other side so he has to record a 1 ETH perpetual short position in his own name but the dealer does not want to expose himself to that risk so he has to hedge it. After Alice’s deposit and position are recorded in the internal accounting and after the dealer’s opposite position is recorded too, the dealer performs a swap for ~$2000 of USDC in order to receive 1 ETH. In that way Alice owns a perpetual position of 1 ETH perpetual long but the dealer owns a perpetual position of 1 ETH short and a spot position of 1 ETH long. Now, imagine ETH jumps to $2500 and Alice wants to close the position. Alice has a profit of $500 on her perpetual position, the dealer has a $500 loss on his perpetual position but a $500 profit from his spot position.</p><p><strong><em>At opening of position:</em></strong></p><p>| Alice: 1 ETH long perp<br>| Dealer: 1 ETH short perp<br>| Dealer: 1 ETH long spot</p><p><strong><em>At closing of trade (perp accounting):</em></strong></p><p>| Alice perp: +$500<br>| Dealer perp: -$500<br>| Total: $0</p><p><strong><em>But the loss of the dealer is hedged (hedge accounting):</em></strong><br> | Dealer perp: -$500<br>| Dealer spot: +$500<br>| Total: $0</p><p>Keep in mind that these are all well rounded values for the sake of the example, doing swaps through external <em>AMM</em>s requires fees to be paid and so on.</p><p>This perpetual design has an important invariant, which has to be noted. <strong>The price the trader’s position is opened at is determined by whatever the hedging trade executes at on the external <em>DEX </em>and not by an independent perp market or directly by an oracle. </strong>With the invariant found, now there are only two questions left to answer — where does the dealer get the USDC to swap for ETH in order to hedge and how does the protocol make any money when no real, significant risk exists. The answer to the first question is simple — LPs, the answer to the second question is even simpler — execution fees (although that is not implemented in our dummy protocol).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4d4e20370a5d6455d246cf0c22b9980d/href">https://medium.com/media/4d4e20370a5d6455d246cf0c22b9980d/href</a></iframe><p>The <em>PerpEngine </em>is a contract that exposes the entry point for opening positions and a deviation guard regarding the price of the <em>AMM </em>execution of the trade.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/17e8db7e9bd7b95586c24b50a0a720f7/href">https://medium.com/media/17e8db7e9bd7b95586c24b50a0a720f7/href</a></iframe><p>At the end we have a <em>PriceOracle </em>contract, which is a very simple implementation of a pull type price adapter like <em>Pyth</em>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b1d7e4e244a61bd5e69912268be1b308/href">https://medium.com/media/b1d7e4e244a61bd5e69912268be1b308/href</a></iframe><p>So a normal usage of the protocol looks like this:</p><p><strong><em>Trader</em></strong><em><br> |<br> </em><strong><em>|</em></strong><em> openPosition()<br> </em><strong>|<br> -&gt; PerpEngine</strong><em><br> </em><strong>|</strong><em><br> </em><strong>| </strong><em>fillOrder()<br> </em><strong>|<br> -&gt; HedgingDealer</strong><em><br> </em><strong>|</strong><em><br> </em><strong>|</strong><em> swap…() — the swap here depends on the direction<br> </em><strong>|<br> -&gt; <em>S</em>potPool<br> |</strong><em><br> </em><strong>|</strong><em> returns oppositeAmount<br> </em><strong>|<br> -&gt; PerpEngine</strong><em><br> |<br> </em><strong>|</strong><em> _checkPriceBand()<br> </em><strong>|<br> -&gt; PerpEngine<br> </strong><em>|<br> </em><strong>|</strong><em> settleTrade()<br> </em><strong>|<br> -&gt; MarginLedger</strong></p><h3>Anatomy Of The First Attack — Hedge Sandwich</h3><p>Notice how when a position is being opened, the trade is executed through the <em>SpotPool</em>, which determines the price at which the order will be filled at but the sanity check is determined by the oracle price. The protocol needs this check as it has to bound the swap to a reasonable price frame. In our protocol it is determined as 10% of the current oracle price because too wide of a tolerance will be too permissive and the trade might execute too far away from the fair value but too narrow of a tolerance will cause trades to constantly fail as the <em>SpotPool </em>price, by default, will always be updated faster than the oracle. Fees contribute even more to the divergence between the two and the <em>_checkPriceBand() </em>exists exactly for this but the attack here lies in the question — what does “within the price band” mean relative to the trade price determination mechanism. So what can happen if an attacker lurks for a staleness in the oracle price, which is not so uncommon and doesn’t require any manipulation?</p><p><strong>Consider the following attack sequence:<br><em>Setup:</em></strong></p><ul><li>Oracle is stale — reporting ETH price of $3720</li><li>DEX pool 1000 ETH / 4 000 000 USDC — price of ETH at $4000</li></ul><p><strong><em>Attack:</em></strong></p><ul><li>Attacker calls <em>MarginLedger.deposit()</em></li><li>Attacker calls <em>SpotPool.swapExactQuoteForBase()</em> — skews the pool up (ETH price goes up)</li><li>Attacker calls <em>PerpEngine.openPosition()</em> — opens a short position on ETH</li><li><em>PerpEngine </em>calls <em>HedgingDealer.fillOrder()</em></li><li><em>HedgingDealer </em>calls <em>SpotPool.swapExactBaseForQuote()</em> — hedges at skewed pool price, meaning that he sells ETH in the pool</li><li><em>PerpEngine </em>calls <em>_checkPriceBand()</em> — checks if skewed price is within +-10% of $3720 — Passes</li><li><em>PerpEngine </em>calls <em>MarginLedger.settleTrade()</em></li><li>Attacker calls <em>SpotPool.swapExactBaseForQuote() </em>to unskew the pool or just holds the ETH</li><li>Attacker calls <em>MarginLedger.withdraw()</em></li><li><em>MarginLedger </em>calls <em>PriceOracle.getPrice()</em> — which is still stale at $3720</li><li><em>MarginLedger </em>sends Attacker tokens before the oracle has a chance to update</li></ul><p><strong>Where does the profit of this attack actually come from?<br></strong>The analysis shows that if the oracle price and the pool are nearly the same, the skew by itself does not do anything. The reason for that is the attacker has to buy ETH to skew the price but then the hedging of the protocol sells back ETH into the pool. The protocol and swap fees also make the situation worse. When using just a hedge sandwich of the pool, there is no lunch for the attacker as his total is always less than or equal to zero. So a stale oracle is needed in order for the attacker to have a profit and that profit comes from the significant but within the price band divergence of the oracle and pool.</p><p><strong><em>Example:</em></strong></p><ul><li>Pool: 1000 ETH / 4 000 000 USDC</li><li>Attacker buys ~2.5 ETH ($9987.53)</li><li>Price goes to ~$4020</li><li>Attacker opens short of 1 ETH</li><li>Dealer hedges at ~$4004</li><li>Attacker sells ~2.5ETH for $9937.76</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WmKB4nw_mXzygq0Mkx2PwA.png" /></figure><p><strong>So why sandwich the hedge at all? Well, the skewing of the pool does not create the numbers of the profit of the attack, it only determines what size can capture it.</strong></p><p>Once the vulnerability is clear (the oracle is stale), there are three strategies to consider on exploiting it:</p><ul><li><strong><em>Direct</em></strong> — Open position on an untouched pool — no sandwich</li><li><strong><em>Skew &amp; Unwind</em></strong> — Skew the pool by buying ETH, open short perp position, sell the ETH back at the end</li><li><strong><em>Skew &amp; Hodl</em></strong> — Skew the pool by buying ETH, open short perp position, keep the ETH</li></ul><p><strong><em>Direct / Skew &amp; Unwind<br></em></strong>Both these strategies are mathematically identical at all the different position sizes that I have tested. They net the same profit to the attacker with a small nuance that if we include the swap fees needed, the Skew &amp; Unwind will net a bit less actually. Skewing the pool and then fully undoing it starts and end at almost exactly the same pool state as never actually touching it (Direct). The curve of both these strategies starts to collapse into losses for the attacker at around 70 ETH position as a large trade’s own impact moves the average fill below profitability or beyond the price band. So it is an optimization problem.</p><p><strong><em>Skew &amp; Hodl</em></strong><br>This strategy dominates both the others at all the sizes possible but also has a limit. The problem is again that it is expensive to unskew the pool at the end when the dealer has already sold ETH into it but no one said that it should be sold back, holding and marking it at real external market price is free. This strategy also peaks but around 150 ETH for a perp short position and starts falling until its own diminishing returns catch it. Basically, to buy a big enough skew in order to keep a bigger position inside the price band costs more and more as the size of that position grows to the point where it is not worth it, the cost of the skew eventually outpaces what the position can extract because of the staleness. This happens around 320 ETH short perp position. Another thing to consider is that this strategy, of course, requires the attacker to risk his own capital and carry an exposure on the ETH that he hodls. Flash loans are useless here as they have to be returned and that brings us automatically back to the Skew &amp; Unwind strategy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2cxG5lhoT3p4I8wyHvUQwA.png" /></figure><p><strong>So there are some strict limitations:</strong></p><ul><li>An oracle has to be stale enough to produce a window of opportunity</li><li>Profiting is an optimization issue — there is a calculable position size that maximizes profits for different pool sizes as smaller and especially larger positions extract less</li><li>The attack has to be done in one atomic transaction — the skew, the position and final withdraw have to be executed inside the same transaction as no space can be left for the protocol to breathe. The oracle might catch up or the pool might change</li><li>This attack is repeatable but again within limits — draining a pool raises alarms pretty quickly well before the theoretical limit is reached</li></ul><p>So where does the profit come from, who is paying for the lunch?</p><p>Well, the dealer always nets to zero as the perp and spot positions cancel each other so the answer, sadly, is the LPs, they are the only ones left to absorb the loss.</p><h3>Conclusion of Part I</h3><ul><li><em>HODL</em></li><li><em>This perpetual contract is not getting a Michelin star</em></li></ul><p>I fear this one became a bit too long so in the next part we are going to look at the two signed prices attack. Stay tuned, the second part is already in the oven!</p><p><strong><em>Full dummy protocol code &amp; tests can be found at:</em></strong></p><p><a href="https://github.com/BozhidarBonev/MediumArticlesCodeExamples/tree/master/SnailOnASlope/hedgeSandwichWithTwoSignedPrices">MediumArticlesCodeExamples/SnailOnASlope/hedgeSandwichWithTwoSignedPrices at master · BozhidarBonev/MediumArticlesCodeExamples</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=193791b1a149" width="1" height="1" alt=""><hr><p><a href="https://coinsbench.com/soas-iii-hedge-sandwich-with-two-signed-prices-part-i-193791b1a149">SOAS III — Hedge Sandwich with Two Signed Prices: Part I</a> was originally published in <a href="https://coinsbench.com/">CoinsBench</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SOAS III — Hedge Sandwich with Two Signed Prices: Part II]]></title>
            <link>https://coinsbench.com/soas-iii-hedge-sandwich-with-two-signed-prices-part-ii-6f93c464a2ab?source=rss-38a0052b4bdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f93c464a2ab</guid>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[web3-security]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Bozhidar Bonev]]></dc:creator>
            <pubDate>Fri, 02 Oct 2026 20:46:01 GMT</pubDate>
            <atom:updated>2026-10-02T20:46:01.594Z</atom:updated>
            <content:encoded><![CDATA[<h3>SOAS III — Hedge Sandwich with Two Signed Prices: Part II</h3><blockquote>Part of the series — “Snail On A Slope”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AYnsiu8TGEBekXBhrZhknQ.png" /></figure><h3>Introduction</h3><p>In the previous part we explored the hedge sandwich kitchen: a hedging perp dealer, a <em>DEX </em>pool and a price band that trusted the oracle to be spot on. The attacker depended on the staleness of the oracle, which he cannot control so it is fair to say that luck was an ingredient in that recipe. If you’ve missed that, I recommend reading the first part of the article as our dummy protocol was explained there. We are just going to expand a bit on it in this second part as we are going to look at the way modern pull based oracles work and how a design feature can end up shooting itself in the foot.</p><p><strong>Pull Oracles In A Nutshell<br></strong>Contrary to the more popular push oracles, pull oracles do not push a price to a contract at an interval. Instead, they form the prices and sign them off-chain at a specific moment, allowing anyone to submit them on-chain with the condition that they can’t be older than the ones already submitted. This means that at any given moment there can be multiple, valid, different, true prices that can be used on-chain by anyone, at any “still fresh” time. So one asset, different true, valid prices and one decision on which price to use and when exactly.</p><h3>Understanding the Protocol</h3><p>Our dummy protocol consists of five contracts, explained in the previous part:</p><ul><li><em>MarginLedger</em></li><li><em>SpotPool</em></li><li><em>HedgingDealer</em></li><li><em>PerpEngine</em></li><li><em>PriceOracle</em></li></ul><p>But with an extra new one:</p><ul><li><em>OracleDealer</em></li></ul><p><strong>Fast recap on the <em>PriceOracle </em>dummy contract:</strong> it is a simple implementation of a pull type price adapter like <em>Pyth</em>. It accepts prices through the <em>setPrice() </em>method by checking the publish time. In a real-world scenario it would also check the signatures but that is irrelevant for our purpose.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b1d7e4e244a61bd5e69912268be1b308/href">https://medium.com/media/b1d7e4e244a61bd5e69912268be1b308/href</a></iframe><p>In the protocol we had a <em>HedgingDealer</em>, which used to take the opposite side of the user’s perp position and hedge it on a DEX. Here we are introducing another dealer, the <em>OracleDealer</em>. which represents another way for users to open a perp position in the same protocol and for LPs to participate. The <em>OracleDealer </em>mechanism is much simpler and looks much safer as it fills user’s orders at the current oracle price and takes the other side of the perp, no swaps on a <em>DEX</em>, no spread, no slippage. Moreover, it is not supplied by a fixed pile of liquidity but rather by LPs who mint and redeem shares with a price based on the total worth of the vault. Basically, a standard <em>ERC-4626 </em>style accounting, nothing new under the sun.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0ba72756ee3f16311eb4d963ca33eaed/href">https://medium.com/media/0ba72756ee3f16311eb4d963ca33eaed/href</a></iframe><p><strong>An example on the LP flow to make things completely clear:</strong></p><ul><li>Alice deposits $50 000 through <em>OracleDealer </em>in order to become LP, since she is the first depositor she gets 50 000 shares, one dollar per share at start</li><li>Some users’ perp positions moved in favor of the vault so now the total worth of it has risen to $110 000</li><li>Bob deposits $50 000, the same as Alice, but he only gets 50 000 * (50 000 / 110 000) which is approximately 22 720 shares</li></ul><p>The share price at any given moment is determined by the vault value divided by the total shares in existence. The more the value of the vault grows, the more expensive the shares.</p><h3>Anatomy Of The Second Attack — Two Signed Prices</h3><p>You can probably already guess the attack, but here is the whole summary of it: When the share price of the vault is computed on each call to <em>deposit() </em>and <em>withdraw() </em>based on whatever the oracle states as “the current, valid” price and the attacker can decide what that “current, valid” price is, nothing stops him from from submitting a favorable price between a <em>deposit() </em>and a <em>withdraw() </em>without ever having to carry the risk associated with the anticipation of a price move. It’s a sure thing so to say.</p><p><strong>Consider the following attack sequence:<br><em>Setup:</em></strong></p><ul><li>An LP exists with a deposit of $100 000 as a first depositor, so 100 000 shares were given to him</li><li>Some non-malicious trader opened a short perp position through the <em>OracleDealer </em>for 10 ETH at $4000 ETH current price. The dealer took the opposite side of the trade so now he has a 10 ETH long perp and as the fill happens exactly at the current price, the vault is still worth $100 000, nobody is up or down yet</li><li>ETH is a crypto currency, duh, so it moves to $4010 per ETH. Somewhere off-chain a fresh price is signed that reflects the change but nobody has pushed it on-chain yet</li></ul><p><strong><em>Attack path:</em></strong></p><ul><li>Attacker calls <em>OracleDealer.deposit() </em>with $1 000 000 while the new price has not been pushed on-chain yet. The vault is still $100 000 for 100 000 shares so, naturally, the attacker receives 1 000 000 shares</li><li>Attacker calls <em>PriceOracle.setPrice() </em>with the new signed $4010 price of ETH</li><li>Attacker calls <em>OracleDealer.withdraw() </em>of a 1 000 000 shares. The vault is now worth $1 100 000 + the 10 ETH long perp position taken against the non-malicious user, which currently yields an upside of $100. So the total vault value currently sits at $1 100 100 against 1 100 000 shares and an attacker withdraw in that case results in 1 000 000 * (1 100 100 / 1 100 000) = $1 000 090.91</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GCM7RXVj0MVivBxIlmMF4g.png" /></figure><p>As you can see, the attacker walks away with 90.9% of a price move to which he exposed himself for a single transaction. The actual risk taker, the LP, who is open to the winds of the possibly swinging 10 ETH long perp, gets to keep only 1/10th of the profit. Contrary to the previous part, there is no optimization issue here, the returns from this attack scale almost linearly with a asymptotic crawl from 90% to 100%.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sbti1ncAiqJjgYkzu-lapw.png" /></figure><p>You can run the same sequence with $10 000 instead of $1 000 000 and check it for yourself. There is no <em>AMM </em>curve to fight or fees and slippage to worry about.<strong> So this is the perfect place to use a flash loan</strong>, something that we saw was useless in the hedge sandwich attack. Moreover, the attack can be done in both directions — decreasing or increasing price.</p><p><strong>Some limitations exist though:</strong></p><ul><li>There has to be an existing, or many, perp position/s to which the dealer has taken the opposite side</li><li>The dealer needs to have some perp position taken, someone needs to have opened</li><li>The total profit from the attack is determined by position size * price move — the attacker can’t profit more per unit than the price difference and the capital size only determines what fraction of the profit he is going to capture, approaching 100% but never actually reaching it with the increase of capital, as shown in the graph above</li><li>Same as in the attack in part I, all has to happen in a single transaction, atomically</li></ul><p><strong>So who is paying for the lunch this time?<br></strong>In part I we saw that the dealer always netted to zero as he hedged the opposite perp position and they canceled by default and the loss appeared as bad debt falling on the LPs. Similarly, here the loss falls on the LPs holding shares in the vault but this time it can’t be remedied in any way, there is no possible way out in any way, the protocol can’t write it off as bad debt as when the attacker’s withdraw executes, the loss is fully realized.</p><h3>Conclusion of Part II</h3><p>Well, first of all, we should be careful where we put our money, LPs get screwed constantly and not in the good way. Secondly, we should be aware of these small but sneaky ways for oracle tinkering that allow full drainage of a protocol. It was created as a different approach to delivering price on-chain but an implementation that is not careful can open the gates for an enormous theft. <em>TWAP </em>can always be considered as an option or even breaking the atomicity between depositing and withdrawing with a cooldown so that prices have time to be pushed on-chain.</p><p>So now we close our inspection of the financial kitchen with this second part, we stated last time that it is surely not getting a Michelin star but this time, at least, there was no cover charge on the entrance to the attack. If you lasted this far, go out in the sun and get an egg&amp;cheese sandwich, ser, you deserve it, see you on the next step up the slope!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f93c464a2ab" width="1" height="1" alt=""><hr><p><a href="https://coinsbench.com/soas-iii-hedge-sandwich-with-two-signed-prices-part-ii-6f93c464a2ab">SOAS III — Hedge Sandwich with Two Signed Prices: Part II</a> was originally published in <a href="https://coinsbench.com/">CoinsBench</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SOAS II — Reentrancy Guard as a Weapon]]></title>
            <link>https://coinsbench.com/soas-ii-reentrancy-guard-as-a-weapon-f7313cf6ee79?source=rss-38a0052b4bdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/f7313cf6ee79</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[web3-security]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Bozhidar Bonev]]></dc:creator>
            <pubDate>Thu, 17 Sep 2026 15:01:06 GMT</pubDate>
            <atom:updated>2026-09-23T09:25:46.974Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>SOAS </strong>II<strong> — Reentrancy Guard as a Weapon</strong></h3><blockquote>Part of the series — “Snail On A Slope”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AYnsiu8TGEBekXBhrZhknQ.png" /></figure><h3>Introduction</h3><p>Imagine a bridge protocol that relays messages between layer 1 and layer 2 networks. A typical message might be sending some ETH and/or calling for the execution of some functionality like “stake”, “add liquidity” or “withdraw”. The typical flow might be a call originating on L2, which emits some data, an off-chain mechanism picks up the data and executes some verification logic on L1, which then calls the messaging logic again on L1. The message is transferred and executed, or has failed and can be retried again.</p><p>I have built a dummy protocol to reconstruct the contracts that execute such logic, with the purpose to show concrete interactions between:</p><ul><li><em>cross-chain message relaying</em></li><li><em>retryable failed messages</em></li><li><em>low-level calls</em></li><li><em>finalization and reentrancy</em></li></ul><p>so that we can later, in part 3, analyze a very creative attack taking advantage of all these.</p><h3>Understanding The Protocol</h3><p>At the core of the protocol stand 4 main actors which hold the logic of this bridge:</p><ul><li><em>L1Relayer</em></li><li><em>L2Relayer</em></li><li><em>RouterL1</em></li><li><em>TargetContract</em></li></ul><p>and 2 main types that hold the data:</p><ul><li><em>Message</em></li><li><em>Withdrawal</em></li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/435d40df044189203d36d16a4e5853da/href">https://medium.com/media/435d40df044189203d36d16a4e5853da/href</a></iframe><p>The important difference between the types is in the concept, the <em>Message</em> represents what we want to relay, and the <em>Withdrawal </em>represents an action that will be finalized on L1.</p><p>For simplicity, we separate two paths for interacting with the protocol:</p><ul><li><em>Simple Message path from L2Relayer to L1Relayer</em></li><li><em>Withdrawal path from L2Relayer through RouterL1 to L1Relayer</em></li></ul><p><strong>Simple Message Path:</strong></p><p><strong>L2Relayer</strong><br><strong>|<br>| </strong><em>Call to</em><strong><br>|<br>-&gt; L1Relayer</strong><br><strong>|<br>| </strong><em>Call to</em><strong><br>|<br>-&gt; TargetContract</strong></p><p><strong>Withdrawal Path:</strong></p><p><strong>L2Relayer</strong><br><strong>|<br>| </strong><em>Call to</em><strong><br>|<br>-&gt; RouterL1</strong><br><strong>|<br>| </strong><em>Call to</em><strong><br>|<br>-&gt; L1Relayer</strong><br><strong>|<br>| </strong><em>Call to</em><strong><br>|<br>-&gt; TargetContract</strong></p><p>In our example, the users first interact with <em>L2Relayer.sol</em>, as the example focuses on relaying a L2 to L1 message.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b38b35b04e8cb6642499fad2ffb8932e/href">https://medium.com/media/b38b35b04e8cb6642499fad2ffb8932e/href</a></iframe><p>Its main job is to package an incoming message from the user into <em>Types.Message </em>and emit an event with the data, so it can be sent to L1. In such systems, there is an off-chain component or mechanism that observes the event and calls the other network with the observed data, therefore doing the job of connecting the two networks. In this example, we skip the off-chain part, as it is not relevant to the goal of the article.</p><p>On L1, there is also a relayer which might relay messages to L2, but this is not relevant for our example.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f2bfa59411e8cd98dcdf36341abebca6/href">https://medium.com/media/f2bfa59411e8cd98dcdf36341abebca6/href</a></iframe><p><em>L1Relayer</em>, when receiving messages, has the responsibility to execute them against their target. So, for example, User from L2 wants to call <em>withdraw()</em> on some L1 DeFi protocol using simple <em>Message </em>path:</p><ul><li>User calls <em>L2Relayer</em>, sending as parameters her <em>targetDeFiContract </em>and data containing <em>withdraw() </em>function to call</li><li><em>L1Relayer </em>calls <em>targetDeFiContract.withdraw()</em></li></ul><p>Both our L1 and L2 relayers inherit from <em>BaseRelayer.sol</em>, which holds the initial message, execution and retry logic.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/13d63b9aa06d52527637041df0e7e81e/href">https://medium.com/media/13d63b9aa06d52527637041df0e7e81e/href</a></iframe><p>The base contract needs to keep track of messages and their failed or processed status, so a hash of the message is used for a unique identifier. In this way, there is a path in the logic which allows a retry on a failed message. As you can already guess, retrying a message requires a failed one not to revert, and this happens through the use of a <em>SimpleSafeCall</em> contract, which does a low-level call and returns a boolean which can be recorded in the mappings.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fbf30c722c2fe6651e1c25c5ca26d126/href">https://medium.com/media/fbf30c722c2fe6651e1c25c5ca26d126/href</a></iframe><p>And now we arrive at the last contract — <em>RouterL1</em>. It is used (for simplicity) for the second path of execution, which is a withdrawal submitted off-chain to <em>executeMessage()</em> on <em>RouterL1</em>, which, in its turn, calls <em>L1Relayer.relayFinalMessage()</em>, where the call to the external contract is performed and the withdraw executed. The router also records executed messages on its own with a mapping, and they cannot be retried. An important point here is that the flow of the withdrawal starts at the router and is marked as finalized before the external call. The external call to <em>L1Relayer </em>is executed, and it may silently fail. The failed call of <em>L1Relayer</em> does not revert, but instead returns a boolean with value false, which is ignored by the <em>RouterL1</em>, leaving the protocol in a state where:</p><ul><li><em>finalized[Alice] = true</em>, as if execution succeeded</li><li>the actual withdrawal execution has failed</li></ul><p>This creates a system invariant that if a withdrawal is marked as finalized, then its execution must have succeeded.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/47327073e8c7bc15d80110b1c4b4866f/href">https://medium.com/media/47327073e8c7bc15d80110b1c4b4866f/href</a></iframe><h3>The Attack — Reentrancy Guard as a Weapon</h3><p>The attack itself is not a classic reentrancy trying to steal funds, but rather an attempt to reach that inconsistent state of succeeded finalization and failed execution. To achieve this, Bob designs and deploys an attacker contract, which has a logic path through which it will revert on the first call to <em>attack()</em>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/019bae34a9cc7029cfffb710a8585e1a/href">https://medium.com/media/019bae34a9cc7029cfffb710a8585e1a/href</a></iframe><p>The point of the forced revert on the first call is to cause a failed message in the relayer, so that the attacker can later retry the transaction.</p><p>Let’s walk through the flow of the malicious calls:</p><p>Bob (the attacker) sends a message from L2 to L1 using the simple <em>Message</em> path, whose target is his attacker contract. <em>L2Relayer </em>packs and emits the message, which is then passed to <em>L1Relayer. RelayFinalMessage() </em>calls the attacker contract, and it reverts, causing a state where <em>failedMessages[attackerHash] = true</em>. Bob then calls his own attacker contract with <em>setRevert(false)</em>, and as of the current moment, Bob has a message that:</p><ul><li><em>failed during the first try</em></li><li><em>can be retried</em></li><li><em>will behave differently on retry, as toRevert is set to false</em></li></ul><p>Alice then creates a legitimate withdrawal from L2 to L1, which Bob observes. Before Alice’s transaction is transmitted by the off-chain operator to <em>RouterL1</em>, Bob sets the data in his malicious contract to Alice’s withdrawal and retries his transaction. What happens now? <em>L1Relayer.relayFinalMessage() </em>is called by Bob with his original message, the relayer checks if this is a retry, and it is so it is allowed. It then executes <em>AttackerContract.attack()</em>, which this time does not revert, but rather calls the <em>RouterL1’s executeMessage() </em>with Alice’s withdrawal, marking it as finalized. At that point, the RouretL1 calls <em>L1Relayer.relayFinalMessage()</em>, but <strong>BOOOOM</strong>! <strong>It fails</strong>. Reentrancy guard is hit, as the original call is already inside <em>relayFinalMessage()</em>, and the call fails. But remember, Alice’s message was already marked as finalized in the <em>RouterL1</em>. It failed because of the reentrancy guard in the relayer. The inner call fails, and nothing is stolen, but when the operator tries to finalize Alice’s transaction, it hits <strong>“withdrawal already finalized”</strong>. Alice’s funds are fully bricked!</p><h4><strong>Full attack flow:</strong></h4><p><strong>Preparation — Bob sets the messages and protocols for the attack</strong></p><ul><li><em>Bob → malicious message → L2Relayer → L1Relayer → AttackerContract → revert</em></li><li><em>Result: </em><br><em>- failedMessages[BobMessage] = true<br>- Bob → setRevert(false)<br>- Bob → setInputForCall(Alice’s withdrawal message)</em></li></ul><p><strong>Execution — Bob retries his original transaction but with Alice’s data before Alice’s transaction is relayed</strong></p><ul><li><em>Bob → retry malicious message → L1Relayer → AttackerContract → RouterL1 → sets finalized[Alice] = true → L1Relayer → ReentrancyGuard reverts → SimpleSafeCall catches revert and returns false → RouterL1 ignores false → Bob’s transaction succeeds</em></li><li><em>Later: Alice/Operator → RouterL1 → revert with “withdrawal already finalized”</em></li></ul><h3>Conclusion</h3><p>This is not a simple reentrancy attack, it is an extremely creative attack that<br>uses the reentrancy guard to make the inner execution fail, while the simple safe call prevents that failure from rolling back the changes throughout the transaction, and the <em>RouterL1 </em>records the withdrawal as finalized. Exactly this divergence of state between contracts in bridge protocols can cause unexpected behaviors and open the path for malicious users to cause harm. Notice how everything works exactly as it is supposed to work — the relayers, the <em>RouterL1</em>, the reentrancy guard — but a vulnerability still shows up. What is also interesting in this case is the way of thinking of the attacker. We can only suppose how one comes up with such a plan to cause harm, but my suggestion is that the start of the chain of thought might be the non-reverting failed calls. Probably numerous hours were spent on finding this attack vector, but at the end it has helped us learn from it so the web3 space can be better secured.</p><p><strong><em>Full dummy protocol code &amp; tests can be found at:</em></strong></p><p><a href="https://github.com/BozhidarBonev/MediumArticlesCodeExamples/tree/master/SnailOnASlope/reentrancyGuardAsAWeapon">MediumArticlesCodeExamples/SnailOnASlope/reentrancyGuardAsAWeapon at master · BozhidarBonev/MediumArticlesCodeExamples</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f7313cf6ee79" width="1" height="1" alt=""><hr><p><a href="https://coinsbench.com/soas-ii-reentrancy-guard-as-a-weapon-f7313cf6ee79">SOAS II — Reentrancy Guard as a Weapon</a> was originally published in <a href="https://coinsbench.com/">CoinsBench</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SOAS I: The Usual Suspect]]></title>
            <link>https://coinsbench.com/soas-i-the-usual-suspect-84faedbb9605?source=rss-38a0052b4bdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/84faedbb9605</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[web3-security]]></category>
            <dc:creator><![CDATA[Bozhidar Bonev]]></dc:creator>
            <pubDate>Sun, 13 Sep 2026 12:28:15 GMT</pubDate>
            <atom:updated>2026-09-23T09:25:11.428Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Part of the series — “Snail On A Slope”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AYnsiu8TGEBekXBhrZhknQ.png" /></figure><h3><strong>Introduction</strong></h3><p>Consider a lending protocol that allows users to supply and borrow liquidity as well as perform swaps and liquidations. A pretty familiar picture in today’s web3 world. A user wants to earn some yield on his crypto so he adds the tokens as liquidity to the protocol, which takes some fees for itself and proportionally adds the user’s funds to the pool so that other operations like swaps are financed. Nothing new, nothing surprising.</p><p>In the dummy protocol we will see in this article, a very simplified reconstruction of a lending protocol, with a focus on the fee gathering mechanism on which we will explore one of the most common attacks that still haunt web3 protocols to this day. There is a substantial chance that at this very moment, when you read this sentence, someone somewhere finds a vulnerability like ours. Yes, it is that common.</p><h3><strong>Understanding The Protocol</strong></h3><p>Our protocol consists of 4 contracts:</p><ul><li><strong><em>LPT</em></strong><em> — an ERC20 token</em></li><li><strong><em>LendingProtocol</em></strong><em> — main lending operations contract</em></li><li><strong><em>ActionVault</em></strong><em> — contract for privileged functions concerning fees and liquidity allocations</em></li><li><strong><em>ActionRouter</em></strong><em> — A simple controller holding the inner logic for all sorts of operations</em></li></ul><p>The main entry point for users is the <em>LendingProtocol</em>, which exposes the <em>supply() </em>function through which the user’s tokens are transferred to and kept by the contract, his liquidity is recorded and fees are charged.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/735714d053ab15a6285d5bc444a09fcf/href">https://medium.com/media/735714d053ab15a6285d5bc444a09fcf/href</a></iframe><p>Fees are defined as 1% of the total added liquidity for simplicity and a <em>claimFees()</em> function is defined as the fee is kept inside the contract and has to exit it when swept by protocol operator. At the supply function, the fee is charged in original supply token sent by user and only later when collected is converted to <em>LPT</em>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b5839057fecb06b76cec4bf48f3f27f3/href">https://medium.com/media/b5839057fecb06b76cec4bf48f3f27f3/href</a></iframe><p>The most simple of examples, it is an ERC20 token that the protocol uses as its own internal token.</p><p>The <em>ActionVault </em>contract consists of functionality regarding the collection of fees. It exposes an external <em>sweepFeesAndTransfer() </em>function guarded by a modifier so that only protocol operator can call it and collect the fees.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6b13635dce55a59e19906f6757adf135/href">https://medium.com/media/6b13635dce55a59e19906f6757adf135/href</a></iframe><p>And the last contract in our protocol is the <em>ActionRouter</em>, which is responsible for the internal logic of whitelisting tokens for example, moving funds between the <em>LendingProtocol </em>and <em>ActionVault </em>as well as connect them to or itself perform swap logic.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b4ae2eb68e13e1260486514895b8fac5/href">https://medium.com/media/b4ae2eb68e13e1260486514895b8fac5/href</a></iframe><h3><strong>The Attack — The Ususal (Front-running) Suspect</strong></h3><p>Through normal operations a random user Alice supplies liquidity to the protocol, let’s say 10 000 DAI token, and the <em>supply() </em>function in <em>LendingProtocol </em>records the input amount as well as the 1% fee, which is 100 DAI in this case. Alice’s liquidity is also kept in this contract until some other operations move it or in a real protocol it is placed in a pool. When fees accumulate, the protocol fee operator has the responsibility to gather them in an external contract or wallet. Our operator first calls <em>sweepFeesAndTransfer()</em> in <em>ActionVault</em>, which in its turn calls the <em>ActionRouter </em>to sweep the fees. Balance of the vault is recorded before and after the swap to determine if there is anything at all to sweep and transfer to the operator. Important to remember is that the vault assumes the increase in the balance is caused by the call to the router but that may not be the case. After that the <em>ActionRouter </em>receives the call and executes the sweep by going through the tokens that need to be swept, checking if they are whitelisted and claiming the recorded fees from the <em>LendingProtocol</em>. The fees are then swapped to the protocol native <em>LPT </em>token and sent to the <em>ActionVault</em>, which at the end has the responsibility to send them to the operator.</p><p><strong><em>Fee Operator</em></strong><br><strong> |</strong><br><strong>|</strong> <em>sweepFeesAndTransfer()<br></em><strong>|<br>-&gt; <em>ActionVault</em></strong><br><strong>|</strong><br><strong>|</strong> <em>sweepFees()</em><br><strong>|<br>-&gt; <em>ActionRouter</em></strong><br><strong>|</strong><br><strong>|</strong> <em>claimFees()</em><br><strong>|<br>-&gt; <em>LendingProtocol</em></strong></p><p>The problem arising here is that important functions are publicly exposed and that opens a path such that operations can go sideways instead through the normal way. The devil is in the details in this case too as the <em>sweepFees()</em> function in the router is exposed to anyone that wants to call it, which triggers interesting chain of events. An attacker can observe for an incoming transaction from the operator to sweep the fees and front-run it by calling directly the <em>sweepFees() </em>in the router. By doing that, the fees get swept from the <em>LendingProtocol</em>, swapped to <em>LPT </em>and sent to the <em>ActionVault</em>. Then when the operator tries to sweep the fees, the <em>ActionVault </em>already holds them and records a <em>beforeBalance </em>equal to <em>afterBalance </em>causing a net of 0, which skips the transfer and the result is fees stranded in the vault as no other path exists to recover them.</p><h4>Attack Flow:</h4><p><strong>Chain of events:</strong></p><ul><li>Alice calls <em>supply() </em>and fees are recorded</li><li>Operator submits transaction to <em>ActionVault.sweepFeesAndTransfer()</em></li><li>Attacker front-runs by calling <em>ActionRouter.sweepFees()</em></li><li><em>LendingProtocol.claimFees() </em>sends the fees to router</li><li>Router swaps them</li><li>Router sends the <em>LPT </em>fees to vault</li><li>Operator transaction is executed</li><li><em>beforeBalance </em>in <em>ActionVault </em>already includes the existing fees</li><li><em>actionRouter.sweepFees() </em>does nothing as the fees are already swept</li><li><em>afterBalance </em>records same value as <em>beforeBalance </em>so net difference is 0</li><li>transfer is skipped and 0 is returned</li></ul><p><strong>Example:</strong></p><ol><li>Alice supplies 10,000 DAI</li><li>100 DAI goes to fees</li><li>Operator tries to call <em>ActionVault.sweepFeesAndTransfer()</em></li><li>Attacker sees transaction and front-runs by calling <em>ActionRouter.sweepFees()</em></li><li><em>LPT </em>fees (100 DAI) are moved to ActionVault</li><li>Operator call is executed and succeeds without moving any funds</li><li>The attacker didn’t profit but instead harmed the accounting flow</li></ol><h3><strong>Conclusion</strong></h3><p>I give you that this is a classic example, a cliché if you want, but this is an everyday bug found in both bounties, contests and private audits. All the functions perform exactly as they should but the exact order in which they are called or allowed to be called can cause not just a big but a repeatable harm to the protocol. This kind of “old” bugs go below the radar as we think of them as too trivial and sometimes we don’t pay enough attention to those common and easy to spot patterns. We sometimes think that it is too easy or that it just can’t be omitted by the developers. Well, it is and will always be the usual suspect, so we better keep watching for it.</p><p><strong><em>Full dummy protocol code &amp; tests can be found at:</em></strong></p><p><a href="https://github.com/BozhidarBonev/MediumArticlesCodeExamples/tree/master/SnailOnASlope/theUsualSuspect">MediumArticlesCodeExamples/SnailOnASlope/theUsualSuspect at master · BozhidarBonev/MediumArticlesCodeExamples</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=84faedbb9605" width="1" height="1" alt=""><hr><p><a href="https://coinsbench.com/soas-i-the-usual-suspect-84faedbb9605">SOAS I: The Usual Suspect</a> was originally published in <a href="https://coinsbench.com/">CoinsBench</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Snail On A Slope]]></title>
            <link>https://coinsbench.com/snail-on-a-slope-1633b867ea22?source=rss-38a0052b4bdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/1633b867ea22</guid>
            <category><![CDATA[web3-security]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Bozhidar Bonev]]></dc:creator>
            <pubDate>Sun, 13 Sep 2026 10:29:15 GMT</pubDate>
            <atom:updated>2026-09-23T09:25:21.802Z</atom:updated>
            <content:encoded><![CDATA[<p>Welcome to the Slope, ser!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AYnsiu8TGEBekXBhrZhknQ.png" /></figure><p>In this series of articles we are going to embark on a journey through the world of blockchain security by exploring the two opposing universes — developers &amp; attackers. The structured world of developers so full of confidence, rules, best practices and thorough testing will be juxtaposed with the chaotic, ruthless, sly and creative world of the attackers. We are going to see some common attacks, which are still often neglected by the protocols, as well as some very interesting examples that only a human can come up with and catch. We will be the snails on the slope, slowly climbing up to understand where, how and why different protocols fail, with the goal to learn, write better code and secure the Web3 space. I hope this research is as useful to you as it was to me. So let’s fucking go!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1633b867ea22" width="1" height="1" alt=""><hr><p><a href="https://coinsbench.com/snail-on-a-slope-1633b867ea22">Snail On A Slope</a> was originally published in <a href="https://coinsbench.com/">CoinsBench</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>