addInvestor() Does Not Check Availability of investors_supply
The addInvestor() function does not check that the total amount allocated to investors stays within the investors_supply limit. An attacker with the admin private key could allocate more tokens than available and then claim all tokens.
Originally disclosed on Code4rena
Submitted by Meta0xNull
Impact
When add investor, addInvestor() does not check how many tokens is available from investors_supply. The total tokens allocated for Investors could more than investors_supply.
Possible Attack Scenario:
- Attacker who have Admin Private key call
addInvestor()andInput \_amount >= investors_supply. - Attacker can Claim All Available Tokens Now.
Proof of Concept
Tools Used
Manual Review
Recommended
- Add
require(\_amount <= (investors_supply - Allocated_Amount)) - When Add an Investor add the amount to
Allocated_Amountwith SafeMath
chickenpie347 (Boot Finance) acknowledged:
While this is true, the addInvestor would be a one-time routine at deployment which would precisely send the allocated number of tokens to the contract as per to the allocatations.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the addInvestor() function lacks a check to ensure the sum of allocated amounts does not exceed investors_supply.
Impact
An attacker with the admin private key could allocate more tokens than the investors_supply and claim all available tokens.
What the attacker needed
Admin private key
The fix
The function should be fixed by adding a require statement to ensure the amount does not exceed the remaining supply and by tracking allocated amounts with SafeMath.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
This is a smart contract bug where a function that adds investors doesn't verify that the total tokens given out don't exceed the supply set aside for investors. Someone with the admin key could give themselves more tokens than allowed and then take all the tokens in the contract.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.