<?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 Sponge on Medium]]></title>
        <description><![CDATA[Stories by Sponge on Medium]]></description>
        <link>https://medium.com/@sponge242?source=rss-7487fec099dd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*9k6zQLWoN5yYbBzj</url>
            <title>Stories by Sponge on Medium</title>
            <link>https://medium.com/@sponge242?source=rss-7487fec099dd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 23:17:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sponge242/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[Chainlink — Smart Contract Vulnerability Labeling 101]]></title>
            <link>https://blog.onesavie.com/chainlink-smart-contract-vulnerability-labeling-101-b20674e1093d?source=rss-7487fec099dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/b20674e1093d</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[kaggle]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Sponge]]></dc:creator>
            <pubDate>Fri, 30 Jan 2026 06:06:19 GMT</pubDate>
            <atom:updated>2026-02-01T12:52:44.493Z</atom:updated>
            <content:encoded><![CDATA[<h3>Chainlink — Smart Contract Vulnerability Labeling 101</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qwSJsSGekDZ63shWOYvmwg.png" /></figure><h3>What is Chainlink Oracle?</h3><p>Chainlink is a oracle network designed to securely bring off-chain data, such as token market prices, into on-chain smart contracts. As a critical infrastructure component for price discovery in DeFi, the security of its integration directly dictates the robustness of the entire protocol.</p><p>This article summarizes 3 common issues in Chainlink integration identified in past audits, providing guidance for developers to handle them carefully during implementation:</p><ol><li>Stale Values</li><li>Not Checking For Down L2 Sequencer</li><li>Deprecated Library</li></ol><h3>1. Stale Value</h3><p>Chainlink price feeds do not update prices continuously. Instead, prices are updated only after a fixed time interval (heartbeat) or when the price changes beyond a certain threshold. This means the returned price may sometimes be outdated.</p><p>It is worth noting that some integrations rely on latestRoundData() only for the returned price, without validating the associated metadata such as updatedAt, which indicates when the price was last updated.</p><p>Using stale prices can be dangerous. If a price feed is delayed due to network issues or oracle failures, a contract may operate on prices that no longer reflect the real market. Attackers can exploit this gap to borrow assets, manipulate valuations, or trigger unfair liquidations.</p><p>The following example shows a vulnerable pattern that does not verify whether the price is fresh:</p><pre>(, int256 price, , , ) = priceFeed.latestRoundData();<br>return uint256(price);</pre><p>It is recommended to validate both the freshness and the validity of oracle data by checking the updatedAt parameter returned from latestRoundData() , comparing it to a staleness threshold, and ensuring that the reported price is reasonable.</p><pre>(, int256 price, , uint256 updatedAt, ) = priceFeed.latestRoundData();<br><br>if (updatedAt &lt; block.timestamp - 60 * 60 /* 1 hour */ ) {<br>    revert(&quot;stale price feed&quot;);<br>}<br><br>require(price &gt; 0, &quot;negative price&quot;);<br>return uint256(price);</pre><p>The staleness threshold should be chosen based on the heartbeat configuration of the specific Chainlink price feed. Developers should refer to the official Chainlink documentation to select an appropriate value.</p><p>Similar findings: <a href="https://github.com/code-423n4/2021-12-perennial-findings/issues/24">1</a>, <a href="https://github.com/code-423n4/2022-04-phuture-findings/issues/1">2</a>, <a href="https://github.com/code-423n4/2022-12-tigris-findings/issues/655">3</a>, <a href="https://github.com/code-423n4/2022-01-yield-findings/issues/136">4</a></p><h3>2. Not Checking For Down L2 Sequencer</h3><p>On Layer 2 networks such as Arbitrum and Optimism, Chainlink price feeds rely on an L2 sequencer to deliver data. If the sequencer goes offline, price updates may stop even though block timestamps continue to move forward. This can cause oracle prices to appear fresh while actually being stale.</p><p>If a smart contract does not check <strong>the L2 Sequencer Uptime Data Feed</strong> before using price data, it may unknowingly rely on outdated information. This can lead to incorrect asset valuations, unsafe borrowing limits, or improper liquidations.</p><p>For this reason, when latestRoundData() is used on L2 networks, it is generally recommended to verify that the sequencer is active before trusting the reported price.</p><p>Here is a simple example:</p><pre>function checkSequencer() public view {<br>    (, int256 answer, uint256 startedAt, ,) = sequencerUptimeFeed.latestRoundData();<br><br>    // Answer == 0: Sequencer is up<br>    // Answer == 1: Sequencer is down<br>    bool isSequencerUp = answer == 0;<br>    if (!isSequencerUp) {<br>      revert SequencerDown();<br>    }<br><br>    // Make sure the grace period has passed after the<br>    // sequencer is back up.<br>    uint256 timeSinceUp = block.timestamp - startedAt;<br>    if (timeSinceUp &lt;= GRACE_PERIOD) {<br>        revert(&quot;Grace period not over&quot;);<br>    }<br>}</pre><p>You can review Chainlink docs on <a href="https://docs.chain.link/data-feeds/l2-sequencer-feeds#overview">L2 Sequencer Uptime Feeds</a> for more details.</p><p>Similar findings: <a href="https://github.com/sherlock-audit/2023-12-flatmoney-judging/issues/234">1</a>, <a href="https://github.com/sherlock-audit/2023-02-bond-judging/issues/1">2</a>, <a href="https://github.com/sherlock-audit/2022-11-sentiment-judging/issues/3">3</a>, <a href="https://github.com/sherlock-audit/2023-04-blueberry-judging/issues/142">4</a></p><h3>3. Deprecated Library</h3><p>In some cases, legacy functions like latestAnswer are used rather than the current standard latestRoundData. These deprecated functions lack critical metadata and therefore often result in silent failures, where the contract continues to execute with incorrect or zero values instead of reverting during an oracle malfunction.</p><p>As these libraries are no longer maintained, they leave the contract vulnerable to breaking during future oracle upgrades. For this reason, the use of legacy oracle interfaces is commonly highlighted in audit reports as a potential risk, and migrating to latestRoundData is generally recommended to provide the necessary data for proper oracle checks.</p><p>Similar findings: <a href="https://github.com/code-423n4/2022-04-jpegd-findings/issues/4">1</a>, <a href="https://github.com/code-423n4/2021-09-wildcredit-findings/issues/55">2</a>, <a href="https://github.com/code-423n4/2022-05-bunker-findings/issues/1">3</a>, <a href="https://github.com/code-423n4/2024-07-loopfi-findings/issues/235">4</a></p><h3>Cited Resources for Learning</h3><ul><li><a href="https://medium.com/cyfrin/chainlink-oracle-defi-attacks-93b6cb6541bf#99af">Chainlink Oracle Security Considerations</a></li><li><a href="https://www.cyfrin.io/blog/price-oracle-manipulation-attacks-with-examples">Price Oracle Manipulation Attacks — The Full Guide</a></li><li><a href="https://chain.link/education-hub/oracle-problem">The Blockchain Oracle Problem</a></li></ul><h3>What’s Next?</h3><p>As part of our ongoing work on smart contract security, we’ll be hosting a Kaggle competition starting on<strong> April 1, 2026</strong>, <a href="https://www.linkedin.com/posts/onesavie-lab_ethereum-smartcontracts-web3security-activity-7403633083243294720-nwZr/?utm_source=share&amp;utm_medium=member_desktop&amp;rcm=ACoAAFcGPscBaYRf-pnkXiGtjFRpvT3BZVTwOYE">sponsored by Ethereum Foundation’s Ecosystem Support Program (ESP)</a>.</p><p>More details are available on <a href="https://onesavielabs.github.io/Bastet_Kaggle_Website/">our website</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b20674e1093d" width="1" height="1" alt=""><hr><p><a href="https://blog.onesavie.com/chainlink-smart-contract-vulnerability-labeling-101-b20674e1093d">Chainlink — Smart Contract Vulnerability Labeling 101</a> was originally published in <a href="https://blog.onesavie.com/">OneSavie Lab</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reentrancy — Smart Contract Vulnerability Labeling 101]]></title>
            <link>https://blog.onesavie.com/reentrancy-smart-contract-vulnerability-labeling-101-3cb22286ed94?source=rss-7487fec099dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/3cb22286ed94</guid>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[kaggle]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Sponge]]></dc:creator>
            <pubDate>Mon, 26 Jan 2026 07:06:12 GMT</pubDate>
            <atom:updated>2026-01-30T03:58:25.644Z</atom:updated>
            <content:encoded><![CDATA[<h3>Reentrancy — Smart Contract Vulnerability Labeling 101</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/0*kJSPPRCKN-Htm6cT" /></figure><h3>🛡️<strong> Understanding the “Reentrancy” Label in Smart Contract Audits</strong></h3><p>In smart contract audits, the Reentrancy label refers to vulnerabilities where a contract makes an external call before updating its internal state. This allows a malicious contract to re-enter the function and repeatedly execute sensitive operations such as withdrawals under the same state, potentially leading to the draining of the contract’s funds.</p><h3>1. Real-World Analogy</h3><p>Imagine withdrawing money at a bank counter.</p><ol><li>The clerk dispenses the cash first, but has not yet updated your account balance in the ledger.</li><li>You immediately return to the counter and request another withdrawal.</li><li>Since the ledger still indicates that you have available funds, the clerk releases additional money.</li></ol><p>If this process can be repeated before the ledger is updated, it becomes possible to withdraw an amount far exceeding the original account balance.</p><p><strong>The core issue is not the speed of the user, but incorrect state update ordering:</strong> funds are released before the internal state is updated.</p><p>In the context of smart contracts, an attacker can <strong>automatically trigger this flow</strong>, repeatedly executing the same operation and draining all available funds before the initial transaction completes its state update.</p><h3>2. Blockchain Definition</h3><p>A reentrancy attack arises from improper state-update ordering in smart contracts, where external calls are made before state changes. This flaw enables malicious contracts to re-enter vulnerable functions multiple times with stale state, leading to repeated withdrawals and severe financial losses.</p><p>A reentrancy vulnerability occurs when:</p><ul><li><strong>Contract A(attacker)</strong> requests funds from <strong>Contract B(victim)</strong>.</li><li>Before <strong>Contract B</strong> updates <strong>A</strong>’s balance, <strong>Contract A</strong> requests funds again.</li><li><strong>Contract B</strong> still believes <strong>A</strong> has enough balance and releases funds again.</li></ul><p>This interaction repeats until all funds in <strong>Contract B</strong> are drained.</p><h3>3. Core Principles &amp; Common Patterns</h3><p>While reentrancy vulnerabilities can take many forms, this section highlights two of common patterns observed in practice:</p><h4><strong>Classic Reentrancy</strong></h4><p>Classic reentrancy occurs when a contract updates its state <strong>after</strong> making an external call.</p><p>For example, if a withdrawal function sends funds to a user before reducing their balance, the user’s contract can call the withdrawal function again before the balance is updated.Since the contract still believes the user has funds, it releases money repeatedly.</p><h4>Token Callback Reentrancy (ERC777 / ERC1155)</h4><p>Some token standards introduce reentrancy risks even when developers do not explicitly write external calls. Standards such as ERC777 and ERC1155 define callback entry points, commonly referred to as <strong>hooks</strong>, where execution is transferred to user-implemented external functions.<br>These hooks are special functions that are automatically triggered when a token transfer occurs.</p><p>For example:</p><ul><li>ERC777 defines the tokensReceived hook, which is triggered when tokens are transferred using functions such as tokensToSend .</li><li>ERC1155 defines the onERC1155Received hook, which is triggered when tokens are transferred using safeTransferFrom() or safeBatchTransferFrom().</li></ul><p>When a contract receives tokens, these hooks allow the receiving contract to execute custom logic <strong>during the transfer process</strong>.</p><p>An attacker can exploit this by implementing the tokensReceived or onERC1155Received to call back into the sending contract, re-entering sensitive functions before critical state variables (such as balances) are updated.</p><p>This makes token transfers functionally equivalent to external calls, even if the source code does not contain an explicit .call() . As a result, developers must treat all token transfers involving callback-enabled standards as potential reentrancy entry points.</p><h3>4. Simplified Code Example</h3><h4>Case : Not Follow Checks-Effects-Interactions (CEI) Patterns</h4><p><strong>Vulnerable (Interactions-before-Effects)<br></strong>The balance is updated <em>after</em> the money is sent.</p><pre>function withdraw() public {<br>    uint amount = balances[msg.sender];<br>    require(amount &gt; 0);<br><br>    // VULNERABILITY: External call happens BEFORE the balance is zeroed<br>    (bool success, ) = msg.sender.call{value: amount}(&quot;&quot;);<br>    require(success);<br><br>    balances[msg.sender] = 0; // This line is never reached during the attack loop<br>}</pre><p><strong>Fixed (Checks-Effects-Interactions Pattern)<br></strong>The state is updated <em>before</em> any external interaction occurs.</p><pre>function withdraw() public {<br>    // Check<br>    uint amount = balances[msg.sender];<br>    require(amount &gt; 0); <br><br>    // FIX: Update the state FIRST (Effect)<br>    balances[msg.sender] = 0;<br>    <br>    // Now if the attacker tries to re-enter, their balance is already 0 (Interaction)<br>    (bool success, ) = msg.sender.call{value: amount}(&quot;&quot;);<br>    require(success);<br>}</pre><h3>5. Inspiration for Data Scientists (Feature Engineering)</h3><p>When building models to detect Reentrancy, focus on these features:</p><h4><strong>Checks-Effects-Interactions (CEI) Patterns:</strong></h4><p>Most reentrancy vulnerabilities arise from violations of the CEI pattern, which requires functions to:</p><ol><li><strong>Checks:</strong> Validate all conditions (e.g., permissions, balances).</li><li><strong>Effects:</strong> Update all internal state variables (e.g., reduce balances, mark flags).</li><li><strong>Interactions:</strong> Only then perform external calls (e.g., sending funds or invoking other contracts).</li></ol><p>This ordering ensures that once an external interaction occurs, the contract’s internal state already reflects the latest and correct information, leaving no opportunity for outdated state to be exploited.</p><p>As a result, focus on functions that handle payouts or update accounting state, such as balance reductions or credit increases. These functions must update critical state <strong>before</strong> making any external calls.</p><h4>NonReentrant Modifier</h4><p>Developers often use execution guards implemented as modifiers, such as OpenZeppelin’s nonReentrant, to prevent reentrant control flow.These modifiers can block direct recursive calls, but they do not guarantee correct state ordering.</p><p>If a function is protected by a nonReentrant modifier, performing external interactions before updating critical state may still result in reentrancy vulnerabilities through indirect or cross-function call paths. (See the <a href="https://ackee.xyz/blog/cross-function-reentrancy-attack/"><strong>Cross Function Reentrancy Attack</strong></a>)</p><p>Therefore, even with reentrancy guards in place, following the CEI pattern is still necessary.</p><h4><strong>External Call</strong></h4><p>When detecting external calls, check for patterns such as .call() and token-related functions like safeTransfer and safeTransferFrom, as they may transfer execution control to external contracts.</p><p>From a feature engineering perspective, these functions should all be treated as potential reentrancy entry points, especially when they appear in asset-transfer paths before critical state updates such as balance reductions or accounting changes.</p><h3>6. Cited Resources for Learning</h3><ul><li><a href="https://swcregistry.io/docs/SWC-107"><strong>SWC-107</strong></a><strong>:</strong> The official Smart Contract Weakness Classification for Reentrancy.</li><li><a href="https://consensysdiligence.github.io/smart-contract-best-practices/attacks/reentrancy/"><strong>ConsenSys Diligence — Reentrancy</strong></a><strong>:</strong> A deep dive into the Checks-Effects-Interactions pattern.</li><li><a href="https://cosimo.gitbook.io/ethereum-security/smart-contract-weaknesses/reentrancy"><strong>Sigma Prime — Solidity Security</strong></a><strong>:</strong> Excellent technical breakdown of multiple reentrancy types.</li><li><a href="https://github.com/crytic/slither"><strong>Trail of Bits — Slither Detectors</strong></a><strong>:</strong> Documentation on how static analysis tools programmatically flag this bug.</li><li><a href="https://ackee.xyz/blog/cross-function-reentrancy-attack/"><strong>Cross Function Reentrancy Attack</strong></a> : A deep dive into the cross function reentrancy attack.</li></ul><h3>7. Real-World Case Studies</h3><h4>Case A: The DAO Hack ($60+ Million Stolen)</h4><ul><li><strong>Background</strong><br>In 2016, The DAO, one of the earliest decentralized investment funds on Ethereum, was exploited shortly after its launch.</li><li><strong>The Bug</strong><br>The withdrawal function sent Ether to the user <strong>before</strong> updating the user’s internal balance.<br>An attacker used a malicious fallback function to repeatedly re-enter the withdrawal logic before the balance was updated.</li><li><strong>The Reentrancy Outcome</strong><br>The attacker was able to drain approximately <strong>3.6 million ETH</strong> (worth over <strong>$60 million USD at the time</strong>).</li><li><strong>Data Insight</strong><br>This is a <strong>Classic Reentrancy Attack</strong>.<br>State updates occurred <strong>after</strong> external calls, violating the Checks-Effects-Interactions pattern.</li></ul><h4>Case B: Cream Finance Reentrancy Exploit ($18 Million Stolen)</h4><ul><li><strong>Background</strong><br>In 2021, Cream Finance experienced multiple attacks, one of which involved reentrancy vulnerability combined with flash loans.<br>The incident stemmed from a reentrancy vulnerability triggered during the <strong>borrow execution flow</strong>, involving <strong>AMP</strong>, a token with <strong>ERC777-like callback behavior</strong>.</li><li><strong>The Bug</strong><br>AMP’s transfer mechanism allowed attacker-controlled callbacks, enabling execution to re-enter the protocol <strong>before critical accounting state was updated</strong>.<br>Using the tokensReceived() callback, the attacker re-entered the borrow() logic recursively.</li><li><strong>The Reentrancy Outcome</strong><br>Attackers finally drained approximately <strong>$18 million USD</strong>.</li><li><strong>Data Insight</strong><br>This is a <strong>Token Callback Reentrancy attack</strong>.<br>External token callbacks were triggered before the borrowing accounting state was fully finalized, allowing reentrant execution under partially updated protocol state.</li></ul><h3>What’s Next?</h3><p>As part of our ongoing work on smart contract security, we’ll be hosting a Kaggle competition starting on<strong> April 1, 2026</strong>, <a href="https://www.linkedin.com/posts/onesavie-lab_ethereum-smartcontracts-web3security-activity-7403633083243294720-nwZr/?utm_source=share&amp;utm_medium=member_desktop&amp;rcm=ACoAAFcGPscBaYRf-pnkXiGtjFRpvT3BZVTwOYE">sponsored by Ethereum Foundation’s Ecosystem Support Program (ESP)</a>.</p><p>More details are available on <a href="https://onesavielabs.github.io/Bastet_Kaggle_Website/">our website</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3cb22286ed94" width="1" height="1" alt=""><hr><p><a href="https://blog.onesavie.com/reentrancy-smart-contract-vulnerability-labeling-101-3cb22286ed94">Reentrancy — Smart Contract Vulnerability Labeling 101</a> was originally published in <a href="https://blog.onesavie.com/">OneSavie Lab</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>