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

Critical address changes should be a two step process #90

Closed
code423n4 opened this issue Nov 7, 2021 · 1 comment
Closed

Critical address changes should be a two step process #90

code423n4 opened this issue Nov 7, 2021 · 1 comment
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working duplicate This issue or pull request already exists

Comments

@code423n4
Copy link
Contributor

Handle

Ruhum

Vulnerability details

Impact

The contracts mostly use OpenZeppelin's Ownable contract. The contract handles the address change in a single step.

If by chance the address passed to transferOwnership() function has a typo, the owner would lose access to the whole deployed contract. In that case, the contract would have to be redeployed.

Instead, it is recommended to use a two-step process. First, you set the new address as the current owner. Then you have to claim the ownership with the new address. Thus, you can be sure that the new address is valid and you have access to it. That way you won't accidentally lose control over your contracts.

Here's Sushiswap's implementation of the Ownable contract as an example:
https://github.com/sushiswap/sushiswap/blob/4fdfeb7dafe852e738c56f11a6cae855e2fc0046/contracts/Ownable.sol

Proof of Concept

OpenZeppelin's Ownable: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol#L62

Swap.sol used OwnerPausable: https://github.com/code-423n4/2021-11-bootfinance/blob/main/customswap/contracts/Swap.sol#L30 which is defined here: https://github.com/code-423n4/2021-11-bootfinance/blob/main/customswap/contracts/OwnerPausable.sol

Tools Used

Manual Analysis

Recommended Mitigation Steps

Use a two-step process for critical address changes as seen here: https://github.com/sushiswap/sushiswap/blob/4fdfeb7dafe852e738c56f11a6cae855e2fc0046/contracts/Ownable.sol

@code423n4 code423n4 added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working labels Nov 7, 2021
code423n4 added a commit that referenced this issue Nov 7, 2021
@chickenpie347 chickenpie347 added the sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") label Nov 16, 2021
@chickenpie347 chickenpie347 added duplicate This issue or pull request already exists and removed sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") labels Jan 3, 2022
@chickenpie347
Copy link
Collaborator

Duplicate of #35

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants