wOPEN
The WOpen token is an implementation of a wrapped token with deposit and withdraw capabilities. It is designed to securely handle Ether deposits and withdrawals while mitigating vulnerabilities such as the WETH permit attack.
Key Features
Deposit and Withdraw: Users can deposit Ether to mint
WOpentokens and withdraw Ether by burningWOpentokens.Security Enhancements: The contract includes a
receivefunction to handle Ether transfers securely, avoiding fallback-based vulnerabilities.Compatibility: Built on Solidity version
0.6.12for enhanced security and compatibility.Standard Compliance: Fully ERC20 compliant with a 1:1 peg to the native Open token.
Changes from Previous Implementations
Previous Implementation
Solidity Version:
>=0.4.22 <0.6Fallback Function:
function() external payable { deposit(); }This fallback function was used to handle Ether transfers.
Vulnerable to WETH permit-style exploits due to reliance on fallback behavior.
Current Implementation
Solidity Version:
0.6.12Receive Function:
The
receivefunction explicitly handles Ether transfers whenmsg.datais empty.Reduces the attack surface and mitigates vulnerabilities associated with fallback functions.
Forked Base Contract
The WOpen contract is forked from the Base Network's WETH implementation. The primary enhancement is the addition of the receive function to improve security.
Test Scenarios
1. BaseWETH Vulnerability to WETH Permit Attack
Objective: Demonstrate that the original
BaseWETHcontract is vulnerable to a WETH permit attack.Test:
Deploy
BaseWETHandERC20Bank.Use
depositWithPermitto exploit the vulnerability.Verify that the attacker can drain the user's balance.
2. WOpen Resilience to WETH Permit Attack
Objective: Verify that
WOpenis not vulnerable to a WETH permit attack.Test:
Deploy
WOpenandERC20Bank.Attempt to exploit
depositWithPermit.Verify that the transaction reverts and the user's balance remains intact.
3. Withdraw Functionality for WOpen
Objective: Verify that users can withdraw Ether by burning
WOpentokens.Test:
Deposit Ether to mint
WOpentokens.Withdraw Ether and verify that the user's balance is updated correctly.
4. Reentrancy Prevention in WOpen
Objective: Ensure that
WOpenis not vulnerable to reentrancy attacks.Test:
Deploy a reentrancy attacker contract.
Attempt to exploit the
withdrawfunction.Verify that the transaction reverts and the user's balance remains intact.
Running and Testing Flow
1. Compile
Run the following command to compile the smart contracts:
2. Deploy
Use the appropriate deployment script to deploy the WOpen contract. For example:
Replace <network-name> with the desired network (e.g., hardhat, sepolia, mainnet).
3. Test
Run the following command to execute the tests for WOpen:
This will run the test files test/testWOPEN.js and test/testAttackWOPEN.js.
Note: There is no NatSpec documentation added to the contract. This decision was made to align with the format followed by other blockchain implementations.
Security Contact
For any security concerns or vulnerabilities, please contact: security@openledger.xyz
References
Note: This documentation is maintained as part of the Open Ledger project. Last updated: June 2025
Last updated