Skip to content
This repository has been archived by the owner on Jul 21, 2024. It is now read-only.

0xhashiman - Proposer can drain all Telcoin #91

Closed
sherlock-admin2 opened this issue Jan 15, 2024 · 2 comments
Closed

0xhashiman - Proposer can drain all Telcoin #91

sherlock-admin2 opened this issue Jan 15, 2024 · 2 comments
Assignees
Labels
Excluded Excluded by the judge without consulting the protocol or the senior Non-Reward This issue will not receive a payout Sponsor Disputed The sponsor disputed this issue's validity Won't Fix The sponsor confirmed this issue will not be fixed

Comments

@sherlock-admin2
Copy link
Contributor

sherlock-admin2 commented Jan 15, 2024

0xhashiman

high

Proposer can drain all Telcoin

Summary

In TelcoinDistributor.sol, a malicious proposer can drain all Telcoin by exploiting the executeTransaction() function.

Vulnerability Detail

When a council member proposes a new proposal, they can specify the totalWithdrawal amount. This amount is directly transferred from the owner's wallet when calling the function executeTransaction(uint256 transactionId). As there is no limit to cap this withdrawal amount, a malicious proposer can execute a valid proposal, withdrawing the entire balance of the owner. The only limit is the amount of tokens that the owner approved for the contract. According to a response from the protocol team on Discord, this approval amount will likely be less than the maximum for security reasons, but large enough to avoid running a transaction every time.

Protocol team answer in discord for how much the approval amount will be .
Likely it will be less than the max for security, but large enough so that a transaction does not need to be run every time.

The line responsible for the transfer from the owner to the TelcoinDistributor contract:

TELCOIN.safeTransferFrom(owner(), address(this), totalWithdrawl);

Additionally, a Proof of Concept is provided to illustrate the exact vulnerability described above. Add it in TelcoinDistributor.test.ts and run it using

npx hardhat test --grep "should execute a malicious proposal successfully"
         it('should execute a malicious proposal successfully', async () => {

            
           await telcoin.connect(owner).approve(telcoinDistributor.getAddress(), 100000000000000) // the owner approval based on the test file

           const totalWithdrawl = 10000000000000;
           const destinations = [proposer.address];
           const amounts = [10000000000000];


         //  prposing a malicious proposal that will drain a lot of tokens from the owner balance 
           await expect(telcoinDistributor.connect(proposer).proposeTransaction(totalWithdrawl, destinations, amounts)).to.emit(telcoinDistributor, "TransactionProposed");
           await advanceTime(100);

             await telcoinDistributor.connect(proposer).executeTransaction(1);
            console.log( await telcoin.balanceOf(proposer));// This will be all owner balance 
           
        });

Impact

The vulnerability allows a proposer to drain the entire balance owned by the protocol's owner, causing severe damage.

Code Snippet

https://github.com/sherlock-audit/2024-01-telcoin/blob/main/telcoin-audit/contracts/protocol/core/TelcoinDistributor.sol#L87-L106
https://github.com/sherlock-audit/2024-01-telcoin/blob/main/telcoin-audit/contracts/protocol/core/TelcoinDistributor.sol#L143-L175
https://github.com/sherlock-audit/2024-01-telcoin/blob/main/telcoin-audit/contracts/protocol/core/TelcoinDistributor.sol#L185-L203

Tool used

Manual Review

Recommendation

I suggest implementing a maximum limit maxTotalWithdrawal for all withdrawals to cap the amount. Additionally, consider adding a setter function for the owner to adjust this limit, either reducing it or increasing it within reasonable bounds. Also, introduce a check for maxTotalWithdrawal in the proposeTransaction() function to ensure proposed transactions adhere to the specified limit.

@amshirif amshirif self-assigned this Jan 18, 2024
@amshirif amshirif added Medium A valid Medium severity issue Sponsor Confirmed The sponsor acknowledged this issue is valid Disagree With Severity The sponsor disputed the severity of this issue Will Fix The sponsor confirmed this issue will be fixed Sponsor Disputed The sponsor disputed this issue's validity Won't Fix The sponsor confirmed this issue will not be fixed and removed Medium A valid Medium severity issue Sponsor Confirmed The sponsor acknowledged this issue is valid Disagree With Severity The sponsor disputed the severity of this issue Will Fix The sponsor confirmed this issue will be fixed labels Jan 18, 2024
@amshirif
Copy link

The recommended solution does not actually address the issue. With the suggested changes the bad actor could simply create multiple transactions. Even adding a running cap between transactions amounts to the approval limits mentioned in the discord thread discussed. Council members will be responsible for evaluating all other transactions to keep other members honest, this is enforced through the challenge process.

@github-actions github-actions bot added Has Duplicates A valid issue with 1+ other issues describing the same vulnerability Excluded Excluded by the judge without consulting the protocol or the senior labels Jan 19, 2024
@sherlock-admin sherlock-admin changed the title Little Brick Blackbird - Proposer can drain all Telcoin 0xhashiman - Proposer can drain all Telcoin Jan 29, 2024
@sherlock-admin sherlock-admin added Non-Reward This issue will not receive a payout and removed Has Duplicates A valid issue with 1+ other issues describing the same vulnerability labels Jan 29, 2024
@nevillehuang
Copy link
Collaborator

Invalid

  • Given any council members can challenge transactions, they will be responsible for vetoing transactions via challenges.
  • For proposals where totalWithdrawal != amount, this would consitute user/council member input error.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Excluded Excluded by the judge without consulting the protocol or the senior Non-Reward This issue will not receive a payout Sponsor Disputed The sponsor disputed this issue's validity Won't Fix The sponsor confirmed this issue will not be fixed
Projects
None yet
Development

No branches or pull requests

4 participants