<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: rim dinov</title>
    <description>The latest articles on DEV Community by rim dinov (@rdin777).</description>
    <link>https://dev.to/rdin777</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3816563%2F096b32fe-8ebb-4541-8e37-d43856cb987e.png</url>
      <title>DEV Community: rim dinov</title>
      <link>https://dev.to/rdin777</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rdin777"/>
    <language>en</language>
    <item>
      <title>How Aave V4’s "Design Choice" Turned Into a $195M Liquidation Deadlock (KelpDAO/rsETH Case)</title>
      <dc:creator>rim dinov</dc:creator>
      <pubDate>Tue, 21 Apr 2026 09:00:08 +0000</pubDate>
      <link>https://dev.to/rdin777/how-aave-v4s-design-choice-turned-into-a-195m-liquidation-deadlock-kelpdaorseth-case-57kk</link>
      <guid>https://dev.to/rdin777/how-aave-v4s-design-choice-turned-into-a-195m-liquidation-deadlock-kelpdaorseth-case-57kk</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Filtkyq7ofvgmw63v76b1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Filtkyq7ofvgmw63v76b1.png" alt=" " width="800" height="436"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Intro&lt;br&gt;
Two months ago, while auditing Aave V4, I discovered a critical DoS vector in their core math library. I reported it, expecting a fix. The response? "This is intended design. Not a bug."&lt;/p&gt;

&lt;p&gt;Fast forward to April 2026: The KelpDAO/rsETH exploit happens. Lazarus Group dumps massive amounts of rsETH into Aave as collateral. When the price crashes, liquidators try to step in, but the protocol hits a wall. The exact wall I warned them about.&lt;/p&gt;

&lt;p&gt;The Technical "Feature"&lt;br&gt;
The issue lies in MathUtils.sol and how it handles the mulDivDown function. In Aave V4, the liquidation bonus is dynamic. It uses a formula that calculates the bonus based on the position's Health Factor.&lt;/p&gt;

&lt;p&gt;Solidity&lt;br&gt;
// src/spoke/libraries/LiquidationLogic.sol:329&lt;br&gt;
(maxLiquidationBonus - minLiquidationBonus).mulDivDown(deltaHealth, range)&lt;br&gt;
The mulDivDown implementation uses a strict intermediate overflow check in assembly. While "safe" in theory, it’s a ticking time bomb for high-precision LSTs (Liquid Staking Tokens) like rsETH.&lt;/p&gt;

&lt;p&gt;Why "Design" Failed Reality&lt;br&gt;
When the position size is massive (like the $293M rsETH position), the intermediate product of (deltaBonus * deltaHealth) exceeds 2 &lt;br&gt;
256&lt;br&gt;
 −1.&lt;/p&gt;

&lt;p&gt;Aave's "design" was to revert on such overflows. But in a liquidation scenario, a revert is a death sentence.&lt;/p&gt;

&lt;p&gt;The liquidator calls executeLiquidation.&lt;/p&gt;

&lt;p&gt;The contract calculates the bonus.&lt;/p&gt;

&lt;p&gt;The math overflows and triggers a revert.&lt;/p&gt;

&lt;p&gt;The transaction fails.&lt;/p&gt;

&lt;p&gt;The bad debt stays on the books.&lt;/p&gt;

&lt;p&gt;The Proof&lt;br&gt;
I’ve published a full Post-Mortem and PoC on my GitHub: rdin777/aave-v4-post-mortem&lt;/p&gt;

&lt;p&gt;In the PoC, I simulated the exact conditions of the rsETH crash. The result? Liquidation logic is completely blocked. The protocol "saw" the debt (as my tests on PositionStatusMap confirmed), but its "eyes" were useless because its "hands" (the math) were tied.&lt;/p&gt;

&lt;p&gt;Lessons Learned&lt;br&gt;
When a security researcher points to a revert in a critical path (like liquidation), "it's by design" is a dangerous answer. In DeFi, availability is as important as correctness. If your math is too "perfect" to handle extreme market conditions, the protocol fails exactly when it's needed most.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/rdin777" rel="noopener noreferrer"&gt;https://github.com/rdin777&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/rdin777/aave-v4-post-mortem" rel="noopener noreferrer"&gt;https://github.com/rdin777/aave-v4-post-mortem&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;#blockchain, #security, #ethereum, #solidity&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8a2oe4p8zpfyqz69f52n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8a2oe4p8zpfyqz69f52n.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmpdii655ko2y84l13x2x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmpdii655ko2y84l13x2x.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>blockchain</category>
      <category>ethereum</category>
      <category>security</category>
      <category>web3</category>
    </item>
    <item>
      <title>How I Mastered Foundry and Earned My 101 Badge: A Journey into Web3 Security</title>
      <dc:creator>rim dinov</dc:creator>
      <pubDate>Mon, 20 Apr 2026 09:36:30 +0000</pubDate>
      <link>https://dev.to/rdin777/how-i-mastered-foundry-and-earned-my-101-badge-a-journey-into-web3-security-38bg</link>
      <guid>https://dev.to/rdin777/how-i-mastered-foundry-and-earned-my-101-badge-a-journey-into-web3-security-38bg</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuq2gtthvddq8dacbbqfe.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuq2gtthvddq8dacbbqfe.PNG" alt=" " width="765" height="505"&gt;&lt;/a&gt;&lt;br&gt;
The world of smart contracts is unforgiving. As a Web3 Security Researcher operating under the handle rdin777, I’ve always known that manual code review is only half the battle. To truly understand a protocol’s vulnerabilities, you need to master the tools that allow you to simulate attacks, manipulate state, and debug at the opcode level.&lt;/p&gt;

&lt;p&gt;Today, I’m proud to share that I’ve officially completed the Foundry Fundamentals course on Cyfrin Updraft! 🛠️&lt;/p&gt;

&lt;p&gt;Why Foundry?&lt;br&gt;
Coming from a security background, I needed a framework that was fast, robust, and written in Solidity. Foundry’s ability to run tests in a local environment while mimicking real-world conditions is a game-changer.&lt;/p&gt;

&lt;p&gt;Throughout 122 lessons, I dived deep into:&lt;/p&gt;

&lt;p&gt;Advanced Testing: Implementing the Arrange-Act-Assert pattern for complex DeFi logic.&lt;/p&gt;

&lt;p&gt;Cheatcodes: Mastering vm.prank, vm.warp, and vm.deal to manipulate blockchain state like a god.&lt;/p&gt;

