Conversation
Critical Bug Fix: V1_BLOCKED Validation Bypass🔴 Critical FindingOur auditors identified a critical vulnerability in the Impact: V1_BLOCKED addresses could successfully transfer tokens through V1 frontends when they should be rejected with a "blocked in V1" error. 🔍 Root CauseThe issue stems from the call chain architecture: The original code checked: if (isV1Frontend(msg.sender)) { // Always false - msg.sender is ControllerToken
if (isV1Blocked(from)) { revert(...); }
}Since ✅ SolutionWe fixed this by querying the caller (ControllerToken) for its configured frontend address using the existing function validate(address from, address to, uint256 amount) external override returns (bool valid) {
if (v1BlockedCount > 0) { // Gas optimization
// Query the caller to get the actual frontend address
address frontend = address(0);
try IControllerToken(msg.sender).getFrontend() returns (address _frontend) {
frontend = _frontend;
} catch {
frontend = msg.sender; // Backwards compatibility for direct calls
}
// Now check if this frontend is a V1 frontend
if (isV1Frontend(frontend)) {
if (isV1Blocked(from)) { revert("...blocked in V1..."); }
if (isV1Blocked(to)) { revert("...blocked in V1..."); }
}
}
// Blacklist checks...
}Key improvements:
🧪 Tests AddedComplete test suite rewrite in
Setup changes:
🚀 Gas Optimization BonusAdded uint256 private v1BlockedCount; // Tracks number of blocked addresses
function validate(...) external override returns (bool valid) {
if (v1BlockedCount > 0) { // Only check if blocked addresses exist
// ... getFrontend() logic ...
}
}Impact: Zero gas overhead on Arbitrum and other V2-only chains that have no blocked addresses. 🧪 How to TestRun the full test suite: forge test --match-contract ValidatorTest -vvExpected output: 17 tests pass (includes 6 new integration tests) Run specific critical test: forge test --match-test testV1FrontendBlocksV1BlockedAddresses -vvvTest gas optimization: forge test --match-test testGasOptimizationNoBlockedAddresses -vv📊 Test Results📝 Files Changed
✅ Checklist
|
Audit for #55 and #54