03.SWC-103_Floating Pragma
2023-07-13 16:10:42 # 09.SWC

SWC-103_Floating Pragma

Floating Pragma

  • Description: Contracts should be deployed with the same compiler version and flags that they have been tested with thoroughly. Locking the pragma helps to ensure that contracts do not accidentally get deployed using, for example, an outdated compiler version that might introduce bugs that affect the contract system negatively.

  • Remediation: Lock the pragma version and also consider known bugs (https://github.com/ethereum/solidity/releases) for the compiler version that is chosen.

    Pragma statements can be allowed to float when a contract is intended for consumption by other developers, as in the case with contracts in a library or EthPM package. Otherwise, the developer would need to manually update the pragma in order to compile locally.

vulnerable contract:

1
2
3
4
5
6
pragma solidity ^0.4.0;
// fix: pragma solidity 0.4.25;

contract PragmaNotLocked {
uint public x = 1;
}
Prev
2023-07-13 16:10:42 # 09.SWC
Next