Suppose I have a contractA with an add function to add numbers with an onlyOwner modifier. This function calls a library to update the number, but the library is deployed as a standalone entity, and the add function is marked as external. Can an attacker call the external library function in the context of contractA and bypass the ownership check in contractA?
1 Answer
No
Solidity libraries, even when deployed as standalone contracts, do not hold state and do not have access to the storage of contracts that use them.
If a user calls Contract B that uses the logic of a function of a library that Contract A (That has an onlyOwner
modifier) uses, it would not change Contract A's state.