Falha na Inicialização (Failure to Initialize)
contract VulnerableContract {
address public owner;
function initialize(address _owner) external {
owner = _owner;
}
function pauseContract() external {
require(msg.sender == owner, "Not the contract owner");
// Lógica para pausar el contrato
}
}contract SecureContract { address public owner; constructor(address _owner) { owner = _owner; } function pauseContract() external { require(msg.sender == owner, "Not the contract owner"); // Lógica para pausar el contrato } }contract SecureContract { address public owner; bool private initialized; function initialize(address _owner) external { require(!initialized, "Already initialized"); owner = _owner; initialized = true; } function pauseContract() external { require(msg.sender == owner, "Not the contract owner"); // Lógica para pausar el contrato } }modifier onlyInitialized() { require(initialized, "Contract not initialized"); _; } function pauseContract() external onlyInitialized { require(msg.sender == owner, "Not the contract owner"); // Lógica para pausar el contrato }
Last updated