The bankruptcy check in the sell_to_customer() function is fundamentally broken, allowing customers to purchase items even when the company is insolvent. This creates a critical vulnerability where the company can be drained of funds while accumulating massive debt.
Normal Behavior: The system should prevent sales when company_balance < holding_debt to protect against insolvency
Specific Issue: The bankruptcy check occurs AFTER holding costs are applied, creating a circular dependency where bankruptcy can only be detected after a sale attempt
Likelihood:
This occurs EVERY TIME a customer attempts to purchase when the company has accumulated holding debt
The circular dependency ensures bankruptcy can never be properly detected before sales
Impact:
Customers can drain company funds even when insolvent
Holding debt can accumulate indefinitely without any protection
Complete system integrity compromise
This proof of concept demonstrates the critical flaw in the bankruptcy detection system. The test sets up a scenario where:
Setup Phase: Company is funded with minimal ETH (1 ETH) and produces 100 items
Time Accumulation: We fast-forward 1 hour, which should create 0.1 ETH in holding costs (100 items × 0.001 ETH/hour)
Bankruptcy State: The company now has 0 ETH balance but 0.1 ETH in holding debt, making it technically bankrupt
Vulnerability Demonstration: The _is_bankrupt() function returns False because it checks the state BEFORE holding costs are applied
Exploitation: A customer can successfully trigger demand and purchase items, even though the company is insolvent
The core issue is that _is_bankrupt() checks company_balance < holding_debt, but holding_debt is only updated when _apply_holding_cost() is called, which happens AFTER the bankruptcy check in sell_to_customer().
The fix addresses the circular dependency by reordering the operations:
Apply Holding Costs First: _apply_holding_cost() is called before the bankruptcy check, ensuring that holding_debt is updated with the current time's accumulated costs
Check Bankruptcy After: The _is_bankrupt() check now operates on the updated state where holding_debt reflects the current accumulated costs
Proper State Validation: This ensures that the bankruptcy check accurately reflects the company's current financial state
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.