Cyfrin_Hub.fund_investor caps new_shares to the remaining supply but still increments company_balance by the full msg.value, so investors overpay whenever they request more shares than the cap allows.
Likelihood: High
Near-cap states are expected at launch; single mis-sized tx triggers the bug and UI race conditions make it easy to overshoot.
Impact: High
Excess payment is never refunded or compensated with shares, producing direct investor loss and inflating treasury balance.
Overview: Python test test_poc_002_investor_overpayment.py fills the cap to 999,000 shares, attempts to buy 2,000 more, and proves only 1,000 shares are issued while full payment for 2,000 is kept.
Step-by-step:
Setup: Owner seeds 1 ETH; investor A mints 999,000 shares (leaving 1,000 remaining slots).
Attack Vector: Investor B sends payment for 2,000 shares in a single call.
Execution Flow: Contract mints only 1,000 shares (capped to remaining supply) but accepts full payment for 2,000.
Result: Investor pays for 2,000 shares but receives only 1,000; excess payment (~1 ETH) trapped in company_balance with no refund.
Recompute payment as share_price * new_shares after clipping and refund msg.value - (share_price * new_shares) in the same transaction.
Alternatively, revert when msg.value overshoots to force investors to size their txs conservatively.
Emit explicit events when refunds occur so analytics can reconcile the treasury.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
View preliminary resultsAppeals are being carefully reviewed by our judges.
The contest is complete and the rewards are being distributed.