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 Hint for Zero Address Allocation #592

Open
rajosch opened this issue Jul 31, 2024 · 3 comments
Open

Add Hint for Zero Address Allocation #592

rajosch opened this issue Jul 31, 2024 · 3 comments

Comments

@rajosch
Copy link

rajosch commented Jul 31, 2024

Context:
Solidity developers often make the mistake of assigning or comparing addresses to the zero address (0x0000000000000000000000000000000000000000). This can lead to vulnerabilities and bugs in smart contracts.

Suggestion:
Implement a new rule in Solhint to check for:

  1. Assignments to the zero address.
  2. Comparisons with the zero address.

Rationale:
This check will help developers avoid common pitfalls and ensure better security and reliability in their smart contracts.

References:

@dbale-altoros
Copy link
Collaborator

hello @rajosch
thanks a lot for suggesting

to understand:

  • Assignments to the zero address:
    Are you referring to assign to a variable address(0) ? or what ?

  • Comparisons with the zero address.
    Is this what you mean ?
    if (userAddress == address(0)) or if (userAddress == 0x0000000000000000000000000000000000000000)

please put examples... thanks

@rajosch
Copy link
Author

rajosch commented Aug 3, 2024

Hi @dbale-altoros,

  1. I am referring to cases where a variable is assigned the value address(0).
  2. I am talking about instances where an assignment to the zero address is possible but not checked against. Example:
function transferOwnership(address newOwner) public {
    require(newOwner != address(0), "New owner cannot be the zero address");
    owner = newOwner;
}

My question is if there should be a hint to check for a zero address allocation if the require statement is not present.
This would help to prevent problems like this RHO incident.

@dbale-altoros
Copy link
Collaborator

sorry @rajosch I'm kind of swamp... I WILL take a look and get back to you as soon as i can

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

2 participants