Skip to content

Latest commit

 

History

History
19 lines (12 loc) · 1.2 KB

SWC-119.md

File metadata and controls

19 lines (12 loc) · 1.2 KB

Title

Shadowing State Variables

Relationships

CWE-710: Improper Adherence to Coding Standards

Description

Solidity allows for ambiguous naming of state variables when inheritance is used. Contract A with a variable x could inherit contract B that also has a state variable x defined. This would result in two separate versions of x, one of them being accessed from contract A and the other one from contract B. In more complex contract systems this condition could go unnoticed and subsequently lead to security issues.

Shadowing state variables can also occur within a single contract when there are multiple definitions on the contract and function level.

Remediation

Review storage variable layouts for your contract systems carefully and remove any ambiguities. Always check for compiler warnings as they can flag the issue within a single contract.

References