Closed code423n4 closed 1 year ago
https://github.com/code-423n4/2023-05-juicebox/blob/main/juice-buyback/contracts/JBXBuybackDelegate.sol#L158
didPay and the swap/mint there will be called with incorrect values. Possibly losing user funds for bad trades.
mintedAmount and reservedRate are not protected from overwrite before didPay
mintedAmount
reservedRate
didPay
// Pass the quote and reserve rate via a mutex mintedAmount = _tokenCount; reservedRate = _data.reservedRate;
Anyone can call payParams with correct params, and set new mintedAmount and reservedRate.
payParams
Then, when controller calls didPay, these incorrect values would be used for swap and mint
swap
mint
vscode
Add a mutex lock. eg, if mintedAmount and reservedRate are not 1, don’t allow the payParams to be called.
Access Control
dmvt marked the issue as duplicate of #60
dmvt marked the issue as unsatisfactory: Invalid
Lines of code
https://github.com/code-423n4/2023-05-juicebox/blob/main/juice-buyback/contracts/JBXBuybackDelegate.sol#L158
Vulnerability details
Impact
didPay and the swap/mint there will be called with incorrect values. Possibly losing user funds for bad trades.
Proof of Concept
mintedAmount
andreservedRate
are not protected from overwrite beforedidPay
Anyone can call
payParams
with correct params, and set newmintedAmount
andreservedRate
.Then, when controller calls
didPay
, these incorrect values would be used forswap
andmint
Tools Used
vscode
Recommended Mitigation Steps
Add a mutex lock. eg, if mintedAmount and reservedRate are not 1, don’t allow the payParams to be called.
Assessed type
Access Control