Root + Impact
Description
The amendSellOrder()
function allows sellers to modify their existing orders by changing the amount, price, or deadline. However, the OrderAmended
event only emits the new values without including the previous values that were changed.
This creates an incomplete audit trail where external systems, dApps, and users cannot easily track what specific changes were made to an order. Without the previous values, it's impossible to determine the magnitude of changes or reconstruct the order's history from events alone.
solidityfunction amendSellOrder(
uint256 _orderId,
uint256 _newAmountToSell,
uint256 _newPriceInUSDC,
uint256 _newDeadlineDuration
) public {
Order storage order = orders[_orderId];
uint256 newDeadlineTimestamp = block.timestamp + _newDeadlineDuration;
order.amountToSell = _newAmountToSell;
order.priceInUSDC = _newPriceInUSDC;
order.deadlineTimestamp = newDeadlineTimestamp;
emit OrderAmended(_orderId, _newAmountToSell, _newPriceInUSDC, newDeadlineTimestamp);
}
event OrderAmended(
uint256 indexed orderId,
uint256 newAmountToSell,
uint256 newPriceInUSDC,
uint256 newDeadlineTimestamp
);
Risk
Likelihood:
Occurs every time an order is amended, which is a core functionality
All amendment operations suffer from this incomplete logging
High likelihood as it affects user experience and system monitoring
Impact:
Incomplete audit trail makes it difficult to track order history
External systems cannot easily determine what changed without additional state queries
Poor user experience for applications trying to show order modification history
Compliance and monitoring systems cannot properly track changes
Proof of Concept
book.amendSellOrder(5, 2e18, 3000e6, 1 days);
OrderAmended(5, 2e18, 3000e6, 1725480012);
Recommended Mitigation
event OrderAmended(
uint256 indexed orderId,
+ uint256 previousAmountToSell,
+ uint256 previousPriceInUSDC,
+ uint256 previousDeadlineTimestamp,
uint256 newAmountToSell,
uint256 newPriceInUSDC,
uint256 newDeadlineTimestamp
);
function amendSellOrder(
uint256 _orderId,
uint256 _newAmountToSell,
uint256 _newPriceInUSDC,
uint256 _newDeadlineDuration
) public {
Order storage order = orders[_orderId];
// ... validation checks ...
uint256 newDeadlineTimestamp = block.timestamp + _newDeadlineDuration;
+
+ // Store previous values before modification
+ uint256 previousAmountToSell = order.amountToSell;
+ uint256 previousPriceInUSDC = order.priceInUSDC;
+ uint256 previousDeadlineTimestamp = order.deadlineTimestamp;
// ... token transfer logic ...
// Update order details
order.amountToSell = _newAmountToSell;
order.priceInUSDC = _newPriceInUSDC;
order.deadlineTimestamp = newDeadlineTimestamp;
- emit OrderAmended(_orderId, _newAmountToSell, _newPriceInUSDC, newDeadlineTimestamp);
+ emit OrderAmended(_orderId, previousAmountToSell, previousPriceInUSDC, previousDeadlineTimestamp, _newAmountToSell, _newPriceInUSDC, newDeadlineTimestamp);
}