Shashank Profile picture
Sep 5 9 tweets 3 min read
Blockchain & Smart Contract Security #11
1/9
Secure Account Existence check for Low-level Calls
A thread and a blogpost @SolidityScan Also read about "King of Ethers" contract hack.

blog.solidityscan.com/secure-account…

#blockchain #security #smartcontracts #SOLIDITY
2/9
What are low-level calls?
Low-level calls are methods that work on raw addresses to call other contracts' functions in Solidity. "call", "delegatecall", "callcode", "send", "transfer", etc are some examples of low-level functions
3/9
The call() method allows you to call any function you want on the address specified, and if the function is implemented on that address, it will be executed.
4/9
delegatecall() method calls a function of contract B from contract A with contract A's storage, balance and address passed to the function. This allows us to use the function in contract B as library code.
Read more here: blog.solidityscan.com/security-issue…
5/9
staticcall() is another low-level function. The only difference between a staticcall and a call is that a staticcall cannot change the state of the contract it is calling.
6/9
Pitfalls of using Low-Level Calls
Low-level call usage has a high chance of erroring out and does not check for call success or code existence as it avoids type checking, function existence checks, and argument packing, calling a contract function is generally not advised
7/9
Security issues that arise due to practices of low level call.
Unchecked Call Return Value:
If call return value is unchecked the contract will be unaware of failed calls.
8/9
In case receive() and fallback() are defined:
The contract's fallback function is called if the function given to the call method doesn't exist. If the contract doesn't provide a fallback function, the call method will return the success state as false.
9/9
Recommendations:
It is always recommended to check for call success or failure when making a low-level call.
@SolidityScan finds these bugs automagically.
Check out the "King of Ethers" contract hack explanation in our blog post.
blog.solidityscan.com/secure-account…

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Shashank

Shashank Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(