Ohwale (@dedohwale) header
Ohwale (@dedohwale) profile picture

Dark scholar of web3. Delving into the abyss, ensuring smart contract security, and optimizing gas in the face of the void. 🌑 ☠️ 🔗

Joined July 2022
Photo by Ohwale (@dedohwale)Photo by Ohwale (@dedohwale)Photo by Ohwale (@dedohwale)Photo by Ohwale (@dedohwale)Photo by Ohwale (@dedohwale)Photo by Ohwale (@dedohwale)Photo by Ohwale (@dedohwale)Photo by Ohwale (@dedohwale)Photo by Ohwale (@dedohwale)Photo by Ohwale (@dedohwale)
Introducing #DedEthAudits: Empowering the security of your Solidity contracts. Our experienced auditors (@DedOhwale, @Arzdev, @Solidityauditor), nurtured by contests and private audits, are your blockchain guardians 🛡️. DM 📩 me for a quote today!
1
1
19
4,859
📝 Solidity Quiz Time What can go wrong with `createPrivatePool()`? ⚠️ Note: `cloneDeterministic()` is from Solady.
2
13
1,014
📝 Solidity Quiz Time What happens when we call `doCall()` here?
3
2
22
1,816
📝 Solidity Quiz Time What does the `callSomeStateVar()` return?
2
1
9
429
📝 Solidity Quiz Time What does the following return?
7
2
13
895
@X3agleX @MalikAremu1 @bitamg2021 @nizhunt The more extended testing script returns 42, x, x, x where x is the memory location. Within execute, the memory persists and the `temp=ops` line assigns the ops memory location to temp. So, when we change temp, we change ops.
1
7
330
Gas Quiz ⛽️❓ Which will cost less?
6
1
12
1,719
(1/6) ⚔️Solidity Attack Vector⚔️ Piece-wise functions When calculating a piece-wise function, there is almost always a point of vulnerability. Let's take a look at a similar example from my recent medium finding. 👇🧵
1
7
1
59
4,795
(2/6) In the example above, we are calculating how many shares to give an individual. 🧮 1. Suppose `totalShares == 0`: A user can send ANY amount of tokens > 1000, and instead, only receives 1000 shares. This cannot be intended behavior.
1
1
314
📚 Solidity Quiz #1📚 What happens if we call `updateData` from the `CallerContract`? Quick run-down of this in 24hrs. ⌛️
7
1
23
1,996
I was going to break it down, but it looks like you guys got it handled! Delegate call needs to be treated with respect, it is a very powerful yet risky call.
209
(1/10)⚔️Solidity Attack Vector⚔️ Forcibly Sending Ether Suppose we have some contract which uses `address(this).balance` within the logic. The first thing to consider is what would happen if we could forcibly send ether to this contract? Could you break the attached? 👇🧵
1
1
1
30
3,341
(2/10) The `selfdestruct` function in Solidity provides a mechanism to destroy a contract and send its funds to another address. 🧨 When `selfdestruct` is called: 1. Ether is sent to the address given 2. Code and state are removed Does it matter what the address is?
1
1
177
(1/4) ⚔️Solidity Attack Vector⚔️ Contract Check A protocol may want to check if the sender is a contract or EOA. To do so, they may look at the code size, as EOA's will return 0. What is wrong with the below implementation? 👇🧵
1
1
43
2,846
(2/4) When is this used? Generally, as a part of an access control mechanism - limiting the accessibility to EOAs exclusively. Voting mechanisms where direct human intervention is preferred comes to mind.
1
4
225
(1/7) ⚔️Solidity Attack Vector⚔️ 1 Wei Attack Suppose we have a vault, where users can deposit assets & in turn receive shares. Then, they can exchange those shares for assets, usually with some interest rate bonus. What is wrong with the below implementation? Answer 👇🧵
5
33
1
160
13,385
(2/7) The "1 Wei Attack" is an exploitation of some DeFi platforms' vaults or liquidity pools, specifically those employing AMMs. This attack takes advantage of the lack of slippage protection which leads to asset dilution and potential loss of funds for unsuspecting users.
1
7
862
(1/2) ⚔️Solidity Atk Vectors⚔️ Let me share 2 more attack vectors with you: 1. Access Control - make sure it is done right & cannot be passed incorrect values 2. Account Existence - do 0 address checks. Check account state if necessary. 🧵👇
1
7
39
4,101
(2/2) Account Existence is especially important when conducting low-level calls such as `call`, `delegatecall`, and `staticcall`. These return true if the account called does not exist. See the warning here ⚠️: docs.soliditylang.org/en/dev…
1
3
376
🚨 Solidity Security Tip 🚨 Be careful with your boolean revert checks! If function 1 & 2 should always have differing behavior, make sure that occurs. If a = false, and b = c, what happens with the attached? How would you fix it? H-03 👇 code4rena.com/reports/2022-1…
1
3
34
1,493
(1/8) Solidity Attack Vectors ⚔️ I have completed my second audit - let me share with you two method of attacks I have used so far, and how you can apply them to your next audit. 1) Reentrancy 2) Math 🧵👇
1
11
48
3,107
(2/8) Reentrency: If you are unfamiliar with this type of attack, here is a summary: teapawt.net/dedohwale/status/16307… So, we need to look for low-level calls which do not follow the checks, effects, interactions pattern. While you are looking at these calls, find the uncheck returns.
(1/6) 🚨 Solidity Security Tip 🚨 Reentrancy attacks broken down: 1️⃣ What is a fallback function? 2️⃣ How can it be used in an attack? 3️⃣ How can we prevent it? Let's dive in 🧵👇
1
2
439
💡Solidity + Networks💡 Auditing tool #2 Visualize the function breakdown in a clear and intuitive way. I will be adding metrics to size nodes based on "importance" for focused efforts while auditing. Again, free with the course. 🔜 🎓
2
9
49
3,160
💡Solidity + Terminal💡 Never scoff at the low-level tools as your disposal. I have written a script specifically for solidity auditing that uses `awk`, `grep`, `echo`, and a few other standard terminal commands. Free for everyone who takes the course. Sneak peak. 👇
5
3
44
3,369
(1/12) ⛽️ Gas Optimization I have a mapping between uint8 and bool. With uint8, we have the maximum number representable being 255. That is, we have 256 different slots to store boolean values. In this mapping, each slot stores a boolean. What would you do? Answer 👇
1
5
2
26
2,822
(2/12) Mappings can only be stored in storage, not memory. storage_slot = keccak256(k+p) % 2**256 We use keccak256 to find the storage slot, where k is the key, p is the position of the mapping, + is concatenation. Solidity does not actually store the keys.
1
189
⛽️ Gas optimization ♻️ Loops Loops are an expensive process in general, make sure they are optimized for some significant gas savings. Attached is an unoptimized loop contract. What is done right? Try to optimize this on your own. The answer is next. 👇
2
9
1
41
2,613
Firstly, we like that it is `pure` - this tells the compiler that we are not reading from storage at all, nor changing anything there. `view` tells the compiler that we will be reading from storage but not changing it, so `pure` is a step up.
1
4
190
⛽️ Gas Optimization Tip Whenever applicable, use 'bytes32' instead of 'bytes memory' or 'string memory'. Generally, memory is cheaper than storage. However, 'bytes' has dynamically allotted space, meaning each use the EVM creates a new memory slot.
2
6
1
43
3,209
In contrast, fixed-size types like 'bytes32' or 'uint256' have a fixed size, which is known at compile-time. The memory allocation for these types can be done at compile-time, and the allocated memory space is already reserved when the contract is deployed to the blockchain.
1
274
(1/14) Having a strong foundation is a must to building anything worthwhile. The foundation of all crypto is Bitcoin, with the proof of work consensus mechanism at the heart of it. Lets go through it part by part. Grab something to drink, this may take awhile. 👇🧵
1
1
10
666
(2/14) Firstly, what is a blockchain? It is simply a chain of blocks which facilitates transactions in a public, distributed manner, where all participants agree upon a common state of data. Anyone can participate, but nobody can control it.
1
70