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

Gas-consuming way to add shareholders #81

Open
code423n4 opened this issue Nov 16, 2021 · 3 comments
Open

Gas-consuming way to add shareholders #81

code423n4 opened this issue Nov 16, 2021 · 3 comments
Labels
bug Something isn't working G (Gas Optimization) sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons

Comments

@code423n4
Copy link
Contributor

Handle

palina

Vulnerability details

Impact

New shareholders can only be added by rewriting the whole shareholders[] array in the FeeSplitter::setShareholders() function, which iterates over an array rendering significant gas consumption. The function FeeSplitter::_addShareholder() adds an individual shareholder, but has private visibility and, therefore, cannot be called by the owner separately.

Proof of Concept

_addShareholder(): https://github.com/code-423n4/2021-11-nested/blob/5d113967cdf7c9ee29802e1ecb176c656386fe9b/contracts/FeeSplitter.sol#L262
setShareholders(): https://github.com/code-423n4/2021-11-nested/blob/5d113967cdf7c9ee29802e1ecb176c656386fe9b/contracts/FeeSplitter.sol#L104

Tools Used

Manual Analysis

Recommended Mitigation Steps

If the shareholders are expected to be added regularly, consider making _addShareholder() accessible to both the contract and the owner:
function addShareholder(address _account, uint256 _weight) public onlyOwner {.

@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels Nov 16, 2021
code423n4 added a commit that referenced this issue Nov 16, 2021
@adrien-supizet
Copy link
Collaborator

This implementation costs a bit more gas indeed, but we decided to go with this one because it is simple and idempotent, and will not be called often.
Acknowledged.

@adrien-supizet adrien-supizet added the sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons label Nov 19, 2021
@maximebrugel maximebrugel added duplicate This issue or pull request already exists and removed sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons labels Nov 22, 2021
@maximebrugel
Copy link
Collaborator

Duplicated : #135

@alcueca
Copy link
Collaborator

alcueca commented Dec 3, 2021

Not a duplicate of #135

@alcueca alcueca reopened this Dec 3, 2021
@alcueca alcueca removed the duplicate This issue or pull request already exists label Dec 3, 2021
@maximebrugel maximebrugel added the sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons label Dec 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working G (Gas Optimization) sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons
Projects
None yet
Development

No branches or pull requests

4 participants