stylus-rust

Solid

Detect bug classes specific to Arbitrum Stylus (Rust→WASM) contracts — storage aliasing & EVM state-cache coherence, msg::value /

AI & Automation 38 stars 5 forks Updated 2 days ago MIT

Install

View on GitHub

Quality Score: 82/100

Stars 20%
53
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Stylus (Rust) detection ## When this applies - Any `.rs` file importing `stylus_sdk` (`use stylus_sdk::{...}`) - Macros `#[entrypoint]`, `#[storage]`, `sol_storage!`, `#[public]`, `#[payable]` - Host-IO calls: `evm::`, `msg::`, `block::`, `contract::`, `call::` (`Call::new`, `transfer_eth`, `RawCall`) - Stylus types `StorageU256`, `StorageMap`, `StorageVec`, `alloy_primitives::U256`/`Address` - A `Cargo.toml` declaring `stylus-sdk` with `crate-type = ["lib", "cdylib"]` Stylus runs the SAME EVM state and shares the SAME external-call surface as Solidity. Rust safety does NOT remove EVM-level footguns — it adds new ones (panics, wrapping arithmetic, aliasing). ## Detection patterns ### Storage aliasing / stale local copy of EVM state (HIGH) ```rust let mut bal = self.balances.get(from); // ← copies value out of storage do_external_call(); // callee may mutate self.balances self.balances.insert(from, bal - amount); // ← writes back STALE value ``` **Signal:** a `.get()` cached in a local, an intervening call/host-IO, then a `.set()`/`.insert()` of the stale local. Stylus storage reads are snapshots, not live references — re-read after any external call. ### Reentrancy via external call before state finalization (CRITICAL) ```rust pub fn withdraw(&mut self) -> Result<(), Vec<u8>> { let amt = self.balance.get(msg::sender()); call::transfer_eth(msg::sender(), amt)?; // ← control leaves contract self.balance.setter(msg::sender...

Details

Author
iktok90-design
Repository
iktok90-design/ai-smart-contract-auditor
Created
1 weeks ago
Last Updated
2 days ago
Language
JavaScript
License
MIT

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category