Post 08 - Cryptocurrency

08 Dec 2022

Task 13, Day 08, Smart Contracts Last Christmas I gave you my ETH

First, before anything else, based on the title there is no way I’m watching the walkthrough video lest I be suckered into losing Whamageddon. Sneaky tip to MWRSecurity, if you don’t already have Wham’s Last Christmas playing quietly in the background, you should reshoot the video with it on a loop.

Smart Contract - program stored on blockchain that runs when predefined conditions exist.

Solidity, Vyper, and Yul languages developed for contracts, but contracts can be other languages like Rust or JavaScript.

Issues

Contracts can execute other functions while the first one is resolving. Logic errors could allow “if balance >0 withdraw $” multiple times before the balance is updated from the first funtion.

Re-entrancy Attack

Re-entrancy occurs when a malicious contract uses a fallback funtion to continue depleting a contract’s total balance due to flawed logic after an initial withdrawal function.

Fallback function can appear once in a single contract in Solidity. Function executes when Ether is transferred without context. In example, fallback can be triggered during initial function, since fallback doesn’t ask for balance and balance still exists in contract A, fallback runs again because Ether was transferred out of context. Executes in a loop until total balance is 0 instead of account balance.

The Task

Find the flag while examining task contracts.

When going to compile, need to have contracts selected first.

Not gonna lie, not my favorite process to go through.