
Why Are Standard Audits Ineffective?
Most hacks in 2024–2025 occurred not because of simple typos in Solidity, but due to infrastructure compromise. If a hacker obtains admin keys, they bypass all standard onlyOwner checks. Our task is to create a defense-in-depth strategy.
Layer 1: Rate Limiting
This is a “nightmare” for a hacker who wants to withdraw everything at once. Even with admin keys, they will hit the limit.
Principle: A maximum withdrawal amount is set for each token over a specific period (e.g., 24 hours).
Translated with DeepL.com (free version)
Solidity
// Example of rate-limiting logic
function _checkAndTrackWithdrawal(address _token, uint256 _amount) internal {
LimitConfig storage config = tokenLimits[_token];
if (!config.isEnabled) return;
UsageTracker storage usage = tokenUsage[_token];
// If more than 24 hours have passed, reset the counter
if (block.timestamp >= usage.windowStart + 86400) {
usage.currentAmount = _amount;
usage.windowStart = block.timestamp;
} else {
usage.currentAmount += _amount;
}
// Main threshold
if (usage.currentAmount > config.maxAmountPerWindow) {
revert RateLimitExceeded();
}
}
Translated with DeepL.com (free version)
Tier 2: Mandatory Timelock
Any critical change (oracle replacement, logic update, withdrawal of large sums) must go through a waiting period (48–72 hours).
Why this works:
An attacker initiates a transaction.
Automated monitoring systems (Forta, Tenderly) detect the suspicious activity.
The security team has 2 days to hit the “panic button” and cancel the transaction before it is executed.
Tier 3: The Role of the “Guardian”
The system must include an address with minimal permissions that cannot transfer funds but can block transactions in Timelock or pause the contract. This should be a “cold” wallet, with keys stored in a bank safe deposit box.
Conclusion: Security Checklist for Auditors
When auditing any major protocol, look for answers to the following questions:
Are there rate limits on withdrawals?
Are the setOracle and updateLogic functions protected via Timelock?
Is there an emergency freeze mechanism available to the Guardian?
Security is not the absence of bugs, but the impossibility of stealing everything, even if a bug is found.
Top comments (0)