Skip to content

Latest commit

 

History

History
18 lines (13 loc) · 1.33 KB

SWC-127.md

File metadata and controls

18 lines (13 loc) · 1.33 KB

Title

Arbitrary Jump with Function Type Variable

Relationships

CWE-695: Use of Low-Level Functionality

Description

Solidity supports function types. That is, a variable of function type can be assigned with a reference to a function with a matching signature. The function saved to such variable can be called just like a regular function.

The problem arises when a user has the ability to arbitrarily change the function type variable and thus execute random code instructions. As Solidity doesn't support pointer arithmetics, it's impossible to change such variable to an arbitrary value. However, if the developer uses assembly instructions, such as mstore or assign operator, in the worst case scenario an attacker is able to point a function type variable to any code instruction, violating required validations and required state changes.

Remediation

The use of assembly should be minimal. A developer should not allow a user to assign arbitrary values to function type variables.

References