is_permissioned() It doesn't make sense to have permissions by default after Blacklisted expires
The permission check function returns true when a blacklist entry has expired, regardless of whether the action requires permission. An attacker could gain unauthorised access to permissioned actions after their blacklist expires.
pub fn is_permissioned(&self, env: &Env, strict: bool) -> bool {
match self {
Self::Blacklisted(expiration) => {
if let Some(expiration) = expiration {
if expiration.is_expired(&env.block) {
- return true;
+ return !strict;
}
}
false
}
Self::Limited { expiration, uses } => {
if let Some(expiration) = expiration {
if expiration.is_expired(&env.block) {
return !strict;
}
}
if *uses == 0 {
return !strict;
}
true
}
Discussion
J4X-98
Escalate
This is intended behavior. The documentation (code comments) describes the intended behavior as follows:
Rust
/// An enum to represent a user's permission for an action
///
/// - **Blacklisted** - The user cannot perform the action until after the provided expiration
/// - **Limited** - The user can perform the action while uses are remaining and before the provided expiration **for a permissioned action**
/// - **Whitelisted** - The user can perform the action until the provided expiration **for a permissioned action**
///
/// Expiration defaults to `Never` if not provided
#[cw_serde]
pub enum Permission {
Blacklisted(Option<Expiration>),
Limited {
expiration: Option<Expiration>,
uses: u32,
},
Whitelisted(Option<Expiration>),
}
The documentation clearly states that the intended behavior for a blacklisted user is "The user cannot perform the action until after the provided expiration". So the user should be able to regain possibility to take actions after expiry which is the whole "vulnerability" described by this group of issues.
sherlock-admin3
Escalate
This is intended behavior. The documentation (code comments) describes the intended behavior as follows:
Rust
/// An enum to represent a user's permission for an action
///
/// - **Blacklisted** - The user cannot perform the action until after the provided expiration
/// - **Limited** - The user can perform the action while uses are remaining and before the provided expiration **for a permissioned action**
/// - **Whitelisted** - The user can perform the action until the provided expiration **for a permissioned action**
///
/// Expiration defaults to `Never` if not provided
#[cw_serde]
pub enum Permission {
Blacklisted(Option<Expiration>),
Limited {
expiration: Option<Expiration>,
uses: u32,
},
Whitelisted(Option<Expiration>),
}
The documentation clearly states that the intended behavior for a blacklisted user is "The user cannot perform the action until after the provided expiration". So the user should be able to regain possibility to take actions after expiry which is the whole "vulnerability" described by this group of issues.
You've created a valid escalation!
To remove the escalation from consideration: Delete your comment.
You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.
cvetanovv
I don't see a problem here. NatSpec comments highlight that when a user is blacklisted, it is expected after a while to be able to regain the possibility to take action after the restriction expires.
Planning to accept the escalation and invalidate the issue.
bin2chen66
/// - Blacklisted - The user cannot perform the action until after the provided expiration
The way I understand this sentence is.
Suppose action is permissionless (strict=false) and can be executed by anyone. But the administrator can restrict someone from performing it, for example by blacklisting alice so that alice cannot perform the action until after the provided expiration.
Example: Suppose withdrawal doesn't need permissions, but the administrator finds out that alice is acting maliciously and blacklists alice for 1 month, so that alice can't withdraw funds Within this month.
But the problem is, if later the administrator decides to make the action withdrawal require permissions by default, i.e.: change strict=true.
But, since alice was previously blackballed and expiration, alice now becomes permissioned instead (Current code returns true.). This does not make sense.
So the blacklisting mechanism, like the other two Limited and Whitelisted, should expire as if it was not set, and go back to the way it was, i.e. !strict, instead of returning true.
J4X-98
Hey @bin2chen66 ,
There is no default limitation state. As you can see on both the other roles, they also return true if they are not limited by expiration/uses. So effectively blacklist goes to the "default" state after expiration.
bin2chen66
hey @J4X-98
sorry , I didn't get what you meant.
if strict=true
current code:
Limited expiration return !strict = false (No permission)
Whitelisted expiration return !strict = false (No permission)
Blacklisted expiration return true (have permission) --> This is the key point, if it expires it should be the same as if it wasn't set up, and doesn't have permissions
J4X-98
Hey @bin2chen66 ,
All the functions only return '!strict' if the user is not allowed by either their whitelist having expired or them not having any uses left. Otherwise the 2 others also return true by default. So there seem to only be 2 intended states:
user is not allowed -> return '!strict'
User is allowed -> return 'true'
And the implementation implements this as intended.
The mediation you recommend would lead to the user still not having permissions after the blacklist expired, leading to a conflict with the description of the functionality.
bin2chen66
hey @J4X-98
Returning true is only good for the strict=false case
In the case of strict=true, returning true would be a serious security issue
That's what this issues mentions.and the sponsor seems to have confirmed this question: Labels :“Sponsor Confirmed "
J4X-98
Hey @bin2chen66 ,
What you recommend is returning !strict, which is the same behavior as when the blacklisted has not expired. This collides with the intended behavior of the user, regaining the possibility of action. The current behavior is
Blacklist is not expired:
strict -> return false
!strict-> return true
Blacklist is expired:
strict-> return true
!strict-> return true
So as a result, the user regains access to strict functions when the blacklist has expired, which adheres to the behavior described by the documentation.
Your proposed mitigation would result in the function always returning !strict, doesn't matter if the blacklist has expired or not, which would make the whole expiration process redundant and would not adhere to the documentation. The function is currently implemented in the way it is documented and does not lead to any vulnerabilities. You are describing intended behavior as a vulnerability, and your mitigation would break intended behavior.
gjaldon
The statement below from this comment is incorrect:
So effectively blacklist goes to the "default" state after expiration.
The "default" state is no access and not upgraded access.
Also, the issue is that when the blacklist expires, the user's permission is upgraded to the level of a non-expired whitelisted user. A non-expired whitelisted user has access even to strict permissioned actions. It does not make sense for a blacklisted user to become whitelisted on expiration. In the NFT ADO Contract, this would mean the expired blacklisted user can arbitrarily mint NFTs like the minter role.
J4X-98
Hey, what you are missing is that a user can only be in two states as the current implementation works. These are either returning !strict or true all the time.
"The "default" state is no access and not upgraded access." -> The default state (which does not exist) you describe always returns false. So in your opinion, while a user is blacklisted, he should be able to access some functionalities that are not strict. Once the blacklist expires, the user should not be able to access anything anymore. This makes no sense and clashes with the documentation of the user regaining access once the blacklist has expired.
It might be a future improvement to change the whole system to add more states that allow for more detailed control of the user's permissions. But for the current states, the contract can choose from there are only 2, and the implementation correctly uses one of those (the restricted one) while the user is blacklisted and the other one (no restrictions) once the blacklist has expired. This confirms the documentation, so there is no vulnerability; it is just a recommendation for future improvement.
cvetanovv
I agree with @J4X-98 comments that this is expected behavior. My early decision remains to accept the escalation and invalidate the issue.
gjaldon
@cvetanovv although the comment is correct, it does not completely describe the current behavior of blacklisting.
Blacklisted - The user cannot perform the action until after the provided expiration
After the blacklisting expires, the user gains whitelisted privileges. It's unclear just based on the comment if the dev team intends to increase a user's permissions to greater than a regular user once their blacklist expires.
Also, isn't the dev team fixing the issue? Doesn't that confirm it?
J4X-98
As described in multiple of the messages above there is no default behavior. There only is returning !strict or true and those are correctly used by the contract.
Repeating the same invalid argument countless times does not make it more true. The judge has already twice confirmed that this issue is invalid, I don't see a reason to continue this discussion.
gjaldon
Hi @J4X-98. Thank you for your opinions.
I presented 2 new arguments which are:
The comment does not completely describe the current behavior of blacklisting
The dev team is fixing the issues, which seems to confirm it
The only way to know the intended functionality is to ask the dev team, especially since it is tagged as Will Fix.
J4X-98
Hey, I think the comment pretty clearly describes the intended behavior "Blacklisted - The user cannot perform the action until after the provided expiration". The user should not be able to access permissioned functions while blacklisted and should be able to do so once the blacklist has expired. This is exactly what happens in the code.
gjaldon
But does it make sense for a previously blacklisted user's privileges to be escalated to the level of a whitelisted user? The comment does not mention anything about that.
It looks like an unintended privilege escalation.
cu5t0mPeo
This seems to be a mistake. I asked the sponsor, but it was after the competition.
gjaldon
I really appreciate your input, @cu5t0mPeo. 🙏🏼
The sponsor has confirmed this as an issue @cvetanovv. It is an unintended privilege escalation. Sorry for all the discussion. Hope that's enough to validate the issue and reject the escalation.
cvetanovv
After the sponsor confirms that this is not an intended design, I will reject the escalation and leave the issue as is.
The original report as published on Sherlock, by bin2chen. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Generating the AI write-up for this report.
This usually takes about a minute. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
How it worked
Root cause
The code returns true for an expired blacklist instead of returning the default permission state based on the strict flag.
Impact
A user whose blacklist has expired gains permissions they should not have, potentially allowing them to perform restricted actions.
What the attacker needed
A blacklisted user; blacklist expires; action changed to require permission
The fix
The issue was fixed by changing the return value for an expired blacklist to `!strict`.
How it was found
An action is initially permissionless (strict = false).
The administrator blacklists alice for one month.
After more than one month, the blacklist expires.
The administrator changes the action to require permission (strict = true).
The permission check for alice returns true, granting her access.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Generating the AI write-up for this report.
This usually takes about a minute. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
A smart contract has a permission system where users can be blacklisted for a period. When the blacklist expires, the code incorrectly treats the user as fully allowed, even for actions that normally require special permission. This means a previously blocked user could suddenly do things they shouldn't be able to do.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.