{"id":13566123,"url":"https://github.com/CyberHoward/cosmwasm-re-entrancy-example","last_synced_at":"2025-04-03T23:31:06.775Z","repository":{"id":166886795,"uuid":"570081984","full_name":"CyberHoward/cosmwasm-re-entrancy-example","owner":"CyberHoward","description":"An example re-entrancy attack on a flashloan vault.","archived":false,"fork":false,"pushed_at":"2022-11-25T08:55:26.000Z","size":261,"stargazers_count":16,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2024-11-04T20:42:09.494Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CyberHoward.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-11-24T09:48:26.000Z","updated_at":"2024-09-10T23:07:24.000Z","dependencies_parsed_at":"2023-05-21T03:15:29.875Z","dependency_job_id":null,"html_url":"https://github.com/CyberHoward/cosmwasm-re-entrancy-example","commit_stats":null,"previous_names":["cyberhoward/cosmwasm-re-entrancy-example"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyberHoward%2Fcosmwasm-re-entrancy-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyberHoward%2Fcosmwasm-re-entrancy-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyberHoward%2Fcosmwasm-re-entrancy-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyberHoward%2Fcosmwasm-re-entrancy-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CyberHoward","download_url":"https://codeload.github.com/CyberHoward/cosmwasm-re-entrancy-example/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247097668,"owners_count":20883122,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T13:02:02.586Z","updated_at":"2025-04-03T23:31:04.901Z","avatar_url":"https://github.com/CyberHoward.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# CosmWasm re-entrancy Exploit Example\n\n\u003e The exploit example is located in `contracts/liquidity_hub/vault-network/exploit_contract`.\n\nA vault in `contracts/liquidity_hub/vault-network/vault` allows users to get a flashloan for a fee. \n\nThe user provide a callback for the flashloan which is sandwiched between the vault's own messages. The execution order is: \n\n- Call vault for flashloan\n- Vault sends tokens, executes the callback and **inserts its own callback**.\n- The calling contract executes whatever he wishes with the received funds\n- the vault callback executes.\n\nThe vault contract can ensure that all lent-out funds are returned by the lender by extending the `Response` with a callback [`vault::CallbackMsg::AfterTrade`]. This callback is ensured to be the last call in the execution order. \n\nThe edge-case that was overlooked was the case in which the lender performs a deposit with his lent funds. This edge-case is shown to be exploitable in `tests/exploit.rs`. \n\n## Run\ncd into `contracts/liquidity_hub/vault-network/exploit_contract` and run `cargo test`. The exploit test can be viewed in `tests/exploit.rs`.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCyberHoward%2Fcosmwasm-re-entrancy-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FCyberHoward%2Fcosmwasm-re-entrancy-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCyberHoward%2Fcosmwasm-re-entrancy-example/lists"}