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

double reading of state variable inside a loop #98

Open
code423n4 opened this issue Nov 16, 2021 · 1 comment
Open

double reading of state variable inside a loop #98

code423n4 opened this issue Nov 16, 2021 · 1 comment
Assignees
Labels
bug Something isn't working G (Gas Optimization) question Further information is requested sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")

Comments

@code423n4
Copy link
Contributor

Handle

pants

Vulnerability details

MixinOperatorResolver.rebuildCache (addressCache[name]), isResolverCached (addressCache[name])

You can cache the value after the first read into a local variable to save the other SLOAD and also the "out of bounds" check.

@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
@maximebrugel
Copy link
Collaborator

maximebrugel commented Nov 19, 2021

The issue is not clear...

So, we confirm for isResolverCached :

function isResolverCached() external view returns (bool) {
    bytes32[] memory requiredAddresses = resolverAddressesRequired();
    for (uint256 i = 0; i < requiredAddresses.length; i++) {
        bytes32 name = requiredAddresses[i];
        address cache_tmp = addressCache[name];
        // false if our cache is invalid or if the resolver doesn't have the required address
        if (resolver.getAddress(name) != cache_tmp || address(0) == cache_tmp) {
            return false;
        }
    }
    return true;
}

But for rebuildCache what are the expected mitigation steps ?

@maximebrugel maximebrugel added sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") question Further information is requested labels Nov 19, 2021
@maximebrugel maximebrugel self-assigned this Dec 21, 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) question Further information is requested sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Projects
None yet
Development

No branches or pull requests

2 participants