&lt;p&gt;Mainnet Forking: Testing how my code interacts with real deployed systems without spending a cent in gas.&lt;/p&gt;

&lt;p&gt;EVM Opcodes: Stepping through transactions with forge test --debug to see exactly what’s happening under the hood.&lt;/p&gt;

&lt;p&gt;From Learning to Practice&lt;br&gt;
I don't believe in theory without practice. While finishing this course, I was already applying these methodologies to my latest audit: Starknet Staking Audit.&lt;/p&gt;

&lt;p&gt;Even though Starknet uses Cairo, the mental framework of rigorous testing and edge-case analysis I learned in Foundry is universal. Whether it's Solidity or Cairo, the goal remains the same: Zero-vulnerability code.&lt;/p&gt;

&lt;p&gt;The "93% Struggle"&lt;br&gt;
A quick tip for my fellow students on Updraft: If you find yourself stuck at 93% completion even with all green checkmarks—double-check every single "Mark as Complete" button! It takes discipline to cross the finish line, but the 100% mark is worth it.&lt;/p&gt;

&lt;p&gt;What’s Next?&lt;br&gt;
This badge is just the beginning. My next milestone is deep-diving into Smart Contract Security &amp;amp; Auditing. I'll be spending the coming weeks breaking down complex protocols and finding the "unfindable" bugs.&lt;/p&gt;

&lt;p&gt;Check out my verified achievement here: &lt;a href="https://profiles.cyfrin.io/u/rdin35051/achievements/foundry" rel="noopener noreferrer"&gt;https://profiles.cyfrin.io/u/rdin35051/achievements/foundry&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's connect!&lt;/p&gt;

&lt;p&gt;GitHub: rdin777&lt;/p&gt;

&lt;p&gt;Warpcast: &lt;a class="mentioned-user" href="https://dev.to/rdin777"&gt;@rdin777&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  web3 #solidity #blockchain #ethereum #cybersecurity #foundry #smartcontracts
&lt;/h1&gt;

</description>
      <category>blockchain</category>
      <category>security</category>
      <category>testing</category>
      <category>web3</category>
    </item>
    <item>
      <title>How I Broke my Starknet Staking Contract with Simple Math: A Lesson on Rounding Errors</title>
      <dc:creator>rim dinov</dc:creator>
      <pubDate>Sun, 19 Apr 2026 11:38:27 +0000</pubDate>
      <link>https://dev.to/rdin777/how-i-broke-my-starknet-staking-contract-with-simple-math-a-lesson-on-rounding-errors-50ob</link>
      <guid>https://dev.to/rdin777/how-i-broke-my-starknet-staking-contract-with-simple-math-a-lesson-on-rounding-errors-50ob</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg5x5tdbs6wd2iea8iqzp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg5x5tdbs6wd2iea8iqzp.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Every smart contract developer knows that floating-point numbers don't exist in Solidity or Cairo. We use integers. But knowing it and feeling the consequences are two different things.&lt;/p&gt;

&lt;p&gt;In my recent security research on a Starknet staking protocol, I implemented a vulnerability that is so simple, yet so devastating: The "Division Before Multiplication" Bug.&lt;br&gt;
The Vulnerable LogicImagine a standard staking reward formula. You want to calculate the reward increase based on time, a reward rate, and the total supply of staked tokens. To maintain precision, we use a multiplier (like $10^{18}$).Here is the line of code that caused the "ghost rewards" issue:&lt;br&gt;
// ⚠️ VULNERABLE CODE&lt;br&gt;
let reward_increase = (duration * rate) / supply * 1_000_000_000_000_000_000;&lt;br&gt;
At first glance, it looks fine. We calculate the rate per time, divide by supply, and scale it up. Wrong.&lt;br&gt;
Why It BreaksIn integer-based languages like Cairo, division is performed first. If (duration * rate) is smaller than supply, the result of the division is exactly 0.Even if you multiply that 0 by a quintillion ($10^{18}$), it remains 0. The rewards for your users simply vanish into the void.&lt;br&gt;
Proving the Flaw (PoC)&lt;br&gt;
To confirm this, I wrote a Proof of Concept using Starknet Foundry (snforge). I simulated a "Whale" entering the pool with a large supply, making the denominator huge.&lt;/p&gt;

&lt;h1&gt;
  
  
  [test]
&lt;/h1&gt;

