solidity-audit-ai / samples /vulnerable /AccessControl.sol
LaelaZ's picture
Deploy Solidity Audit AI to HF Spaces (Docker)
31ea9b2 verified
raw
history blame contribute delete
578 Bytes
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title UnguardedVault
/// @notice Sensitive functions lack access control.
contract UnguardedVault {
address public owner;
constructor() {
owner = msg.sender;
}
function deposit() external payable {}
// VULNERABLE: anyone can change the owner.
function setOwner(address newOwner) external {
owner = newOwner;
}
// VULNERABLE: anyone can drain the contract.
function withdrawAll(address payable to) external {
to.transfer(address(this).balance);
}
}