I have my own smart contract. Users on my webpage needs to first approve (increaseAllowance) and then they call "donate" function and part of the assets are sent to my vault and the other part goes to the address of another user.
Strange thing is that everything worked fine, after couple of months I think my app was hacked somehow. Now when user call increaseAllowance, assets are sent immediately to another smart contract I know nothing about. This happens before user call my true "donate" function and ofcourse call to my "donate" function fails, because assets are already drained.
tx = await tokenContract.increaseAllowance(smartContractAddress, amount, {
gasLimit: gasLimit,
gasPrice: gasPrice
});
After this call, assets are immediately sent to this contract: 0xa847991e081c2dcabc960839c8c2b92047fbc435
If you look to contract creator, there is warning:
This is malicious transaction: https://polygonscan.com/tx/0x2b6694c82f5ab8159111b15bc5fb2440a3d8d034927b4dfdab5d38f9a47d413f
Real transaction should look like this: https://polygonscan.com/tx/0x5a527c8fd1ca8bffc7f9393c5a97940ef10b71c64461c4caed928ddcab06a1cb
Can someone tell me how is this possible? User is giving permision for token transfer to my smart contract address and yet assets are sent out by malicious user to a contract I never interacted with.
** Noone lost any funds (except me, rly small amount) and I really wanna learn how to avoid such things. Thank you.