智能合约漏洞——通过tx.origin授权(Authorization Through tx.origin)

通过tx.origin授权(Authorization Through tx.origin)

  tx.origin(原始交易发起者的外部地址)是一个全局变量,它返回发送交易的地址。重要的是千万不要使用tx.origin,因为另一个合约会使用fallback函数来调用你的合约并获得授权,授权地址存储在tx.origin中。

  考虑以下案例,首先你部署了一个TxUserWallet合约:

// This contract contains a bug - do not use
contract TxUserWallet {
    address owner;

    constructor() public {
        owner = msg.sender;
    }

    function transferTO(address payable dest, uint amount) public {
        require(tx.origin == owner);
        dest.transfer(amonut);
    }
}

  上述我们可以看出TxUserWallet通过tx.origin授权了transferTO()。

  然后是攻击合约TxAttackWallet:

interface TxUserWallet {
    function transferTo(address payable dest, uint amount) external;
}

contract TxAttackWallet {
    address payable owner;

    constructor() public {
        owner = msg.sender;
    }

    function() external {
        TxUserWallet(msg.sender).transferTo(owner, msg.sender.balance);
    }
}

  如果有人现在欺骗你向TxAttackWallet合约地址发送ETH,攻击者可以检查tx.origin找到发送交易的地址来窃取你的资金。

  所以为了防止这种攻击的发生,一般使用msg.sender。

hadoop.security.authorization=true是Hadoop的一个配置选项,用于开启ServiceLevel Authorization。当设置为true时,Hadoop会对用户进行验证,并根据配置的访问控制列表(ACL)来限制用户对Hadoop服务的访问权限。\[1\]这意味着只有被授权的用户才能执行特定的操作,其他用户将被拒绝访问。如果设置为false,则不会进行任何验证,所有用户都将拥有全部权限。\[1\] 要修改hadoop.security.authorization的配置,需要重启Hadoop服务。你可以在Hadoop的配置文件中找到这个选项,并将其值修改为true或false。例如,在hdfs-site.xml文件中,你可以找到以下配置项: <property> <name>hadoop.security.authorization</name> <value>true</value> </property> \[2\] 如果你尝试执行未经授权的操作,你可能会收到类似以下的错误消息: User xxx (auth:SIMPLE) is not authorized for protocol interface org.apache.hadoop.hdfs.protocol.ClientProtocol: denied by configured ACL \[3\] 这表示用户xxx没有被授权执行指定的操作,可能是由于ACL配置的限制导致的。因此,开启ServiceLevel Authorization可以提高Hadoop集群的安全性,确保只有经过授权的用户才能访问和操作Hadoop服务。 #### 引用[.reference_title] - *1* *2* [Hadoop 权限管理](https://blog.csdn.net/iteye_4515/article/details/82435582)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [如何控制 hadoop 的用户访问权限](https://blog.csdn.net/h952520296/article/details/107937020)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值