Normal Behavior: The owner's produce() function is intended to increase the company's inventory and overall value, which should benefit all shareholders proportionally over time.
The Issue: A critical flaw exists where the value added to the company's valuation from production is immediately greater than the cost of that production. An attacker can monitor the blockchain for the owner's produce() transaction and front-run it by buying shares. This allows them to capture the instant, risk-free profit created by the owner's action, diluting the value for all other legitimate investors.
Likelihood:
This vulnerability will occur whenever the owner calls any administrative function that instantly increases the company's net worth more than its cost.
An attacker can reliably execute this by monitoring the mempool for the owner's transactions and submitting their own investment with a higher gas fee.
Impact:
This flaw leads to the direct and systematic extraction of value from the company at the expense of other shareholders.
It breaks the economic fairness of the simulation and siphons value from the protocol, undermining its core purpose.
Explanation: The following test simulates the front-running attack. An attacker monitors for the owner's produce() transaction and invests right before it executes, unfairly capturing the value increase. The test confirms that the attacker's shares are worth more than their initial investment immediately after the owner's transaction is mined.
**Vulnerable Code: **https://github.com/CodeHawks-Contests/2025-10-company-simulator/blob/main/src/Cyfrin_Hub.vy#L128-L145
Proof of Concept: https://github.com/Sagarchhetri83/2025-10-company-simulator/blob/main/src/tests/Exploit.t.sol#L99-L130
Explanation: The fix makes the produce() function economically neutral at the moment of execution. By ensuring the value added to the company's inventory is exactly equal to the cash spent on production, it eliminates the front-running opportunity.
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.