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

Add tests for reentrancy in _rentStorage function #458

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Pawar7349
Copy link

@Pawar7349 Pawar7349 commented Jan 16, 2025

Motivation

This pull request addresses potential reentrancy vulnerabilities in the _rentStorage function of the IdGateway contract. It is crucial to secure the contract against reentrancy attacks to prevent unintended behaviors and potential financial losses.

Change Summary

Implemented a new test contract RentStorageTest to specifically target and test for reentrancy issues in the _rentStorage function.

Added comprehensive test cases to verify the robustness of the _rentStorage function against reentrancy attacks.

Ensured that the function handles overpayment, exact payment, and edge case scenarios correctly.

Merge Checklist

Choose all relevant options below by adding an x now or at any time before submitting for review

[x] The PR title adheres to the conventional commits standard.

[x] The PR has been tagged with change type label(s) (i.e., feature, bugfix).

[x] The PR's changes adhere to all the requirements in the contribution guidelines.

[x] All commits have been signed.

Additional Context

The test suite covers various edge cases, ensuring the _rentStorage function's reliability and security. These tests help maintain the integrity and trustworthiness of the IdGateway contract.


PR-Codex overview

This PR refines the _rentStorage function in IdGateway.sol by changing how overpayment is calculated and transferred to the payer. It introduces a more secure method for sending funds and ensures proper calculation before external calls.

Detailed summary

  • Updated _rentStorage function to calculate overpayment after determining the amountToRent.
  • Changed the way overpayment is sent to payer using call instead of sendNative.
  • Added a require statement to check the success of the payment transfer.
  • Kept the receive function to restrict access to storageRegistry.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

@Pawar7349 Pawar7349 force-pushed the fix/rent-storage-reentrancy branch from f0ee162 to 88d880b Compare January 16, 2025 08:42
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

Successfully merging this pull request may close these issues.

1 participant