Loading...

Loading

medium(4)

low(3)
Code Quality Observations(1)
Gas Optimizations(1)

Attack Chain Analysis

Balance Corruption to Full Draincritical

An attacker first calls emergencyWithdraw with an amount exceeding their zero balance. The unchecked underflow in _processWithdrawal (Finding: emergencyWithdraw has no balance check) wraps balances[attacker][token] to near type(uint128).max. The attacker then calls the standard withdraw function, which checks balances[msg.sender][token] >= amount and passes because the corrupted value is enormous. The safeTransfer sends all real tokens held by the contract to the attacker, fully draining every depositor's funds. The CEI violation in withdraw (Finding: CEI Violation in withdraw()) further compounds this by allowing a re-entrant call during the token transfer if the token has a callback hook, accelerating the drain.

emergencyWithdraw has no balance check — arbitrary fund drainageemergencyWithdraw Has No Balance Check — Bypasses All Access ControlsCEI Violation in withdraw(): State Updated After External Call
Order Cancellation Griefing Enabling Profitable Fill Front-Runhigh

An attacker monitors the mempool for large profitable fill transactions. Using the unauthorized cancel vulnerability (Finding: Unauthorized order cancellation), the attacker cancels the target order before the legitimate fill transaction confirms, causing the filler's transaction to revert. The attacker then re-places a similar order at a manipulated price and fills it themselves, capturing the profit. The incomplete order deletion (Finding: Incomplete order deletion in _cancelOrder) leaves stale linked-list state that could further corrupt orderbook traversal.

Unauthorized order cancellation — no msg.sender check in cancel()Incomplete order deletion in _cancelOrder leaves remaining/next/prev fields set
Price Manipulation via Unenforced Deviation and Truncated Quotehigh

Because MAX_PRICE_DEVIATION is never enforced in placeOrder (Finding: MAX_PRICE_DEVIATION constant is defined but never enforced), a malicious maker can place orders at extreme prices. A taker who fills such an order at a large amount may trigger the uint128 truncation bug in fillOrder (Finding: quoteAmount silently truncated when cast to uint128), paying a drastically reduced quote amount while receiving the full base token amount. The maker loses value and the taker profits at their expense.

MAX_PRICE_DEVIATION constant is defined but never enforcedquoteAmount silently truncated when cast to uint128 in fillOrder

Agent Coverage

AgentStatusFindingsSeverityConfidenceDurationCoverage
reentrancysuccess4
2C
87%40.6sCross-function reentrancy in withdraw() and emergencyWithdraw(), CEI (Checks-Effects-Interactions) pattern compliance across all state-mutating functions, unchecked arithmetic blocks in _processWithdrawal, Integer overflow/truncation in fillOrder quoteAmount uint128 cast, Access control on emergencyWithdraw, ERC-777 callback reentrancy risk on safeTransfer calls, Linked list integrity in placeOrder, cancel, fillOrder, Balance accounting consistency across deposit/withdraw/placeOrder/fillOrder, uint128 overflow in balance additions, Order existence checks and authorization
access controlsuccess4
89%38.6sAccess control on all state-modifying functions (deposit, withdraw, placeOrder, cancel, fillOrder, emergencyWithdraw), Authorization checks: who can cancel orders, who can call emergencyWithdraw, Unchecked arithmetic in _processWithdrawal and its impact on balance underflow, Integer overflow/truncation in fillOrder quoteAmount cast from uint256 to uint128, Linked list integrity in order insertion, cancellation, and fill removal, Reentrancy: CEI pattern compliance in withdraw, fillOrder, emergencyWithdraw, ERC20 safeTransfer/safeTransferFrom usage, Signature/authentication patterns (none present), Initializer protection (no upgradeable proxy, not applicable), Delegatecall patterns (none present), tx.origin usage (not present)
economicsuccess6
1C2H1M1L
88%52.7sFlash loan attack surface on balance-based order pricing, Oracle dependency (none found — pure orderbook, no price oracle), Access control on all state-mutating functions (cancel, emergencyWithdraw), Integer overflow/underflow in unchecked arithmetic blocks, Safe downcasting from uint256 to uint128 in fillOrder quoteAmount, Reentrancy via safeTransfer (CEI ordering checked in withdraw, fillOrder, emergencyWithdraw), Linked list integrity after cancel and fill operations, Sandwich/MEV exposure on order fills, Governance attack vectors (none present), Fee-on-transfer and rebasing token interactions, First-depositor inflation attacks (no LP share minting), Price deviation constant enforcement
logic validationsuccess5
1C1H2M
88%52.9sInput validation on all external functions (deposit, withdraw, placeOrder, cancel, fillOrder, emergencyWithdraw), Unchecked arithmetic blocks for underflow/overflow (found critical issue in _processWithdrawal), Authorization checks on order management functions (found missing auth in cancel), Integer overflow and truncation in quoteAmount cast to uint128, Precision loss and rounding direction in fillOrder quote calculation, Linked list integrity in order insertion, cancellation, and removal, State cleanup completeness in _cancelOrder and _removeFilledOrder, Reentrancy: SafeERC20 used, CEI pattern generally followed, ERC-20 standard compliance via OpenZeppelin imports, totalDeposits accounting correctness, getOrders linked list traversal for DoS via unbounded loop
code qualitysuccess8
1L
87%1.2mReentrancy in withdraw and emergencyWithdraw, Access control on emergencyWithdraw and cancel, Integer overflow/underflow in unchecked blocks, Unsafe downcasts from uint256 to uint128, Linked list integrity in placeOrder, cancel, and fillOrder, CEI pattern compliance, ERC-20 standard compliance for deposit/withdraw, Precision loss in price calculations, Dead code analysis, Constant/immutable usage
compiler bugssuccess4
1C
88%42.1sAccess control on cancel(), placeOrder(), fillOrder(), emergencyWithdraw(), Arithmetic overflow/underflow in unchecked blocks (_processWithdrawal), Integer truncation in fillOrder quoteAmount casting, Reentrancy in deposit(), withdraw(), fillOrder() — all follow CEI or use SafeERC20 with balance-before-transfer pattern, Linked list integrity in order insertion/removal (_cancelOrder, _removeFilledOrder), ERC20 transfer safety — SafeERC20 used throughout public entry points, Compiler bug applicability — pragma ^0.8.20 is outside all known affected ranges, Dust order / MIN_ORDER_SIZE enforcement in placeOrder, MAX_PRICE_DEVIATION constant declared but not enforced in placeOrder
assembly safetysuccess5
88%50.0sFull codepoint-by-codepoint scan for non-ASCII characters, RTLO (U+202E), zero-width characters (U+200B, U+200C, U+200D), and Cyrillic homoglyphs in all identifiers, function names, and string literals — none found, Inline assembly blocks — none present in this contract, Access control on all external/public state-mutating functions (deposit, withdraw, placeOrder, cancel, fillOrder, emergencyWithdraw), Integer arithmetic including unchecked blocks, uint128/uint256 cast truncation risks, Reentrancy patterns and checks-effects-interactions ordering, Linked list manipulation correctness in placeOrder, cancel, fillOrder, Constant enforcement (MIN_ORDER_SIZE, MAX_PRICE_DEVIATION), MockTIP20 contract for minter access control and mint function safety, SafeERC20 usage correctness, Event emission completeness, Flash loan / price oracle manipulation attack surfaces
l2 specificsuccess7
1M1L
85%1.1mDeposit and withdrawal logic including CEI pattern compliance, emergencyWithdraw unchecked arithmetic and access control, Order placement, cancellation, and fill logic, Authorization checks in cancel() and placeOrder(), Integer overflow/underflow in fillOrder quoteAmount cast, Linked list integrity in _cancelOrder and _removeFilledOrder, MAX_PRICE_DEVIATION enforcement (or lack thereof), Fee-on-transfer token compatibility, Reentrancy vectors across deposit/withdraw/fillOrder, uint128 overflow in balance accumulation, getOrders view function for unbounded loop / DoS, MockTIP20 minter access control, Chain-agnostic analysis (no L2-specific markers found)

Scope and Methodology

Target0xf6118a2190311d3b2ef2d77ed3cd8e63a0617f53
ChainEthereum
Complexitymoderate
Standards DetectedERC20
Analysis ModelClaude Sonnet 4.6
Specialist Agents9
Agent Types
reentrancyaccess controleconomiclogic validationcode qualitycompiler bugsassembly safetyl2 specific
Scope TemplateDeFi - AMM/DEX (auto-selected)
MethodologyAutomated multi-agent analysis. Each specialist agent independently reviews the contract source code for vulnerabilities in its domain. Findings are deduplicated, scored, and synthesized into this report.
Findings are gated by demonstrated exploit feasibility against the analyzed contract. Observations that describe accepted blockchain behavior, consensus-layer issues, or infeasible preconditions are excluded from scored findings. See scope policy.

Severity Classification

CriticalDirect loss of funds or complete protocol compromise. Exploitable with high likelihood. Requires immediate remediation.
HighSignificant risk to funds or protocol integrity. Conditionally exploitable or requires specific circumstances. Should be fixed before deployment.
MediumLimited or conditional impact. May require unlikely conditions to exploit. Should be addressed but not blocking.
LowMinor impact. Best practice deviations, minor inefficiencies. Fix when convenient.
InformationalNo direct security impact. Code quality observations, gas optimizations, style recommendations.

Limitations

This automated audit has inherent limitations. The following areas are not covered.

Disclaimer

This report is an automated point-in-time assessment and does not guarantee protection against all possible attacks. It does not cover off-chain components, economic modeling, or business logic correctness unless explicitly noted. Changes to the contract after the audit commit are not reviewed. This is not financial or legal advice. WalletGuard, powered by Gestalt Labs, provides this analysis as-is with no warranty of completeness.

Embed Badge
WalletGuard Audit Badge
Markdown
[![WalletGuard Audit](https://walletguard.ai/api/badge/c82b6d5e-384e-421e-94ac-a81edc3fe419)](https://walletguard.ai/audit/c82b6d5e-384e-421e-94ac-a81edc3fe419)
HTML
<a href="https://walletguard.ai/audit/c82b6d5e-384e-421e-94ac-a81edc3fe419">
  <img src="https://walletguard.ai/api/badge/c82b6d5e-384e-421e-94ac-a81edc3fe419" alt="WalletGuard Audit Badge" />
</a>
WalletGuardSecured by WalletGuard
How We AuditView all reports for this contractUID: 0xf40e65ad...ab1694This report was produced by generic vulnerability pattern matching.
Modelsonnet
Duration2.8m
CostN/A
Tokens- in / - out
Source verified via Etherscan
WalletGuard Audit: EVMBench: 2026-01-tempo-stablecoin-dex | Score: 1.0/10