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

Re-entrancy attack allowed through underwriteLoan #6

Open
mrthankyou opened this issue Jul 28, 2021 · 0 comments
Open

Re-entrancy attack allowed through underwriteLoan #6

mrthankyou opened this issue Jul 28, 2021 · 0 comments

Comments

@mrthankyou
Copy link

Description of Bug

It is possible for a user to liquidate the PawnBank contract via the underwriteLoan function through a re-entrancy attack. This is caused by line 209:

(bool sent, ) = payable(loan.lender).call{value: _bidPayout}("");

and line 226:

loan.lender = msg.sender;

How to Reproduce The Bug

Let's assume the malicious actor has two contracts. The first contract will underwrite the loan for 1 ether. The second contract controlled by the same malicious actor will underwrite the same loan for 1.1 ether. On line 209, the PawnBank contract will deliver 1 Ether to the first contract. If the first contract is designed to call underwriteLoan again when it receives Ether, then the PawnBank contract will deliver another 1 Ether to the first contract. This results in a liquidation of the PawnBank contract.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant