Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S08:绕过合约检查 預防辦法部分可能有漏洞 #432

Closed
RoyHonChain opened this issue Mar 7, 2023 · 1 comment
Closed

S08:绕过合约检查 預防辦法部分可能有漏洞 #432

RoyHonChain opened this issue Mar 7, 2023 · 1 comment

Comments

@RoyHonChain
Copy link
Contributor

RoyHonChain commented Mar 7, 2023

以下這一段內容 是不是可能有漏洞
你可以使用 (tx.origin == msg.sender) 来检测调用者是否为合约。如果调用者为 EOA,那么tx.origin和msg.sender相等;如果它们俩不相等,调用者为合约。

假設背景設定為:

  • EOA、合約A(惡意合約)、合約B(檢查是否為合約)
  • 合約A裡面有個函數是delegatecall另外一個合約

操作為:

  1. 我用EOA -call-> 合約A
  2. 合約A -delegatecall->合約B

那我在合約B看到的 tx.origin 與 msg.sender 都為我的 EOA
這樣是否就繞開合約檢查了呢?

image

當然這麼做可能意義不大,因為語境在合約A,合約B的資料理應不受影響。
但還是可以繞開檢查

@AmazingAng
Copy link
Owner

Delegatecall合约B不会改变B的状态,而是改变A(恶意合约)。
你再看看delegatecall章节

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants