Solidity Smart Contract Reentrancy & Flash Loan Attack Auditor
Trained on post-mortem analyses of $500M+ DeFi exploits. Deconstructs contract logic step-by-step to expose zero-day edge cases before mainnet deployment.
Parametric Customizer & Compiler Live Tool
Adjust the variables below. The prompt code and API payload update dynamically in real time.
Specifies business logic and economic attack vectors.
Identifies EVM opcode level vulnerabilities.
Directs DeepSeek R1 reasoning tokens toward specific failure modes.
Paste your smart contract functions or interface logic here.
Act as a Principal Smart Contract Security Auditor and Certified Ethical Hacker (CEH) specializing in EVM bytecode and DeFi protocol exploits. Audit the provided Solidity smart contract.
### CONTRACT CONTEXT:
- Target Protocol: Lending & Borrowing Collateral Vault (ERC-4626)
- Solidity Version: ^0.8.24 with transient storage (TSTORE / TLOAD)
- Primary Threat Model: Cross-function and Read-Only Reentrancy with external curve pools
### CONTRACT CODE:
```solidity
contract VulnerableBank {
mapping(address => uint256) public balances;
function deposit() external payable { balances[msg.sender] += msg.value; }
function withdraw() external {
uint256 balance = balances[msg.sender];
require(balance > 0, "Zero balance");
(bool success, ) = msg.sender.call{value: balance}("");
require(success, "Transfer failed");
balances[msg.sender] = 0;
}
}
```
### AUDIT DIRECTIVES:
1. **Formal Threat Modeling**:
- Check for classic Reentrancy (CEI pattern violations) AND cross-contract Read-Only Reentrancy.
- Check for Flash Loan price oracle manipulation (spot AMM pool reserves vs. TWAP / Chainlink).
- Check for ERC-4626 vault share inflation attacks, integer truncation, and unchecked low-level calls.
2. **Exploit Proof-of-Concept (Foundry Test)**:
- Write an executable Foundry (`forge test`) Solidity PoC demonstrating the attack vector against the vulnerable function.
3. **Hardened Production Fix**:
- Provide the fully patched contract code using OpenZeppelin ReentrancyGuardUpgradeable and custom errors. High-powered reasoning model with exceptional code decompilation capability.
Leonardo Phoenix & Flux: Generate photorealistic studio assets with 150 daily free credits. Zero setup required.
πΈ Real Sample Outputs & Verified Results
Visual evidence and benchmark responses generated using this exact prompt formula.
π¬ Prompt Engineering Anatomy
Why this prompt consistently delivers high-tier results: technical parameter breakdown.
Foundry (forge test) Executable PoC Directive Instructing the AI to generate a runnable Foundry test forces the model to mathematically verify whether the attack is actually feasible, eliminating false positive alerts.
Transient Storage (TSTORE) Opcode Audit Solidity 0.8.24 allows cheap reentrancy guards via transient storage, but can cause bugs if state isn't cleared before next transaction.
π¬ Frequently Asked Questions
Troubleshooting common edge cases, model incompatibilities, and best practices.
Can DeepSeek R1 replace a human smart contract audit firm?
No. While DeepSeek R1 excels at finding common vulnerabilities and generating Foundry PoCs, high-value protocols should always undergo peer reviews by certified firms.
How do I run the generated Foundry test?
Paste the PoC into your `test/` folder and run `forge test -vvvv` in your terminal.
Explore Related Blockchain & Smart Contracts Prompts View all β
DeepSeek R1 Architecture & Security Vulnerability Code Auditor
Engineered specifically for DeepSeek R1 and reasoning models. Directs the thinking tokens (<think>) to rigorously stress-test edge cases before proposing optimized refactors.
cursorCursor AI (.cursorrules) for Next.js 15, React 19 & Tailwind CSS
Stops Cursor from writing outdated Next.js 13 patterns, Pages Router syntax, or deprecated React hooks. Enforces strict TypeScript, Server Actions, and modular clean architecture.
cursorFastAPI, PostgreSQL & Supabase Production (.cursorrules)
Eliminates common Python AI code generation traps: synchronous database calls in async routes, outdated Pydantic v1 syntax, and missing transaction rollbacks.