properly verify sbpf v3 executables in loader at deploy / upgrade #617
Replies: 3 comments 5 replies
|
It is, should be, always has been and always will be possible to deploy broken binaries to mainnet. This sort of thing is not what the verifier exists to catch, and also why the current verifier catches almost zero edge cases. This is just one of hundreds of ways you could deploy a broken binary. After the program cache is fixed, we will eventually opt to remove the verifier from the loader entirely to unblock future core BPF migration and shift all verification of the binary to the JIT, and failing that, at runtime. This is not a runtime issue, it is a tooling and devex issue that is best solved before a program buffer ever touches the chain, not after a user has already gone through their program upgrade ceremony only to hit a wall on one of thousands of arbitrary ways you can produce an invalid binary. |
The
As mentioned above, the flag in #67 is provided by I think we can assume the vast majority of devs use While I agree this particular issue can be nasty, I think catching it in development is trivial for program developers. Any testing library or framework that runs through SVM will throw the Furthermore, we shipped tooling that can catch it in your binary as well, with #67. This will make its way into the Solana CLI, but devs don't have to wait for that, they can just update We will also publish a full SBPFv3 migration guide - geared towards Rust and assembly devs alike - with footguns like this explicitly detailed before moving SIMD-0500 back into the feature queue. All remedies thus far have been on the tooling side. The compiler itself still does not deem On the runtime side, we've actually long discussed removing the Agave provides a The idea is that the runtime should treat deployed bytecode just like any other user-provided input - such as transactions - and employ only the minimum required to protect the network from sabotage, gracefully handling invalid inputs by way of CUs and fees. This would mean letting the Loader program write pretty much anything into a program and letting the runtime deal with it during transaction processing. |
|
discussed with @buffalojoec and determined this is not best way forward |
Uh oh!
There was an error while loading. Please reload this page.
problem
relocations are removed in sbpf v3. this means that
extern "C"syscalls, which require relocation, are now invalid if used in sbpf v3.proposed solution
agave: add
Executable::verify::<LocalVerifier>();after theExecutable::verify::<RequisiteVerifier>();call insolana_program_runtime::deploy::deploy_program.rs.fd: add an equivalent to the
LocalVerifier'sCALL_IMMcheck inflamenco/vm/fd_vm.c:fd_vm_validatesig: add an equivalent in
v2/components/runtime/vm/executable.zig:Executable.verifymithril: add an equivalent in
pkg/sbpf/verifier.go:sbpf.(*Verifier).VerifyProgramwhy this
the minimum platform tools version that builds valid sbpf v3 is v1.53. this version does not contain the fix in anza-xyz/cargo-build-sbf/67 to add
-z defsto rustflags.the fix in anza-xyz/cargo-build-sbf/14910 only applies to
solana program deploy.we cannot assume:
solana program deploy(squads v4 does not)even if we do assume these things, it should not be possible to deploy a broken binary to mainnet. this effectively proposes a fix for what is a currently broken program verification process.
the only way to conclusively fix this is to reject the deploy / upgrade instruction. this necessitates a loader change. therefore it necessitates a simd.
All reactions