File size: 578 Bytes
31ea9b2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// 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);
    }
}