using tx.origin in access control checks #209
-
Is using |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Yes, it's still considered a serious security risk. The correct approach is to use Best practice: never use |
Beta Was this translation helpful? Give feedback.
Yes, it's still considered a serious security risk.
Using
tx.origin
in access control is unsafe because any contract that your user interacts with can trigger your contract, meaning that malicious contracts could trick users into executing actions as if they were authorized.The correct approach is to use
msg.sender
, which refers to the direct caller of the function, not the origin of the full transaction.Best practice: never use
tx.origin
for authorization logic, this hasn't changed.