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

scheduleRely can be executed immediately defeating the Time ward allocation purpose #701

Closed
c4-submissions opened this issue Sep 14, 2023 · 4 comments
Labels
bug Something isn't working downgraded by judge Judge downgraded the risk level of this issue duplicate-298 grade-c low quality report This report is of especially low quality QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax unsatisfactory does not satisfy C4 submission criteria; not eligible for awards

Comments

@c4-submissions
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2023-09-centrifuge/blob/512e7a71ebd9ae76384f837204216f26380c9f91/src/Root.sol#L65

Vulnerability details

The use of MAX_DELAY to set the maximum amount of time that a scheduledRely can last is correct but there is actually no way to use a minimal time to limit the time that a contract or address has to wait before they can actually become a ward. I assume the Time ward allocation was made to verify the integrity of the contract trying to become a ward before granting them permission

let ‘s check out a scenario

An attacker, Alice, gains access to one of the initial ward accounts in the protocol

Alice, with her newfound access, uses the protocol's relyContract function to add a new address, "Malicious1," as a ward.

Malicious1, now having ward privileges, proceeds to create additional rogue wards by using the same relyContract function. Malicious1 creates "Malicious2" as a ward.

Since there's no wait time before a ward can be accepted as a ward, all these dangerous appointment can come into effect and become a ward before other wards realise

Proof of Concept

  uint256 private MAX_DELAY = 4 weeks;
/// --- Timelocked ward management ---
    function scheduleRely(address target) external auth {
        schedule[target] = block.timestamp + delay;
        emit RelyScheduled(target, schedule[target]);
    }

    function cancelRely(address target) external auth {
        schedule[target] = 0;
        emit RelyCancelled(target);
    }

    function executeScheduledRely(address target) public {
        require(schedule[target] != 0, "Root/target-not-scheduled");
        require(schedule[target] < block.timestamp, "Root/target-not-ready");

        wards[target] = 1;
        emit Rely(target);

        schedule[target] = 0;
    }

You can see that when you actually try to ScheduleRely there is no minimum TIME_DELAY to actually have a required duration of time to verify the integrity of the ward that is being added, if its malicious or not.

Recommended Mitigation Steps

The same way you set the MAX_DELAY to prevent a long amount of time before executing the rely, you should also set a MIN_DELAY to verify the integrity of the address or contract before execution

Assessed type

Context

@c4-submissions c4-submissions 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 Sep 14, 2023
c4-submissions added a commit that referenced this issue Sep 14, 2023
@c4-pre-sort
Copy link

raymondfam marked the issue as low quality report

@c4-pre-sort c4-pre-sort added the low quality report This report is of especially low quality label Sep 16, 2023
@c4-pre-sort
Copy link

raymondfam marked the issue as duplicate of #298

@c4-judge
Copy link

gzeon-c4 changed the severity to QA (Quality Assurance)

@c4-judge c4-judge added downgraded by judge Judge downgraded the risk level of this issue QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax and removed 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value labels Sep 25, 2023
@c4-judge
Copy link

gzeon-c4 marked the issue as grade-c

@c4-judge c4-judge added grade-c unsatisfactory does not satisfy C4 submission criteria; not eligible for awards labels Sep 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working downgraded by judge Judge downgraded the risk level of this issue duplicate-298 grade-c low quality report This report is of especially low quality QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax unsatisfactory does not satisfy C4 submission criteria; not eligible for awards
Projects
None yet
Development

No branches or pull requests

3 participants