Skip to content

Unrestricted sweepToken Function

Description

The sweepToken function is allowed to be called by anyone, potentially leading to unauthorized access and control. This is a case of improper access control, where the function's accessibility is not restricted to authorized users.

Examples

Insecure Code

solidity
function sweepToken(...) {
  token.transfer(...);
}

Secure Code

solidity
function sweepToken(...) {
  require(msg.sender == admin, "...");
  token.transfer(...);
}

Remediation

Add a require statement to restrict access to the sweepToken function, such as require(msg.sender == admin, "...");

Rule Details

FieldValue
IDCODE-0678
CategoryAccessControl
SeverityHIGH
CWECWE-284
ConfidenceMEDIUM
ImpactHIGH
LikelihoodLOW
ExploitabilityMODERATE
Tagsaccess control, solidity
OWASPN/A

References