People often ask me "How did you learn how to hack?" The answer: by reading. This page is a collection of the blog posts and other articles that I have accumulated over the years of my journey. Enjoy!
swap call._transfer function had code for figuring out the dividends for the stakers of the token. This is done with two lines of code:
_balances[uniswapV2Pair] = \
_balanceOf[uniswapV2Pair].add(contractTokenBalance);
_balances[address(this)] = \
_balanceOf[uniswapV2Pair].sub(contractTokenBalance);
if statement to trigger this functionality is trivial to trigger every time. So, an attacker can send very little FM to increase the amount owned by the uniswapV2Pair contract. This is NOT the intended functionality.skim function is for making the balances match the reserves. Without the bug above, this wouldn't matter. But, since we can desync these trivially, an attacker can call this function to get the difference between the contracts.skim function being callable by anyone is very strange. Overall, an interesting exploit.(dei balance * usdc balance) / total supply
delegateCall to call other implementation contracts. Its public functions are flash loan callbacks, which makes sense since it will use these for arbitrage opportunities. The callback for dYdX is interesting to look at.withdrawTokens in the StarstreamTreasury to send to 532,571,155.859 $STARS to themselves. The treasury's owner was this contract, which gave it complete control to do whatever it wants.__prototype__ object. By doing this, an attacker can overwrite the default properties of an object to cause all sorts of havoc. This is normally caused by blindly merging objects together. Does this similar vulnerability affect other languages?dunder (double underscore) methods such as __str__() and attributes such as __class__. In Python, it is possible to overwrite these properties at run time.__get/setattr__ and __get/setitem__ are used to set attributes about an object. If an attacker is able to set properties of a class arbitrarily using these functions, then we have class pollution. Similar to Prototype Pollution, this may happen when creating a Python class object from a JSON blob on the fly..__base__, an attacker can traverse up the hierarchy of objects indefinitely, with some limitations. The main limitation is that the field we want to overwrite must be in the same hierarchy in the inheritance chain. Or, the __globals can be traversed and overwritten with this as well!subprocess.Popen the author of the post overwrites the COMPSEC variable by traversing the globals to gain trivial command injection. There are an unlimited amount of primitives to view but many of them are going to be specific to the application in use.handleDeductFee() has no fee for incoming checks for who calls it and the amount. There were some other values that were controllable on this as well.MerkleRedeem's purpose is to distribute rewards. The original way this was architected only allowed for a single token per contract. This led the way for the Merkle Orchard contract, which allows for multiple tokens being claimable in a single contract. All rewards were in this contract.mint is used to create new bears within this ecosystem._safeMint from the OZ reference implementation. There is a map that checks to see whether or not a given address has minted an NFT. The safe is in regards to a check for the onERC721Received hook if it's a contract and has nothing to do with security.addressMinted is added at the end of the function. This violates the check-effects-use pattern. As a result, an attacker can mint the NFT and implement the hook within the _safeMint() function. Since the variable was not set, we can reenter the mintNFT function to create another one. Of course, this can be done as long as we can enough gas.