The trigger_demand() function in CustomerEngine.vy is designed to simulate customer demand. If the sale fails (e.g., due to zero inventory), the company's reputation is penalized by 5 points.
A malicious attacker can continuously spam the trigger_demand() function, forcing failed sales and rapidly decreasing the company's reputation.
Attack Scenario:
Attacker ensures the company has zero inventory.
Attacker calls trigger_demand() repeatedly (waiting 60 seconds between calls due to the cooldown).
The company's reputation rapidly drops from 100 to 0.
Once the reputation is near zero, the company's ability to operate is severely hampered, as the sell_to_customer function in Cyfrin_Hub uses reputation to determine the sale price and success probability. A low reputation can permanently halt sales, effectively griefing the protocol.
Likelihood: Medium
The attack requires a simple script to call the function repeatedly with a 60-second delay. This is easily automated and guaranteed to work when inventory is low. The cost to the attacker is minimal (gas for the transaction).
Impact: Medium
The attack does not directly steal funds, but it causes a severe disruption of protocol functionality. By driving the reputation to zero, the attacker can effectively halt all future sales, preventing the company from generating revenue and making the shares worthless. This is a denial-of-service (DoS) attack on the core business logic.
This was confirmed during the manual audit:
Setup: Company funded, zero inventory. Initial reputation is 100.
Attack: Attacker calls trigger_demand() 20 times (waiting 60 seconds between calls).
Result: Reputation drops from 100 to 0 (20 * 5 = 100). The company is now in a state where sales are highly unlikely to succeed, effectively halting the protocol's revenue stream.
Supporting Code:
Implement a minimum purchase price or a higher cost for the trigger_demand() function to deter spamming.
Additionally, consider implementing a mechanism where only the owner can reset the reputation, or where the reputation penalty decreases as the reputation gets lower.
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.