Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SortedTroves. insert is vulnerable to developer error #1031

Open
xavierlepretre opened this issue Dec 11, 2023 · 0 comments
Open

SortedTroves. insert is vulnerable to developer error #1031

xavierlepretre opened this issue Dec 11, 2023 · 0 comments

Comments

@xavierlepretre
Copy link

The function SortedTroves.insert takes in uint256 _NICR as a parameter. Further in the call stack, this value is compared to _troveManager.getNominalICR(_nextId) and _troveManager.getNominalICR(_prevId).

I understand it is the intention of the developer to have the insert function be called with a correct _NICR value.

However, I reckon the SortedTroves contract could protect itself form the risk that the developer does not follow the original intentions with this change:

-   _insert(troveManagerCached, _id, _NICR, _prevId, _nextId);
+   _insert(troveManagerCached, _id, troveManagerCached.getNominalICR(_id), _prevId, _nextId);

On the downside, it creates a couple extra SLOAD costs, mitigated by the fact that the storage locations are likely to have been written in the same transaction and so should cost WARM_STORAGE_READ_COST, plus, the rest of the function cold reads a lot of other storage locations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant