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

onlyOwner spoofing #1

Closed
pingleware opened this issue Dec 22, 2021 · 3 comments
Closed

onlyOwner spoofing #1

pingleware opened this issue Dec 22, 2021 · 3 comments

Comments

@pingleware
Copy link
Owner

This is a serious flaw with smart contracts that use onlyOwner permissions, because a person can just needs to know the public owner address and then can invoke the RPC eth_call passing setting the sender with the owner address and now can hijack the smart contract?

Research is needed for best practices to prevent onlyOwner spoofing.

pingleware pushed a commit that referenced this issue Dec 22, 2021
@pingleware
Copy link
Owner Author

I fixed the onlyOwner spoofing by including a signed hash to verify the owner signature. I discovered from a DAPP, you can spoof the msg.sender by setting the from: attribute in the web3 call. A more secure method, is the owner creates a signed hash with a signature and passes both the onlyOwner method which will verify the contract owner and hash owner are the same.

@pingleware
Copy link
Owner Author

According to SWC-121,122, and 123 ecrecover is NOT recommended to obtain the signer from the signature/hash. EIP-712 implementation is the preferred method for recovering the signer of a signature/hash as defined at https://soliditydeveloper.com/ecrecover. The new Owner.sol contract uses a custom safer ecrecover method.

https://swcregistry.io/docs/SWC-121
https://swcregistry.io/docs/SWC-122
https://swcregistry.io/docs/SWC-123
ethereum/EIPs#1469
https://soliditydeveloper.com/ecrecover

@pingleware
Copy link
Owner Author

Fixed by including a signed message for onlyOwner. An okOwner function is provided which only checks the msg.sender against the contract owner.

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

1 participant