-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Stricter contract checks inside Contract.Create and Contract.Update #2030
Comments
Thinking about it, I agree with @Qiao-Jin here (#1883 (comment)) , for example we can't check a valid script without executing the script.
It's a valid script and you can't parse if it's valid without execute it. |
JMP offsets are actually trivial to check without executing them (it can even be done in the same single pass over the bytecode with opcode checks, |
I've probably missed the main point. Of course the check would say that this particular script is invalid and it's perfectly fine for me. We accept some bytecode to store and execute in a public setting, I think it implies some responsibility for it, so if we can with reasonable effort prevent some errors and misbehavior we better do that. And Contract.Create/Update syscalls is just where it all happens, either contract (and manifest) gets accepted or not, that's why it has to be done there. |
Validate only abi and manifest it's ok for me |
We can start with that, it's easier and it already adds some value. |
@shargon the point is having something syntatically correct, at least, which "your eyes" have done already in your example hahaha |
Before I forget... again, I think we should check the integrity of all scripts, even Verification/Witness scripts. If we do that, and we are certain that previous Neo2 scripts will fail on Neo3, then on Neo layer (not NeoVM), we can support some "if" case that allows mapping from previous standard Neo2 script (with CHECKSIG opcode) to equivalent standard Neo3 script. This does not cover all cases, but if it covers 99% of users, that's very good (specially those who may be "left behind" during migration). Again, this "if" would skip execution from Neo3-VM, and manually execute the check (21 + pubkey + ac). |
Summary or problem description
We do almost no checks for contracts and manifests deployed and I think it's a problem. At the moment one can deploy some
/dev/urandom
contents as a script with almost any garbage in the manifest (the only restriction is ABI hash and group signature correctness) and it will be happily accepted by the chain. I don't think it gives us any benefits, in fact it could be beneficial to provide a bit more guarantees to our users by stricter checks of contracts on their creation/update.Do you have any solution you want to propose?
We have #1883 for one specific problem already, but I'd like to outline some other things we can check:
Notice that there is a check for that implemented in Update deploy command following NEO3 schema neo-node#463, but IMO it's done in the wrong place.
Of course Neo-vm returns ANY when invoking a script at an address that is outside of its bounds neo-vm#376 should also be handled in the
Contract.Call
or VM to fail at that level, but I think it's not enough, incorrect manifest shouldn't be deployed in the first place.It sure will add some overhead to these calls, but TPS metrics are absolutely irrelevant here IMO, because contract creation/update is non-frequent and costly operation. We can do that and this service is being paid for (hi, #2001 also). At the same time we will surely prevent some (not all, of course) errors and tricks that could be done and provide more predictable and safer execution environment.
Neo Version
Where in the software does this update applies to?
The text was updated successfully, but these errors were encountered: