Skip to content
This repository has been archived by the owner on Jul 11, 2019. It is now read-only.

Improve safety checks for the upgradeability mechanism #28

Closed
facuspagnuolo opened this issue Apr 10, 2018 · 7 comments
Closed

Improve safety checks for the upgradeability mechanism #28

facuspagnuolo opened this issue Apr 10, 2018 · 7 comments
Assignees
Labels
kind:enhancement An upgrade or a new feature that improves the system topic:security Security reviews and considerations
Milestone

Comments

@facuspagnuolo
Copy link
Contributor

facuspagnuolo commented Apr 10, 2018

The current upgradeability model only prevents you from registering or upgrading to a zero address. Apart from that, it does not check if you upgrade a contract to a version registered for another contract, or if the contract that you are upgrading follows whatever was required by your previous version (e.g. storage or function signatures), etc.

We should explore how we can improve current model to handle most of these scenarios preventing projects from registering and/or upgrading to undesired addresses.

@facuspagnuolo facuspagnuolo added kind:enhancement An upgrade or a new feature that improves the system topic:upgradeability Upgreadeability for user contracts labels Apr 10, 2018
@facuspagnuolo
Copy link
Contributor Author

@frangio you raised this issue, please add your ideas or edit the description directly, thx!

@facuspagnuolo facuspagnuolo added this to the v0.1.0 (Kernel MVP) milestone Apr 10, 2018
@frangio
Copy link
Contributor

frangio commented Apr 10, 2018

it does not ensure whether you upgrade a contract to a version registered for another contract

This refers to the fact that the upgradeTo function signature allows to change a proxy's implementation to any other contract, by sending an unrelated contractName.
https://github.com/zeppelinos/core/blob/519f4a0005113b4c0c7a6f315c30f56032239911/contracts/ProjectController.sol#L87

I see this as a problem in the conceptual model. Proxies' implementations should only be upgraded to other compatible implementations.

The current notion of compatibility between older and newer implementations seems to be that they have the same contractName. Thus, the solution would be to change upgradeTo to have signature upgradeTo(proxy, version) (or possibly upgradeTo(proxy, distribution, version)). ProjectController will need to keep track of the contractName corresponding to each Proxy.

This leaves out the possibility of upgrading from ERC721Basic to ERC721Full, so we may need to define a more general notion of compatibility. This ties into the idea of migrations. We could define compatibility between X and Y as: there is a migration from X to Y. I feel like this is a very powerful abstraction, but it may also be too complex.

@frangio
Copy link
Contributor

frangio commented Apr 10, 2018

if the contract that you are upgrading follows whatever was required by your previous version (e.g. storage or function signatures)

This is not possible to do on-chain. Off-chain, we could and should definitely check some of these things. Storage layout (#63) is the obvious one. I think these checks should part of our toolchain to register new versions.

@frangio
Copy link
Contributor

frangio commented Apr 10, 2018

Additionally, a very simple one that we should add is checking that an implementation has any code in it (via extcodesize), when it is registered.

@spalladino spalladino added topic:security Security reviews and considerations and removed topic:upgradeability Upgreadeability for user contracts labels Apr 12, 2018
@frangio frangio self-assigned this Apr 19, 2018
@frangio
Copy link
Contributor

frangio commented Apr 23, 2018

Simple safety check added in #53.

Opened a spin-off issue in #63.

I'm leaving this issue open because it's something that we should keep thinking about.

@facuspagnuolo facuspagnuolo modified the milestones: v0.1.0 (Kernel MVP), v0.2.0 May 10, 2018
@facuspagnuolo facuspagnuolo modified the milestones: Backlog, Sprint #2, v2.0.0 Jun 5, 2018
@frangio
Copy link
Contributor

frangio commented Jul 16, 2018

See zeppelinos/zos-cli#320 for another safety issue to tackle.

@facuspagnuolo
Copy link
Contributor Author

I'm closing this issue since we are already exploring some improvements in separate issues. In case we decide to tackle any other particular edge case or scenario, we could open another issue for that. Improving safety is something that never ends :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind:enhancement An upgrade or a new feature that improves the system topic:security Security reviews and considerations
Projects
None yet
Development

No branches or pull requests

3 participants