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

Wrong implementation of accesss control for KatanaGovernance._authorized() #116

Open
c4-bot-8 opened this issue Oct 25, 2024 · 0 comments
Open
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 🤖_primary AI based primary recommendation 🤖_18_group AI based duplicate group recommendation sufficient quality report This report is of sufficient quality

Comments

@c4-bot-8
Copy link
Contributor

Lines of code

/root/katana-operation-contracts/src/governance/KatanaGovernance.sol#L377-L383

Vulnerability details

Proof of Concept

The following implementation of _isAuthorized is wrong since an account is considered authorized if
block.timestamp > expiry even if $.allowed[account] = false. Meanwhile, even after the authorization expires, if $.allowed[account] is true, then it is still authorized.


 function _isAuthorized(Permission storage $, address account) private view returns (bool) {
    uint256 expiry = $.whitelistUntil;
    if (expiry == UNAUTHORIZED) return false;
    if (expiry == AUTHORIZED || block.timestamp > expiry) return true; // but we have not checked the account!

    return $.allowed[account];
  }

Recommended Mitigation Steps

The correct way is to check both expiration time and $.allowed[account] with a conjunction.


 function _isAuthorized(Permission storage $, address account) private view returns (bool) {
    uint256 expiry = $.whitelistUntil;
    if (expiry == UNAUTHORIZED) return false;
-    if (expiry == AUTHORIZED || block.timestamp > expiry) return true; // but we have not checked the account!

+    if(expiry = AUTHORIZED) return true;

-    return $.allowed[account];
-    if(block.timestamp > expiry && $.allowed[account]) return true;

  }

Assessed type

Access Control

@c4-bot-8 c4-bot-8 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 Oct 25, 2024
c4-bot-8 added a commit that referenced this issue Oct 25, 2024
@c4-bot-12 c4-bot-12 added 🤖_18_group AI based duplicate group recommendation 🤖_primary AI based primary recommendation labels Oct 30, 2024
howlbot-integration bot added a commit that referenced this issue Nov 4, 2024
@howlbot-integration howlbot-integration bot added the sufficient quality report This report is of sufficient quality label Nov 4, 2024
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 🤖_primary AI based primary recommendation 🤖_18_group AI based duplicate group recommendation sufficient quality report This report is of sufficient quality
Projects
None yet
Development

No branches or pull requests

2 participants