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

feat: add dynamic callstack for prevent the re-entrancy attack #178

Merged
merged 5 commits into from
Apr 28, 2022

Conversation

brew0722
Copy link
Contributor

@brew0722 brew0722 commented Apr 1, 2022

Description

Closes #155 Finschia/wasmvm#62

  • add dynamic callstack for prevent the re-entrancy attack
  • add max call depth limitation

about integration test,
cannot make the test logic with multiple contracts in the cosmwasm repo.
So I tested manually via try_reentrancy msg of dynamic_caller_contract.
Reentry is well blocked like this(A->B->A):

{"height":"7","txhash":"066247EDDA6EB99AD88027D3B4B22A67434EBDC65CC87D7BB00E156A1D5865B9","codespace":"wasm","code":5,"data":"","raw_log":"failed to execute message; message index: 0: Error calling the VM: Error executing Wasm: Wasmer runtime error: RuntimeError: func_info:{module_name:dynamic_callee_contract, name:stub_reentrancy, signature:[I32] -\u003e []}, error:Unknown error during call into backend: Some("Error executing Wasm: Wasmer runtime error: RuntimeError: func_info:{module_name:dynamic_caller_contract, name:stub_should_never_be_called, signature:[] -\u003e []}, error:User error during call into backend: A contract can only be called once per message."): execute wasm contract failed","logs":[],"info":"","gas_wanted":"200000","gas_used":"67989","tx":null,"timestamp":""}

In order to put the above integration tests structurally into code, it need to go into lbm's cli_test.
So This will be done after merging into main in the future.

Types of changes

  • Bug fix (changes which fixes an issue)
  • New feature (changes which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • ETC (build, ci, docs, perf, refactor, style, test)

Checklist

@brew0722 brew0722 added enhancement New feature or request dynamic_link relate the dynamic link call feature labels Apr 1, 2022
@brew0722 brew0722 self-assigned this Apr 1, 2022
@brew0722 brew0722 force-pushed the virtual_callstack branch 2 times, most recently from 6d59eef to c40b1da Compare April 8, 2022 04:44
@brew0722 brew0722 marked this pull request as ready for review April 8, 2022 05:49
Jiyong Ha added 3 commits April 11, 2022 13:49
Even in a running existing contract, a wasmer instance is newly created every call.
cannot use the wasmer instance for check the duplication.
@brew0722
Copy link
Contributor Author

rebased to squash merged PR(#182).

Copy link
Contributor

@shiki-tak shiki-tak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@brew0722 brew0722 merged commit 990b9e1 into Finschia:dynamic_link Apr 28, 2022
@brew0722 brew0722 deleted the virtual_callstack branch April 28, 2022 02:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dynamic_link relate the dynamic link call feature enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants