Summary
No data is stored in the locks map
Vulnerability Details
There is no data stored in mapping(address => Lock) public locks;, so the following function cannot correctly obtain account related data.
function getLockedBalance(address account) external view returns (uint256) {
@> return locks[account].amount;
}
function getLockEndTime(address account) external view returns (uint256) {
@> return locks[account].end;
}
Poc
Add the following test to test/unit/core/tokens/veRAACToken.test.js and execute it:
describe("check locks mapping", () => {
it("Poc", async () => {
const duration = 365 * 24 * 3600 * 4 ;
await veRAACToken.connect(users[0]).lock(ethers.parseEther("100"), duration);
expect(await veRAACToken.getLockedBalance(users[0].address)).to.be.eq(0);
expect(await veRAACToken.getLockEndTime(users[0].address)).to.be.eq(0);
await veRAACToken.connect(users[0]).increase(ethers.parseEther("900"));
expect(await veRAACToken.getLockedBalance(users[0].address)).to.be.eq(0);
expect(await veRAACToken.getLockEndTime(users[0].address)).to.be.eq(0);
});
});
Impact
There is no data stored in mapping(address => Lock) public locks;, so the following function cannot correctly obtain account related data.
Tools Used
Manual Review
Recommendations
The corresponding data should be obtained from _lockState.locks
function getLockedBalance(address account) external view returns (uint256) {
- return locks[account].amount;
+ return _lockState.locks[account].amount;
}
function getLockEndTime(address account) external view returns (uint256) {
- return locks[account].end;
+ return _lockState.locks[account].end;
}