&lt;p&gt;fn test_math_precision_loss() {&lt;br&gt;
    let duration: u256 = 100; &lt;br&gt;
    let rate: u256 = 10000;&lt;br&gt;&lt;br&gt;
    let supply: u256 = 1_000_000_000_000_000_000_000; // 1000 tokens&lt;br&gt;
    let precision: u256 = 1_000_000_000_000_000_000; &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Result: (1,000,000 / 10^21) = 0. Then 0 * 10^18 = 0
let reward_increase = (duration * rate) / supply * precision;
assert(reward_increase == 0, 'BUG_STILL_EXISTS');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;br&gt;
The test passed, meaning the rewards were indeed lost.&lt;/p&gt;

&lt;p&gt;The Fix&lt;br&gt;
The rule is simple: Always multiply before you divide. By reordering the operations, we keep the numbers large before the division "chops off" the precision.&lt;br&gt;
// ✅ SECURE CODE&lt;br&gt;
let reward_increase = (duration * rate * 1_000_000_000_000_000_000) / supply;&lt;br&gt;
With this fix, even small rewards are captured and distributed correctly.&lt;br&gt;
Conclusion&lt;br&gt;
Precision loss is a silent killer in DeFi. One misplaced set of parentheses or a wrong order of operations can lead to frozen funds or broken incentives.&lt;/p&gt;

&lt;p&gt;You can check out my full audit and the PoC code on my GitHub: rdin777/starknet-staking_audit1&lt;/p&gt;

&lt;h1&gt;
  
  
  starknet #cairo #security #blockchain #smartcontracts
&lt;/h1&gt;

</description>
      <category>blockchain</category>
      <category>programming</category>
      <category>security</category>
      <category>web3</category>
    </item>
    <item>
      <title>Securing Starknet: Fixing Gas DoS &amp; Logic Flaws with AI-Assisted Auditing</title>
      <dc:creator>rim dinov</dc:creator>
      <pubDate>Fri, 17 Apr 2026 10:04:34 +0000</pubDate>
      <link>https://dev.to/rdin777/securing-starknet-fixing-gas-dos-logic-flaws-with-ai-assisted-auditing-2a5</link>
      <guid>https://dev.to/rdin777/securing-starknet-fixing-gas-dos-logic-flaws-with-ai-assisted-auditing-2a5</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F66noz0mhcyo8jfdw8c5j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F66noz0mhcyo8jfdw8c5j.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In my previous post, I demonstrated how an unbounded loop could lead to a 9.8M Gas DoS on Starknet. Today, I’m sharing the follow-up: how I mitigated this vulnerability and fixed a critical logic flaw—Duplicate Token Registration.&lt;/p&gt;

&lt;p&gt;🛡️ The Second Vulnerability: Identity Crisis&lt;br&gt;
While testing the Gas DoS, I realized the contract lacked a basic check: it didn't verify if a token was already registered. An attacker could spam the same token address 500 times, inflating the loop size with zero effort and minimal cost.&lt;/p&gt;

&lt;p&gt;🛠️ The Fix: Implementing a Registration Map&lt;br&gt;
To solve this, I introduced a Map to track unique assets. In Cairo, using a LegacyMap (or the modern Map) is the most gas-efficient way to handle identity checks.&lt;/p&gt;

&lt;p&gt;Updated Contract Logic:&lt;br&gt;
Rust&lt;/p&gt;

&lt;h1&gt;
  
  
  [storage]
&lt;/h1&gt;

&lt;p&gt;struct Storage {&lt;br&gt;
    btc_tokens: Map,&lt;br&gt;
    btc_tokens_count: u32,&lt;br&gt;
    token_registered: Map, // New tracking map&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;fn add_btc_token(ref self: ContractState, token: ContractAddress) {&lt;br&gt;
    // 1. Validation: Prevent duplicate entries&lt;br&gt;
    let is_registered = self.token_registered.read(token);&lt;br&gt;
    assert(!is_registered, 'Token already registered');&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// 2. State update
let count = self.btc_tokens_count.read();
self.btc_tokens.write(count, token);
self.btc_tokens_count.write(count + 1);

// 3. Mark as registered
self.token_registered.write(token, true);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;br&gt;
✅ Verification with Snforge&lt;br&gt;
Security is nothing without proof. I used snforge to write a specialized test case that expects a panic when a duplicate is added.&lt;/p&gt;

&lt;p&gt;Rust&lt;/p&gt;

&lt;h1&gt;
  
  
  [test]
&lt;/h1&gt;

&lt;h1&gt;
  
  
  [should_panic(expected: ('Token already registered', ))]
&lt;/h1&gt;

&lt;p&gt;fn test_duplicate_token_registration() {&lt;br&gt;
    // ... setup ...&lt;br&gt;
    dispatcher.add_btc_token(token_address);&lt;br&gt;
    dispatcher.add_btc_token(token_address); // This must fail&lt;br&gt;
}&lt;br&gt;
Results:&lt;/p&gt;

&lt;p&gt;All 4/4 security tests passed.&lt;/p&gt;

&lt;p&gt;The "Gas Bomb" can no longer be created using duplicate addresses.&lt;/p&gt;

&lt;p&gt;Codebase refactored to modern Cairo syntax (removing core:: internal calls).&lt;/p&gt;

&lt;p&gt;🧠 Key Takeaway for Auditors&lt;br&gt;
When auditing loops, always look for the entry point. Preventing the "inflation" of data at the storage level is just as important as optimizing the loop itself.&lt;/p&gt;

&lt;p&gt;Check out the full PoC and the fix on my GitHub: &lt;a href="https://github.com/rdin777/starknet-staking_audit1" rel="noopener noreferrer"&gt;https://github.com/rdin777/starknet-staking_audit1&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  starknet #blockchain #auditing #cairo
&lt;/h1&gt;

</description>
      <category>ai</category>
      <category>blockchain</category>
      <category>security</category>
      <category>web3</category>
    </item>
    <item>
      <title>The Starknet Challenge</title>
      <dc:creator>rim dinov</dc:creator>
      <pubDate>Fri, 17 Apr 2026 09:51:54 +0000</pubDate>
      <link>https://dev.to/rdin777/the-starknet-challenge-4b16</link>
      <guid>https://dev.to/rdin777/the-starknet-challenge-4b16</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/openclaw-2026-04-16"&gt;OpenClaw Challenge&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Built
&lt;/h2&gt;

&lt;p&gt;&amp;lt;!-- Give us an overview of your project and the problem it solves. --&amp;gt;I investigated a critical Gas DoS vulnerability in a Starknet staking contract. The issue was rooted in an unbounded loop that allowed for duplicate token registrations, eventually hitting the block gas limit. I developed a fix using a mapping-based approach to ensure O(1) complexity for token validation and successfully verified the solution with a comprehensive test suite in snforge.&lt;/p&gt;

&lt;h2&gt;
  
  
  How I Used OpenClaw
&lt;/h2&gt;

&lt;p&gt;&amp;lt;!-- Walk us through how OpenClaw powers your project. What skills, integrations, or workflows did you set up? --&amp;gt;I integrated KiloClaw as a professional security assistant to streamline my auditing workflow:&lt;br&gt;
Workflow Integration: I deployed a custom AI agent and connected it to Telegram via BotFather for real-time security briefings.&lt;/p&gt;

&lt;p&gt;Real-time Verification: I used the agent to cross-verify my findings on the Gas DoS exploit. The bot provided insights into Starknet-specific monitoring tools like Voyager and suggested custom detector patterns for my remediation plan.&lt;/p&gt;

&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;&amp;lt;!-- Share a video of your project in action - this is the best way to show off what you built. Screenshots or a project link are welcome too. --&amp;gt;GitHub Repository: rdin777/starknet-staking_audit1&lt;br&gt;
Proof of Concept: My test suite shows the transition from a failed state (9.8M gas limit hit) to a fully optimized 4/4 passing state.&lt;/p&gt;

&lt;p&gt;AI Interaction:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff88uc9zf50edt7lspi1j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff88uc9zf50edt7lspi1j.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Learned
&lt;/h2&gt;

&lt;p&gt;&amp;lt;!-- Any surprises, challenges, or key takeaways from the build? --&amp;gt;The biggest takeaway was how AI-assisted auditing can bridge the gap between manual discovery and continuous monitoring. While manual analysis identified the logic flaw, KiloClaw helped me conceptualize a long-term monitoring strategy. I also learned the nuances of pairing Telegram bots with the Kilo cloud instance, which is a game-changer for independent researchers.&lt;/p&gt;

&lt;h2&gt;
  
  
  ClawCon Michigan
&lt;/h2&gt;

&lt;p&gt;I didn't attend in person, but participating in the OpenClaw Challenge virtually has been an incredible deep dive into the future of AI-driven security!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feihaq2l039npgpj5kwru.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feihaq2l039npgpj5kwru.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzuqeo91g8dxilcapwy8k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzuqeo91g8dxilcapwy8k.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&amp;lt;!-- Thanks for participating! --&amp;gt; Thanks for participating! &lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>openclawchallenge</category>
    </item>
    <item>
      <title>Gas Bomb in Starknet: How One Unbounded Loop Can Brick Your Staking Protocol</title>
      <dc:creator>rim dinov</dc:creator>
      <pubDate>Thu, 16 Apr 2026 07:32:11 +0000</pubDate>
      <link>https://dev.to/rdin777/gas-bomb-in-starknet-how-one-unbounded-loop-can-brick-your-staking-protocol-3n5b</link>
      <guid>https://dev.to/rdin777/gas-bomb-in-starknet-how-one-unbounded-loop-can-brick-your-staking-protocol-3n5b</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz45azybov8ky90c4fxgb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz45azybov8ky90c4fxgb.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
Introduction&lt;br&gt;
Many developers migrating from Solidity to Cairo often overlook the fact that Starknet has its own unique gas limits and execution architecture. In this article, I will demonstrate how the absence of loop boundaries can transform a standard smart contract into a "gas bomb" that is impossible to defuse.&lt;/p&gt;

&lt;p&gt;The Vulnerability&lt;br&gt;
While auditing a staking protocol, I identified a classic but critical vulnerability: an Unbounded Loop. The contract maintains a list of tokens eligible for rewards, and the core logic iterates through this entire list in a single transaction.&lt;/p&gt;

&lt;p&gt;Rust&lt;br&gt;
// Simplified logic from the audited contract&lt;br&gt;
fn update_rewards(ref self: ContractState) {&lt;br&gt;
    let mut i: u32 = 0;&lt;br&gt;
    let count = self.btc_tokens_count.read();&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;while i &amp;lt; count {
    let _token = self.btc_tokens.read(i);
    // Reward calculation logic resides here...
    i += 1;
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;br&gt;
The flaw is evident: the update_rewards function has no upper bound. As the number of registered tokens grows, the gas required to execute this function increases linearly until it hits a hard limit.&lt;/p&gt;

&lt;p&gt;The Attack Scenario&lt;br&gt;
Lack of Access Control: The add_btc_token function is public, allowing any user to register a token.&lt;/p&gt;

&lt;p&gt;Storage Bloating: An attacker repeatedly calls this function, filling the storage with hundreds of dummy token addresses.&lt;/p&gt;

&lt;p&gt;Denial of Service (DoS): When a legitimate user or admin attempts to trigger update_rewards, the transaction fails consistently with an Out of Gas error.&lt;/p&gt;

&lt;p&gt;Proof of Concept (PoC)&lt;br&gt;
Using Starknet Foundry (snforge), I developed a test suite to measure the impact. The results are staggering:&lt;/p&gt;

&lt;p&gt;Token Count Gas Consumption (L2 Gas)    Status&lt;br&gt;
1 Token ~13,840 ✅ Normal&lt;br&gt;
500 Tokens  ~8,047,846  ⚠️ CRITICAL (DoS)&lt;br&gt;
Once the gas cost nears the Starknet block gas limit, the contract becomes "bricked." Users will be unable to claim rewards or withdraw their assets because the reward calculation is a mandatory prerequisite for these actions.&lt;/p&gt;

&lt;p&gt;Mitigation Strategies&lt;br&gt;
To prevent such vulnerabilities, developers should:&lt;/p&gt;

&lt;p&gt;Implement Pagination: Instead of processing the entire list, handle tokens in batches (e.g., 50 tokens per transaction).&lt;/p&gt;

&lt;p&gt;Enforce Access Control: Restrict token registration to an Owner or a DAO-governed role.&lt;/p&gt;

&lt;p&gt;Adopt a Pull-over-Push Pattern: Allow users to trigger updates for specific tokens individually rather than forcing a global state update.&lt;/p&gt;

&lt;p&gt;Conclusion&lt;br&gt;
In Web3, security is not just about preventing logic errors; it’s about understanding the constraints of the underlying infrastructure. This case serves as a reminder that gas efficiency is directly tied to protocol availability.&lt;/p&gt;

&lt;p&gt;Research and PoC developed by rdin777&lt;br&gt;
Check out the full repository here: github.com/rdin777/starknet-staking_audit1&lt;/p&gt;

&lt;h1&gt;
  
  
  Starknet, #Cairo, #SmartContractSecurity, #Blockchain, #BugBounty
&lt;/h1&gt;

</description>
      <category>blockchain</category>
      <category>rust</category>
      <category>security</category>
      <category>web3</category>
    </item>
    <item>
      <title>Starknet BTC Staking: How to Extract Rewards with Zero Collateral (And Why the Team Ignored It)</title>
      <dc:creator>rim dinov</dc:creator>
      <pubDate>Tue, 14 Apr 2026 11:07:14 +0000</pubDate>
      <link>https://dev.to/rdin777/starknet-btc-staking-how-to-extract-rewards-with-zero-collateral-and-why-the-team-ignored-it-fo</link>
      <guid>https://dev.to/rdin777/starknet-btc-staking-how-to-extract-rewards-with-zero-collateral-and-why-the-team-ignored-it-fo</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpe2govi5431ps3rahltp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpe2govi5431ps3rahltp.png" alt=" " width="800" height="449"&gt;&lt;/a&gt;&lt;br&gt;
The "AI Slop" That Bypassed Your Security&lt;br&gt;
In the world of Web3 security, the "Proof of Concept" (PoC) is the only source of truth. Recently, I discovered a critical logic bypass in the Starknet BTC Staking Attestation module. When I brought it to the team, the response was dismissive: "This looks like AI slop; we won't review it."&lt;/p&gt;

&lt;p&gt;Today, I am releasing the technical details and a public PoC to protect the ecosystem. If a vulnerability is "AI slop," then the protocol is currently being exploited by "AI" that knows how to drain its rewards.&lt;/p&gt;

&lt;p&gt;The Technical Deep Dive: The "Ghost Staking" Vulnerability&lt;br&gt;
The core of the issue lies in the Attestation.cairo contract. The protocol attempts to verify BTC staking by checking block data, but it makes a fundamental mistake in its "source of truth."&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The Insecure Root of Trust
The contract relies on get_block_hash_syscall(target_block_number) to validate proofs.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Фрагмент кода&lt;br&gt;
// Vulnerable logic snippet&lt;br&gt;
let block_hash = get_block_hash_syscall(target_block_number);&lt;br&gt;
assert(block_hash == provided_proof.block_hash, 'Invalid block proof');&lt;br&gt;
The Flaw: Block hashes are public data. Any network participant can retrieve a valid block hash and include it in a forged attestation. The contract validates that the block exists, but fails to verify that a specific transaction (the BTC deposit) belongs to the user submitting the proof.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Lack of Collateral Binding
Because the attestation logic doesn't strictly bind a unique BTC transaction to a Starknet address, an attacker can:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Monitor public BTC block data.&lt;/p&gt;

&lt;p&gt;Generate a valid-looking attestation structure using public hashes.&lt;/p&gt;

&lt;p&gt;Trigger the reward minting function without ever locking a single Satoshi.&lt;/p&gt;

&lt;p&gt;Proof of Concept (PoC)&lt;br&gt;
I have isolated the exploit in a clean environment. You can find the full code here: [Insert your GitHub Link: rdin777/starknet-staking_audit1]&lt;/p&gt;

&lt;p&gt;To reproduce the vulnerability:&lt;/p&gt;

&lt;p&gt;Run Cairo Tests:&lt;br&gt;
cd ghost_staking_audit &amp;amp;&amp;amp; snforge test tests/test_ghost_stake.cairo&lt;br&gt;
Result: The test demonstrates a user with zero collateral successfully claiming rewards.&lt;/p&gt;

&lt;p&gt;External Simulation:&lt;br&gt;
node scripts/exploit.js&lt;br&gt;
Result: This script generates the forged attestation data that bypasses the assert checks in the contract.&lt;/p&gt;

&lt;p&gt;The Disclosure Timeline&lt;br&gt;
March 21, 2026: Submitted the technical report to the team (Lotem Kahana). Dismissed as "AI-generated" without a technical audit.&lt;/p&gt;

&lt;p&gt;March 22-24, 2026: Offered private PoC walkthrough. Requested a technical review. Zero response.&lt;/p&gt;

&lt;p&gt;March 24, 2026: Public Disclosure.&lt;/p&gt;

&lt;p&gt;Conclusion&lt;br&gt;
Dismissing independent research as "AI slop" without running the provided tests is a dangerous precedent. Security is about code, not egos. The vulnerability remains unpatched in the current logic.&lt;/p&gt;

&lt;p&gt;I invite the Starknet community to review the PoC and judge for themselves.&lt;/p&gt;

&lt;p&gt;Researcher: rdin777&lt;br&gt;
Keywords: #Starknet #Cairo #SecurityAudit #L2 #Vulnerability&lt;/p&gt;

</description>
    </item>
    <item>
      <title>The "Ghost" Votes of Olas Protocol: Why Lack of Sync is a Critical Economic Flaw</title>
      <dc:creator>rim dinov</dc:creator>
      <pubDate>Fri, 10 Apr 2026 10:16:23 +0000</pubDate>
      <link>https://dev.to/rdin777/the-ghost-votes-of-olas-protocol-why-lack-of-sync-is-a-critical-economic-flaw-35h5</link>
      <guid>https://dev.to/rdin777/the-ghost-votes-of-olas-protocol-why-lack-of-sync-is-a-critical-economic-flaw-35h5</guid>
      <description>&lt;p&gt;Introduction&lt;br&gt;
In the world of DeFi and DAO governance, the voter escrowed (ve) model is a gold standard for aligning long-term incentives. Users lock their tokens, receive voting power, and decide how rewards (inflation) are distributed. But what happens when the system "forgets" that you’ve already withdrawn your tokens?&lt;/p&gt;

&lt;p&gt;In this article, I’ll break down a vulnerability I discovered in the Olas Protocol (Autonolas) during a Code4rena audit, where a lack of synchronization between core contracts allows for infinite inflation manipulation.&lt;/p&gt;

&lt;p&gt;The Architecture: A Tale of Two Contracts&lt;br&gt;
The Olas governance system relies on two main pillars:&lt;/p&gt;

&lt;p&gt;veOLAS.sol: The vault where tokens are locked and the time-weighted balance is managed.&lt;/p&gt;

&lt;p&gt;VoteWeighting.sol: The engine that calculates voting weights to determine inflation distribution across different "gauges".&lt;/p&gt;

&lt;p&gt;For the system to work, VoteWeighting must always know exactly how much power a user has.&lt;/p&gt;

&lt;p&gt;The Vulnerability: Persistent Weights after Withdrawal&lt;br&gt;
The flaw lies in the withdraw() flow. When a user's lock period ends in veOLAS.sol, they call the withdraw function to get their tokens back.&lt;/p&gt;

&lt;p&gt;The Logic Failure:&lt;/p&gt;

&lt;p&gt;veOLAS.sol successfully burns the user's lock and returns the tokens.&lt;/p&gt;

&lt;p&gt;However, it does not trigger any update or notification to VoteWeighting.sol.&lt;/p&gt;

&lt;p&gt;In VoteWeighting, the user's last recorded slope and bias (the mathematical components of voting power) remain on the books. The contract still "thinks" the user has voting power based on their old, now-deleted lock.&lt;/p&gt;

&lt;p&gt;Attack Scenario: The "Sybil Inflation" Loop&lt;br&gt;
An attacker can exploit this "ghost" voting power to capture a disproportionate share of the protocol's inflation:&lt;/p&gt;

&lt;p&gt;Lock: Attacker locks a large amount of OLAS in veOLAS for the maximum duration.&lt;/p&gt;

&lt;p&gt;Vote: They use this power in VoteWeighting to vote for a specific gauge (e.g., a pool they control).&lt;/p&gt;

&lt;p&gt;Wait &amp;amp; Withdraw: Once the lock expires, they withdraw their tokens.&lt;/p&gt;

&lt;p&gt;The Ghost Power: The attacker’s tokens are back in their wallet, but their vote in VoteWeighting is still active and counting towards reward distribution.&lt;/p&gt;

&lt;p&gt;Repeat: The attacker moves the same tokens to a new wallet and repeats the process.&lt;/p&gt;

&lt;p&gt;Result: An attacker can stack "ghost" votes from multiple expired locks to effectively take over the protocol's reward distribution mechanism.&lt;/p&gt;

&lt;p&gt;Impact &amp;amp; Final Thoughts&lt;br&gt;
While this was classified as a Low/Medium risk by some due to the specific timing required for locks, from an economic security standpoint, it’s a fundamental flaw. It breaks the "1 token = X voting power" rule.&lt;/p&gt;

&lt;p&gt;Key Takeaway for Auditors:&lt;br&gt;
Always check the "Exit" functions. If a protocol uses a multi-contract architecture for governance, ensure that every state change in the Vault is reflected in the Voting Engine.&lt;/p&gt;

&lt;p&gt;About the Author&lt;br&gt;
I am RimDinov (rdin777), a Web3 Security Researcher and Bug Bounty Hunter. I document my daily findings as I dive deeper into smart contract audits and protocol security.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/rdin777" rel="noopener noreferrer"&gt;https://github.com/rdin777&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Ethereum, #Solidity, #SmartContract, #Audit, #DeFi
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkfy28pquucgcv35i6p26.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkfy28pquucgcv35i6p26.PNG" alt=" " width="800" height="364"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>blockchain</category>
      <category>security</category>
      <category>web3</category>
    </item>
    <item>
      <title>The Bricking Point: Analyzing Permanent Fund Loss in Panoptic’s SFPM</title>
      <dc:creator>rim dinov</dc:creator>
      <pubDate>Tue, 07 Apr 2026 07:06:33 +0000</pubDate>
      <link>https://dev.to/rdin777/the-bricking-point-analyzing-permanent-fund-loss-in-panoptics-sfpm-29b8</link>
      <guid>https://dev.to/rdin777/the-bricking-point-analyzing-permanent-fund-loss-in-panoptics-sfpm-29b8</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2c3zrun1o7n5znofbdn3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2c3zrun1o7n5znofbdn3.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
Executive Summary&lt;br&gt;
During a deep-dive security analysis of the Panoptic protocol (v1.1.x), I identified a critical vulnerability within the SemiFungiblePositionManager (SFPM). The issue, which I’ve categorized as Permanent Bricking, allows for a scenario where user liquidity becomes mathematically "un-burnable." Due to precision loss and rounding discrepancies in the core math libraries, certain positions can enter a state of deadlock, resulting in a 100% loss of funds for the affected user.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Technical Context: The Role of SFPM
Panoptic is a groundbreaking protocol for perpetual options built on top of Uniswap V3. At its heart lies the SFPM, which manages Uniswap V3 liquidity positions by wrapping them into ERC-1155 tokens.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;While conducting the audit, I utilized the protocol's deployment configurations (deployment-info.json) to identify the target contract. By tracing the CREATE2 Salt (0x82bf455e9ebd6a541ef10b683de1edcaf05ce7a136f15df6a78bf60145fff15c), I was able to isolate the SFPM logic and its interaction with the broader ecosystem.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The Vulnerability: Mathematical Deadlock
The vulnerability stems from the way SFPM calculates LiquidityChunks and net shares. In DeFi, rounding is usually a minor "dust" issue, but in Panoptic's complex integration with Uniswap V3 ticks, it can become fatal.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The "Ghost Debt" Scenario:&lt;br&gt;
When a user attempts to burn a position, the contract calculates the required liquidity to be removed. If the internal accounting—affected by prior swaps or time-weighted fee accumulations—results in a required burn amount that is even 1 wei higher than the user's recorded balance (due to rounding up in the protocol's favor), the transaction triggers an Arithmetic over/underflow.&lt;/p&gt;

&lt;p&gt;Because there is no "emergency exit" or "rounding tolerance" in the burnTokenizedPosition function, the user's funds are effectively "bricked" inside the contract forever.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Proof of Concept (PoC)
To validate this, I developed a test suite using Foundry (Forge) and Solc 0.8.26. The goal was to simulate a state where a position becomes un-burnable.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Key Testing Steps:&lt;/p&gt;

&lt;p&gt;Low-Level Injection: Using vm.etch, I injected the contract bytecode at a specific test address (0x...1337) to simulate a precise deployment state.&lt;/p&gt;

&lt;p&gt;State Manipulation: Using vm.warp and vm.roll, I simulated the passage of time and block progression to trigger fee accumulation.&lt;/p&gt;

&lt;p&gt;The Revert: Attempting to interact with the position resulted in a consistent EVM Revert, as seen in the traces.&lt;/p&gt;

&lt;p&gt;Execution Trace Analysis:&lt;br&gt;
The following trace demonstrates the failure point where the EVM execution halts during a call to the bricked address:&lt;/p&gt;

&lt;p&gt;Caption: Foundry trace showing a forced Revert during the burn logic execution.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Root Cause &amp;amp; Remediation
The root cause is a lack of rounding tolerance in the liquidity accounting logic. In high-precision environments like Panoptic, strict equality or strict subtraction without buffers is dangerous.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Recommended Fixes:&lt;/p&gt;

&lt;p&gt;Implement Epsilon Tolerance: Allow for a 1-2 wei discrepancy when burning the final shares of a position.&lt;/p&gt;

&lt;p&gt;Virtual Shares: Implement a virtual share mechanism to protect against inflation-related rounding errors.&lt;/p&gt;

&lt;p&gt;Invariant Checks: Update the math libraries to ensure that rounding always favors the user's ability to exit, even if it cost the protocol a negligible amount of "dust."&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Conclusion
Complexity is the enemy of security. While the SFPM is a masterpiece of engineering, the mathematical edge cases of Uniswap V3 tick management create risks that are difficult to catch without rigorous stress testing. This discovery highlights the need for continuous auditing and formal verification of math-heavy DeFi protocols.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Researcher: Rim Dinov (&lt;a class="mentioned-user" href="https://dev.to/rdin777"&gt;@rdin777&lt;/a&gt;)&lt;br&gt;
&lt;a href="https://github.com/rdin777/Permanent-loss-of-user-funds-Panoptic" rel="noopener noreferrer"&gt;https://github.com/rdin777/Permanent-loss-of-user-funds-Panoptic&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  solidity, #security, #ethereum, #web3
&lt;/h1&gt;

</description>
      <category>blockchain</category>
      <category>ethereum</category>
      <category>security</category>
      <category>web3</category>
    </item>
    <item>
      <title>Finding a Critical Logic Flaw in Legion Protocol’s Epoch Vesting</title>
      <dc:creator>rim dinov</dc:creator>
      <pubDate>Sat, 04 Apr 2026 05:15:37 +0000</pubDate>
      <link>https://dev.to/rdin777/finding-a-critical-logic-flaw-in-legion-protocols-epoch-vesting-39g6</link>
      <guid>https://dev.to/rdin777/finding-a-critical-logic-flaw-in-legion-protocols-epoch-vesting-39g6</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe4wauowxv0z7lgwroubg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe4wauowxv0z7lgwroubg.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By RimDinov (&lt;a class="mentioned-user" href="https://dev.to/rdin777"&gt;@rdin777&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;While performing a deep-dive security audit of the Legion Protocol, I identified a critical vulnerability in their linear epoch-based vesting contract. This flaw isn't just a minor edge case — it’s a fundamental logic error that can lead to permanent loss of user funds and broken protocol invariants.&lt;/p&gt;

&lt;p&gt;In this article, I’ll break down how the vulnerability works, why the math fails, and how I built a Proof-of-Concept (PoC) using Foundry to prove it.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The Architecture: Epoch vs. Linear Vesting
Most vesting contracts use a simple linear formula based on block.timestamp. However, Legion implemented an Epoch-based approach. Tokens are unlocked in "chunks" (epochs) rather than every second.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;While this design can be useful for certain tokenomics, its implementation in LegionLinearEpochVesting.sol introduced a dangerous state dependency.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The Vulnerability: State-Dependent Vesting Math
The core issue lies in the _vestingSchedule function. Instead of being a pure function of time, the amount of vested tokens is calculated based on the global state variable s_lastClaimedEpoch.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The "Double-Claim" Trap&lt;br&gt;
Take a look at the vulnerable code snippet:&lt;/p&gt;

&lt;p&gt;Solidity&lt;br&gt;
// @notice Vulnerable calculation in LegionLinearEpochVesting.sol&lt;br&gt;
if (currentEpoch &amp;gt; s_lastClaimedEpoch) {&lt;br&gt;
    amountVested = ((currentEpoch - 1) * _totalAllocation) / s_numberOfEpochs;&lt;br&gt;
}&lt;br&gt;
The Logic Flaw: If a user (or bot) calls the release() function twice during the same epoch:&lt;br&gt;
The first time currentEpoch &amp;gt; s_lastClaimedEpoch - the transaction goes through, tokens are transferred, s_lastClaimedEpoch is updated.&lt;/p&gt;

&lt;p&gt;The second time, currentEpoch becomes EQUAL to s_lastClaimedEpoch. The if condition fails, and amountVested returns 0.&lt;/p&gt;

&lt;p&gt;In certain scenarios, this may cause the contract to consider tokens "issued" even though the user received 0.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The "Dust" Problem: Precision Loss
Another critical issue is the handling of token decimals. The contract uses a fixed 1e18 denominator (likely from a Constants.sol file) without properly scaling for tokens like USDC or USDT (6 decimals).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This causes massive rounding errors. For low-decimal tokens, a significant portion of the funds (the "dust") will remain stuck in the contract forever because the math simply truncates the value to zero.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Proof of Concept (PoC)
To verify the impact, I wrote a dedicated exploit test in Foundry. The test simulates a user trying to claim multiple times and proves that funds become inaccessible due to the epoch-tracking logic.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can find the full PoC and the audit repository here:&lt;br&gt;
👉 &lt;a href="https://github.com/rdin777/ltgion-newaudit" rel="noopener noreferrer"&gt;https://github.com/rdin777/ltgion-newaudit&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Pro-Tip: Always run your tests with forge test -vvvv to see the exact state changes during the exploit.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Mitigation: How to Fix It
To fix these issues, I recommended the following to the Legion team:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Remove State Dependency: Calculate the vested amount based strictly on block.timestamp and the totalAllocated, subtracting only the totalReleased so far.&lt;/p&gt;

&lt;p&gt;Dynamic Scaling: Use ERC20(token).decimals() to handle precision instead of hardcoded constants.&lt;/p&gt;

&lt;p&gt;Conclusion&lt;br&gt;
Smart contract security is about more than just finding reentrancy or overflow bugs. It's about understanding the business logic. Even a simple vesting contract can hide critical flaws if the state management isn't handled with extreme care.&lt;/p&gt;

&lt;p&gt;Follow me for more security deep-dives:&lt;/p&gt;

&lt;p&gt;GitHub: &lt;a href="https://github.com/rdin777" rel="noopener noreferrer"&gt;https://github.com/rdin777&lt;/a&gt;&lt;/p&gt;

</description>
      <category>blockchain</category>
      <category>security</category>
      <category>solidity</category>
      <category>testing</category>
    </item>
    <item>
      <title>Audit Speed: Hunting NFT Theft in V11 Finance (Duplicate Story) Subtitle: Why being right is only half the battle in Web3 security.</title>
      <dc:creator>rim dinov</dc:creator>
      <pubDate>Wed, 01 Apr 2026 06:24:30 +0000</pubDate>
      <link>https://dev.to/rdin777/audit-speed-hunting-nft-theft-in-v11-finance-duplicate-story-subtitle-why-being-right-is-only-4ci9</link>
      <guid>https://dev.to/rdin777/audit-speed-hunting-nft-theft-in-v11-finance-duplicate-story-subtitle-why-being-right-is-only-4ci9</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpfp9b6tziqaw5akvcisp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpfp9b6tziqaw5akvcisp.png" alt=" " width="800" height="165"&gt;&lt;/a&gt;&lt;br&gt;
Execution of the exploit in a local Foundry environment. The 'PASS' status confirms that the skim() function is indeed vulnerable to unauthorized collateral draining.&lt;/p&gt;

&lt;p&gt;🧐 Introduction&lt;br&gt;
In the fast-paced world of smart contract audits, being right is only half the battle. You also have to be first. Recently, during the V11 Finance audit on Cantina, I discovered a critical flaw that allowed anyone to drain wrapped NFT collateral.&lt;/p&gt;

&lt;p&gt;Although my finding was marked as a Duplicate of #1, the technical journey and the resulting PoC (Proof of Concept) are worth sharing.&lt;/p&gt;

&lt;p&gt;🔍 The Vulnerability: Public skim() and Untrusted Collateral&lt;br&gt;
The core of the issue was in the wrapper contract's interaction with the underlying liquidity pool.&lt;/p&gt;

&lt;p&gt;The Flaw&lt;br&gt;
The contract exposed a public skim() function. In Uniswap-style pools, skim() is used to recover tokens that are "stuck" in the contract (balance &amp;gt; reserve). However, in V7's implementation, there were no access controls or internal checks to ensure the caller was authorized to touch the "excess" tokens.&lt;/p&gt;

&lt;p&gt;The Attack Vector:&lt;br&gt;
An attacker monitors the contract holding wrapped NFT collateral.&lt;/p&gt;

&lt;p&gt;By manipulating the internal state or simply catching a moment when the balance exceeds the tracked reserve, the attacker calls skim(attackerAddress).&lt;/p&gt;

&lt;p&gt;The contract blindly transfers the excess tokens (representing NFT ownership or collateral) to the attacker.&lt;/p&gt;

&lt;p&gt;🛠 The Proof of Concept (Foundry)&lt;br&gt;
To confirm this, I wrote a custom test case: test_SkimAttack_Theft().&lt;/p&gt;

&lt;p&gt;Solidity&lt;br&gt;
function test_SkimAttack_Theft() public {&lt;br&gt;
    // 1. Setup: User deposits NFT collateral&lt;br&gt;
    vm.prank(user);&lt;br&gt;
    v7Contract.deposit(nftId);&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// 2. The Attack: Unauthorized caller triggers skim()
vm.prank(attacker);
v7Contract.skim(attacker);

// 3. Verification: Attacker now owns the collateral
assertEq(nftToken.ownerOf(nftId), attacker);
console.log("Attack Successful: Collateral Stolen!");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;br&gt;
Terminal Output:&lt;br&gt;
[PASS] test_SkimAttack_Theft() (gas: 45231)&lt;br&gt;
The test confirmed that the vulnerability was live and easily exploitable.&lt;/p&gt;

&lt;p&gt;📉 The "Duplicate" Verdict&lt;br&gt;
When I submitted the report, it was linked to Finding #1.&lt;/p&gt;

&lt;p&gt;In big contests, the most "obvious" critical bugs are often caught within the first few hours. While it's a bit disappointing to miss out on the primary reward, it’s a massive confidence booster.&lt;/p&gt;

&lt;p&gt;Lesson Learned: If you find a bug that looks "too easy," submit it immediately. Don't wait to polish the report—speed is a feature in competitive auditing.&lt;/p&gt;

&lt;p&gt;💡 Conclusion&lt;br&gt;
Even though it's a duplicate, this finding confirms that my "security radar" is calibrated to the same frequency as the top researchers in the space.&lt;/p&gt;

&lt;p&gt;Key Takeaways:&lt;/p&gt;

&lt;p&gt;Public functions are dangerous: Always ask "Who can call this?"&lt;/p&gt;

&lt;p&gt;PoC is King: Having a working Foundry test makes your report undeniable.&lt;/p&gt;

&lt;p&gt;Stay Fast: The difference between a $5k reward and a Duplicate is often just a few minutes.&lt;/p&gt;

&lt;h1&gt;
  
  
  Web3Security #Ethereum #Solidity #Audit #Cantina #V11Finance.
&lt;/h1&gt;

</description>
      <category>blockchain</category>
      <category>security</category>
      <category>solidity</category>
      <category>web3</category>
    </item>
    <item>
      <title>Precision Forensics: Reverse Engineering a DeFi Trading App via Network Analysis</title>
      <dc:creator>rim dinov</dc:creator>
      <pubDate>Mon, 30 Mar 2026 07:00:38 +0000</pubDate>
      <link>https://dev.to/rdin777/precision-forensics-reverse-engineering-a-defi-trading-app-via-network-analysis-1p3a</link>
      <guid>https://dev.to/rdin777/precision-forensics-reverse-engineering-a-defi-trading-app-via-network-analysis-1p3a</guid>
      <description>&lt;p&gt;Intro&lt;br&gt;
In the world of DeFi and automated trading, precision is everything. A single rounding error or a missing truncation logic can lead to a "death by a thousand cuts" where users lose small fractions of their funds over thousands of transactions. Today, I decided to perform a quick "Black-box" audit on a popular trading protocol's web application to see how they handle their math under the hood.&lt;/p&gt;

&lt;p&gt;The Method: No Source Code? No Problem.&lt;br&gt;
When the source code is private, a security researcher’s best friend is the Browser DevTools (Network Tab). By intercepting the communication between the Frontend and the Backend/Smart-contracts, we can see the "raw" data before it gets prettified for the user.&lt;/p&gt;

&lt;p&gt;The Findings: The "8-Decimal" Red Flag&lt;br&gt;
While analyzing the trade history of a strategy, I noticed a significant inconsistency in the API responses.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;UI Inconsistency
In the user interface, profit values were displayed with an unusual number of decimal places (e.g., 4.18489805 USDT). For a stablecoin display, this is more than just a UI bug; it’s a sign that the data isn't being normalized.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1ujicthvtt6wvblh9o20.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1ujicthvtt6wvblh9o20.png" alt=" " width="800" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Deep Dive into the JSON Response
Looking at the deals endpoint, the raw JSON confirmed my suspicions.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The profit field returned a string with 8 decimals: "4.18489805".&lt;/p&gt;

&lt;p&gt;In the same object, total_profit was truncated to 2 decimals: "7.94".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffhzss8rj97kjfcpvofr4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffhzss8rj97kjfcpvofr4.png" alt=" " width="800" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Why This Matters (The Security Risk)&lt;br&gt;
This inconsistency suggests that the protocol's architecture lacks a unified Math/Precision library.&lt;/p&gt;

&lt;p&gt;Rounding Direction: If one part of the system rounds up and another rounds down (or doesn't round at all), it creates arbitrage opportunities or "ghost" funds.&lt;/p&gt;

&lt;p&gt;Truncation Issues: If the backend isn't truncating these "long-tail" decimals, it might be performing internal calculations with floating-point math instead of fixed-point integer math (which is a cardinal sin in blockchain security).&lt;/p&gt;

&lt;p&gt;Conclusion&lt;br&gt;
Even without looking at the Solidity code, we can see that the data handling layer has gaps. For developers, the lesson is simple: Always normalize your precision at the API level and ensure your rounding directions are consistent across all modules.&lt;/p&gt;

&lt;h1&gt;
  
  
  web3security, #blockchain, #bugbounty, #solidity.
&lt;/h1&gt;

</description>
    </item>
  </channel>
</rss>
