The fund_investor() function in the Cyfrin_Hub.vy allows public users to invest ETH in exchange for shares
Now in the following vyper code if self.issued_shares>0 but net_worth<issued_shares then net_worth // issued_shares == 0 that makes share_price =0 and msg.value // share_price is a division-by-zero causing immediate revert
Likelihood:
An Attacker(or naturally possible state) can cause share_price=0 and prevent anyone from buying shares causing Denial of Service.
Impact:
Denial of Funding
Unexpected Reverts and Availability Issues in production
issued_shares == 0 on the first fund path uses INITIAL_SHARE_PRICE — investor1 buys a huge number of shares, making issued_shares very large. This also increases company_balance by the same large ETH amount.
The owner then calls produce(...) to spend almost all the contract’s internal company_balance, leaving net_worth very small (a small number of wei). issued_shares remains the huge number minted earlier.
When investor2 calls fund_investor() (via fund_cyfrin(1)), the contract computes:
With net_worth < issued_shares, share_price becomes 0. The msg.value // share_price causes a division-by-zero, which reverts the transaction.
Either set share_price to a minimum 1 wei or when share_price equals 0 or If you prefer to reject purchases when price would be zero then put assert share_price > 0, "Share price computed to 0; cannot buy"
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.
The contest is complete and the rewards are being distributed.