SlideShare a Scribd company logo
1 of 68
2023
Tal Be’ery
Roi Vazan
Web3’s red pill: Smashing Web3 transaction
simulations for fun and profit
👋 Hi, I’m Tal Be’ery
● Co-Founder, CTO @ ZenGo
● 20 years of cyber security experience
● Former EIR Innov8 VC, VP Research Aorato
(acquired by Microsoft)
● @talbeerysec
👋 Hi, I’m Roi Vazan
● Researcher @ ZenGo
● 10 years of cyber security experience
Agenda
● Intro on blockchain evolution
○ Bitcoin → Ethereum
○ Ethereum apps
● Ethereum apps power the Web3 revolution
○ The Web3 triangle: user, web3 interface, smart contract
○ Security in the Web3 triangle: The visibility challenge
● Transaction simulation
○ Solving Web3’s visibility problems
● Attacking transaction simulation
○ False visibility is worse than no visibility: Red pills and TOCTOU exploits
○ Vulns, bounties, grants!
Good luck from Coinbase 😉
Blockchains: Bitcoin → Ethereum
Blockchain: In a nutshell
● “Just” a distributed database
○ Reaching a consensus on conflicts is not trivial!
● Messages are authenticated
○ User address corresponds to a public key
○ User signs messages with a private key
○ Private key stored in a wallet
● Very useful for value transfer = digital money!
● Bitcoin (2009) is doing that:
○ “1 built-in program”: “Send(source,dest,amount)”
■ Check authenticity by verifying the user’s signature on the transaction
■ Add amount to dest, subtract amount from source
■ Results are saved in the blockchain
Bitcoin is an arcade machine
Blockchain: beyond sending money
● Ethereum, co-founded by Vitalik (2015)
○ Has a similar “1 built-in program” for money transfer
○ But also, allows users to upload custom code (smart contract) and interact with it
■ Smart contracts are uploaded into addresses
■ Smart contracts expose callable methods
■ Very similar to a dynamic library (“.dll”, “.so”)
○ When interacting with a contract
■ Destination address is the contract
■ Function name and call parameters are passed as part of the transaction
■ Network fee (“gas”) depends on the complexity of the execution
Ethereum is a game console
Ethereum Apps: Tokens (ERC20)
● Before:
○ if you wanted your own coin, you needed to create your own blockchain
● After:
○ You just need to implement a smart contract that supports 6 methods (and 2 events)
Software eats world: DeFi “Money Lego”
● ERC20 is a standard, so dev developed standard services
○ Exchange in smart contract: DEX
○ Deposits / Loans
○ Derivatives
● Composability
○ Everything is just a function call
○ You can make an app to “mix and match”
■ Example “swap + deposit” app
● Finds the best interest rate for coin
● Switches user coin to it and deposits
Ethereum Apps: NFTs
● Current leading use case “Funny JPEGs”
● In future, also more serious use cases: registries, fractional ownership
● All you need to do is to implement 9 functions (and 3 events)
NFT in the wild
● The user owns NFTs
○ Ownership is public on blockchain
○ User can transfer via wallet
● Multiple marketplaces
○ For example: Opensea, rarible
Blockchain: Web3
Classic Blockchain: “Bitcoin”
How can user consume apps?
● (Most) Users cannot interact directly with smart contracts
○ We need to provide UI for this new system
○ We need to tell the wallet what to sign
● We already solved similar problems with Web
● Let’s repurpose Web2 to work with blockchain!
Web2
Web3 Echosphere: Web + Blockchain
Web3 Echosphere: Web + Blockchain
The Web3 Triangle
1. Web2 app interface:
App UX, suggests transactions to the user
2. Wallet
key management, transaction signing and blockchain interaction
3. Blockchain smart contracts (“contracts”)
implements the app’s logic.
The Web3 Triangle – Demo
Web3: Moving apps to the blockchain
ZenGo 💕 Ethereum and Web3
● Ethereum supported since day 1
○ Polygon added
● ClearSign:
○ Web3 first firewall integrated into the wallet
● Native tokens support
○ ERC20
○ NFTs gallery
● Ethereum Foundation grant
● Security research
○ Including this talk! :)
Rumor has it that Microsoft 💕 Ethereum too…
Web3 Security
Ethereum: The most(?) secure execution env!
● Trusted execution is a hard problem
○ Integrity of data and code
○ Consider malware, HW supply chain, Operating system supply chain
● Usually “solved” in hardware: SGX, TEE, etc.
● Ethereum
○ Code and inputs are on chain
○ Execution is independently validated by multiple validators
● In Ethereum an attacker will need to compromise the majority of validators
to compromise a computation!
● Implicit bug bounty of $200B
● More on this: zengo.com/wagmi-web3-will-be-more-secure-than-web2/
If it’s so good, how come it’s so bad?
● If Web3 is so secure, how come there are so many hacks and money loss
cases?
Answer: because humans make mistakes
● The program (code + input) is executed perfectly, but either code or input (or
both) is malicious!
Attack scenario #1: Malicious user
● The program (code + input) is executed perfectly, but
○ The smart contract’s code has vulns
○ Malicious user send maliciously crafted inputs to exploit
● Not going to discuss that today
Attack #2: Malicious web2 interface
● The program (code + input) is executed perfectly, but:
○ The input is bad for the user
■ Input is suggested by a malicious dapp
● Definitely going to discuss that today
Attack #3: Malicious code
● The program (code + input) is executed perfectly, but:
○ The code is malicious
● Definitely going to discuss that today
Malicious interfaces in the wild: BadgerDAO
● “Bringing Bitcoin to DeFi” : Earn interest on your BTC
○ via ERC20
BadgerDAO hack: injected code to web interface
● BadgerDao web interface infected with injected code
○ [Nov 2021] first version injected
○ Captured by web.archive.org
○ De-obfuscated by ZenGo
● Code Diff (The injected website is in red on left)
BadgerDAO Who is $50M fish?
● According to press
○ Celsius
○ Using MetaMask
BadgerDAO: IncreaseAllowance vs. Approve
● Usually ERC20 funds access request
with Approve()
● Attackers used a lesser known
method IncreaseAllowance()
● MM did not recognize
IncreaseAllowance()
○ No humanly understandable explanation
○ Not showing user that they are
interacting with an ERC20 contract
Malicious Smart Contracts in the wild
● The truth is this danger is fairly limited
● Bad contracts can only touch Ethereum
○ Smart contract based assets requires an approve before (as before)
● Ethereum sending is visible as
○ ‘Ethereum has a similar “1 built-in program” for money transfer’
● Still there could be scams like
○ Give $10 ETH to get $200 ERC-20
Is execution (code + input) malicious or benign?
● Visibility is the key:
● Users needs to know before they sign a transaction what would be the outcome of sending
this RPC parameters to the contract
● We can try to analyze the code
○ CS theory tells us this problem is undecidable
● However, antivirus has been dealing with this issue for decades
○ VM / sandbox / detonation chamber
● Instead of analyzing what the program does, let’s just execute it in a
sandboxes environment!
● and then apply some security logic on it.
Simulation to the rescue
Ethereum is a state machine
● EVM is the runtime environment for smart contract in Ethereum
EVM opcodes
● Predefined instructions
● Smart contract written in High level languages, broken down into EVM
codes
● Execution is initiated by a transaction
Special variables in the EVM
● Not part of the “regular state”, by definition
○ Some of them are controlled by the user
○ Some of them are “global” variables
● Runtime environment variables:
○ COINBASE - the Account which is going to get the current block fee rewards
○ GASPRICE - Transaction’s gas price
○ BASEFEE - EIP1559 block’s basefee
Runtime execution
Runtime execution: Example
Are we ready to simulate? Not yet!
● The problem:
○ We can execute a smart contract and observe state changes, but how
can we explain them to the user?
○ State changes are hard to explain
● Solution:
○ Events to the rescue!
Ethereum events
● Invoked by smart contracts during execution
○ Generated on-chain
○ Not stored on-chain - can’t be consumed by smart contracts
● Frequently used by off-chain services
● Any contract can emit any event
● Can we trust events?
○ We can trust good Smart Contract events - as they intend to represent a real on-chain state
Common events in ERC20 and ERC721 (NFT’s)
● Approval event
○ Emitted every time the token owner allows another address to access their tokens
■ In ERC721 - ApprovalForAll - all the tokens within the collection
■ In ERC20 - Approve - specific amount of tokens
● Transfer events
○ Emitted every time a token is being transferred from an address to another
Simulation flow
1. Transaction is being simulated
○ Potential emitted events are shown to the user
2. Based on the events results the user decides whether to reject or continue
the transaction
3. Transaction is broadcasted to the blockchain
Preventing BadgerDao with Simulations + FW
Attacking simulations
Red pill & Blue pill
● Find a red pill predicate
○ Am I in a simulation now?
● If in simulation
○ Show benign behavior
● If in non-simulation
○ Attack!
Red Pills exploit: A blueprint
simulation? non-simulation?
Red Pills in Cyber Security
● Traditional Red pills:
○ Malware Vaccination tricks:
■ VM detection
■ isDebuggerPresent
■ SandBox detection
● Web3 Security Red Pills:
○ Malicious smart contract:
■ Can it be aware it runs in simulation?
Web3 Red Pills hypothesis: Special variables
● In real environment naturally provided by:
○ The user - User specifies variables (i.e gaslimit)
○ The environment - i.e block base fee
● However in simulation:
○ Being generated by the simulation node provider
● Almost any value is technically valid, however not every value is
“reasonable”
● Maybe these are our Red Pills?
Validating the hypothesis
● To validate, we need to see the value of special variables in simulation
● Challenge: simulation products are black boxes
○ Just showing simulation results
● Solution: Using standard events in order to debug!
○ Transfer events are restricted to a specific signature
○ Byte by byte debugging
○ Solidity casting
Bingo!
● Applying the technique we were able:
○ Easily debug every environment variable of any provider
○ Search for unreasonable values
● Some unreasonable values found
○ COINBASE always the null address (0x000000…000)
○ GASPRICE always 0
○ GASLIMIT always a constant extremely high values
● Once we discover an unreasonable value provided by a simulation vendor
○ We can create a “red pill” predicate for it:
■ If simulation, then show a good trade
■ If non-simulation, just take the money
● And finally, deploy dedicated exploit contract for every vendor
Exploit example: COINBASE null address
● Red pill predicate
○ Is COINBASE == 0 ?
● Exploit
○ Tricks the user to sign a transaction using the simulation:
■ At simulation sends ERC20 token back
■ On chain it will not!
Demo - Exploiting Coinbase wallet
Disclosures table
Bounties, Grants
● Bounties:
○ Coinbase wallet
○ Rabby wallet
● Grants:
○ from the Ethereum Foundation: https://zengo.com/ethereum-foundation-awards-
zengo-a-grant-for-web3-security-research/
How to fix
● Use the REAL environment variables from the current environment
○ That way a malicious contract can no longer differentiate
● Some of them should be provided by the user:
○ GASPRICE
○ GASLIMIT
● Some of them aren’t known yet:
○ COINBASE - Use the last block’s value (consecutive COINBASE value may appear on-chain)
Cat and Mouse - TOCTOU
● Simulating the transaction + confirming it takes time
● Malicious application can leverage it:
○ Dapp checks the timestamp when the tx was craftet
○ Contract checks time elapsed
● Red Pill predicate
○ Is blockDiff > X
Demo - Exploiting using TOCTOU
Wrap up
Takeaways
● Web3 enables decentralized apps with thrilling use cases
● However, it creates new attack surfaces
○ Rogue contracts
○ Rogue interfaces
● Users have no visibility to what they are signing!
● You cannot fight what you cannot see
● Transaction simulation provides visibility
○ But has some limitations and can be attacked
■ Red Pills!
● Transaction simulation should be implemented securely
● With this new visibility, Web3 firewalls can save the users!
ClearSign: Web3 Personal Firewall
www.zengo.com
twitter.com/zengo
medium.com/zengo
github.com/zengo-x
contact@zengo.com
2023
Thank
you!

More Related Content

What's hot

イマドキC++erのモテカワリソース管理術
イマドキC++erのモテカワリソース管理術イマドキC++erのモテカワリソース管理術
イマドキC++erのモテカワリソース管理術Kohsuke Yuasa
 
Legal issues with Bitcoin
Legal issues with BitcoinLegal issues with Bitcoin
Legal issues with BitcoinAndres Guadamuz
 
Dna storage
Dna storageDna storage
Dna storageCareerIn
 
Understanding hd wallets design and implementation
Understanding hd wallets  design and implementationUnderstanding hd wallets  design and implementation
Understanding hd wallets design and implementationArcBlock
 
Crypto currency
Crypto currencyCrypto currency
Crypto currencyAmit RJ
 
AMP Kynetics - ELC 2018 Portland
AMP  Kynetics - ELC 2018 PortlandAMP  Kynetics - ELC 2018 Portland
AMP Kynetics - ELC 2018 PortlandKynetics
 
Blockchain Technology
Blockchain TechnologyBlockchain Technology
Blockchain TechnologyPalakGulati10
 
The Design of Blockchain-Based Apps (DApps)
The Design of Blockchain-Based Apps (DApps)The Design of Blockchain-Based Apps (DApps)
The Design of Blockchain-Based Apps (DApps)Erik Trautman
 
Haswellサーベイと有限体クラスの紹介
Haswellサーベイと有限体クラスの紹介Haswellサーベイと有限体クラスの紹介
Haswellサーベイと有限体クラスの紹介MITSUNARI Shigeo
 
Crypto Wallets: A Technical Perspective (Nakov at OpenFest 2018)
Crypto Wallets: A Technical Perspective (Nakov at OpenFest 2018)Crypto Wallets: A Technical Perspective (Nakov at OpenFest 2018)
Crypto Wallets: A Technical Perspective (Nakov at OpenFest 2018)Svetlin Nakov
 
Introduction To CryptoCurrency
Introduction To CryptoCurrencyIntroduction To CryptoCurrency
Introduction To CryptoCurrencySanjay Kumar
 
A technical Introduction to Blockchain.
A technical Introduction to Blockchain.A technical Introduction to Blockchain.
A technical Introduction to Blockchain.Dev
 
Polygon Encode Club_deck
Polygon Encode Club_deckPolygon Encode Club_deck
Polygon Encode Club_deckVanessa Lošić
 
SANS_PentestHackfest_2022-PurpleTeam_Cloud_Identity.pptx
SANS_PentestHackfest_2022-PurpleTeam_Cloud_Identity.pptxSANS_PentestHackfest_2022-PurpleTeam_Cloud_Identity.pptx
SANS_PentestHackfest_2022-PurpleTeam_Cloud_Identity.pptxJasonOstrom1
 
Introduction to Cryptocurrency (Bitcoin)
Introduction to Cryptocurrency (Bitcoin)Introduction to Cryptocurrency (Bitcoin)
Introduction to Cryptocurrency (Bitcoin)Kashif Khans
 

What's hot (20)

イマドキC++erのモテカワリソース管理術
イマドキC++erのモテカワリソース管理術イマドキC++erのモテカワリソース管理術
イマドキC++erのモテカワリソース管理術
 
Legal issues with Bitcoin
Legal issues with BitcoinLegal issues with Bitcoin
Legal issues with Bitcoin
 
Dna storage
Dna storageDna storage
Dna storage
 
All about Bitcoins!
All about Bitcoins!All about Bitcoins!
All about Bitcoins!
 
Crypto wallets
Crypto walletsCrypto wallets
Crypto wallets
 
Understanding hd wallets design and implementation
Understanding hd wallets  design and implementationUnderstanding hd wallets  design and implementation
Understanding hd wallets design and implementation
 
Crypto currency
Crypto currencyCrypto currency
Crypto currency
 
Blockchain Poc for Certificates and Degrees
Blockchain Poc for Certificates and DegreesBlockchain Poc for Certificates and Degrees
Blockchain Poc for Certificates and Degrees
 
Smart Contract Security
Smart Contract SecuritySmart Contract Security
Smart Contract Security
 
AMP Kynetics - ELC 2018 Portland
AMP  Kynetics - ELC 2018 PortlandAMP  Kynetics - ELC 2018 Portland
AMP Kynetics - ELC 2018 Portland
 
Blockchain Technology
Blockchain TechnologyBlockchain Technology
Blockchain Technology
 
The Design of Blockchain-Based Apps (DApps)
The Design of Blockchain-Based Apps (DApps)The Design of Blockchain-Based Apps (DApps)
The Design of Blockchain-Based Apps (DApps)
 
Haswellサーベイと有限体クラスの紹介
Haswellサーベイと有限体クラスの紹介Haswellサーベイと有限体クラスの紹介
Haswellサーベイと有限体クラスの紹介
 
Crypto Wallets: A Technical Perspective (Nakov at OpenFest 2018)
Crypto Wallets: A Technical Perspective (Nakov at OpenFest 2018)Crypto Wallets: A Technical Perspective (Nakov at OpenFest 2018)
Crypto Wallets: A Technical Perspective (Nakov at OpenFest 2018)
 
Introduction To CryptoCurrency
Introduction To CryptoCurrencyIntroduction To CryptoCurrency
Introduction To CryptoCurrency
 
A technical Introduction to Blockchain.
A technical Introduction to Blockchain.A technical Introduction to Blockchain.
A technical Introduction to Blockchain.
 
Polygon Encode Club_deck
Polygon Encode Club_deckPolygon Encode Club_deck
Polygon Encode Club_deck
 
What's cryptocurrency ?
What's cryptocurrency ?What's cryptocurrency ?
What's cryptocurrency ?
 
SANS_PentestHackfest_2022-PurpleTeam_Cloud_Identity.pptx
SANS_PentestHackfest_2022-PurpleTeam_Cloud_Identity.pptxSANS_PentestHackfest_2022-PurpleTeam_Cloud_Identity.pptx
SANS_PentestHackfest_2022-PurpleTeam_Cloud_Identity.pptx
 
Introduction to Cryptocurrency (Bitcoin)
Introduction to Cryptocurrency (Bitcoin)Introduction to Cryptocurrency (Bitcoin)
Introduction to Cryptocurrency (Bitcoin)
 

Similar to Web3’s red pill: Smashing Web3 transaction simulations for fun and profit

Web3 Security: The Blockchain is Your SIEM
Web3 Security: The Blockchain is Your SIEMWeb3 Security: The Blockchain is Your SIEM
Web3 Security: The Blockchain is Your SIEMTal Be'ery
 
Daniel Connelly Ethereum Smart Contract Master's Thesis
Daniel Connelly Ethereum Smart Contract Master's ThesisDaniel Connelly Ethereum Smart Contract Master's Thesis
Daniel Connelly Ethereum Smart Contract Master's ThesisDaniel Connelly
 
Simone Bronzini - Weaknesses of blockchain applications - Codemotion Milan 2018
Simone Bronzini - Weaknesses of blockchain applications - Codemotion Milan 2018Simone Bronzini - Weaknesses of blockchain applications - Codemotion Milan 2018
Simone Bronzini - Weaknesses of blockchain applications - Codemotion Milan 2018Codemotion
 
Stefano Maestri - Blockchain and smart contracts, what they are and why you s...
Stefano Maestri - Blockchain and smart contracts, what they are and why you s...Stefano Maestri - Blockchain and smart contracts, what they are and why you s...
Stefano Maestri - Blockchain and smart contracts, what they are and why you s...Codemotion
 
Best practices to build secure smart contracts
Best practices to build secure smart contractsBest practices to build secure smart contracts
Best practices to build secure smart contractsGautam Anand
 
Fluent destry saul
Fluent destry saulFluent destry saul
Fluent destry saulDestry Saul
 
Dylan Butler & Oliver Hager - Building a cross platform cryptocurrency app
Dylan Butler & Oliver Hager - Building a cross platform cryptocurrency appDylan Butler & Oliver Hager - Building a cross platform cryptocurrency app
Dylan Butler & Oliver Hager - Building a cross platform cryptocurrency appDevCamp Campinas
 
How to Create Blockchain Products by Fr8 Network Lead Engineer
How to Create Blockchain Products by Fr8 Network Lead EngineerHow to Create Blockchain Products by Fr8 Network Lead Engineer
How to Create Blockchain Products by Fr8 Network Lead EngineerProduct School
 
Blockchain architected
Blockchain architectedBlockchain architected
Blockchain architectedIBM Sverige
 
Building Apps with Ethereum Smart Contract
Building Apps with Ethereum Smart ContractBuilding Apps with Ethereum Smart Contract
Building Apps with Ethereum Smart ContractVaideeswaran Sethuraman
 
Blockchain, bitcoin, ethereum and ICOs
Blockchain, bitcoin, ethereum and ICOsBlockchain, bitcoin, ethereum and ICOs
Blockchain, bitcoin, ethereum and ICOsBogdan Fiedur
 
Blockchain Basics
Blockchain BasicsBlockchain Basics
Blockchain BasicsAli Ayyash
 
BlockChain Basic Concepts
BlockChain Basic ConceptsBlockChain Basic Concepts
BlockChain Basic ConceptsMuLearn
 
Smart contract honeypots for profit (and fun) - bha
Smart contract honeypots for profit (and fun)  - bhaSmart contract honeypots for profit (and fun)  - bha
Smart contract honeypots for profit (and fun) - bhaPolySwarm
 
How to Create Blockchain Products by Slice.Market CTO
How to Create Blockchain Products by Slice.Market CTOHow to Create Blockchain Products by Slice.Market CTO
How to Create Blockchain Products by Slice.Market CTOProduct School
 
Blockchain Fundamentals for Beginners - 101 Blockchains
Blockchain Fundamentals for Beginners - 101 BlockchainsBlockchain Fundamentals for Beginners - 101 Blockchains
Blockchain Fundamentals for Beginners - 101 Blockchains101 Blockchains Academy
 
Blockchain and smart contracts, what they are and why you should really care ...
Blockchain and smart contracts, what they are and why you should really care ...Blockchain and smart contracts, what they are and why you should really care ...
Blockchain and smart contracts, what they are and why you should really care ...maeste
 

Similar to Web3’s red pill: Smashing Web3 transaction simulations for fun and profit (20)

Web3 Security: The Blockchain is Your SIEM
Web3 Security: The Blockchain is Your SIEMWeb3 Security: The Blockchain is Your SIEM
Web3 Security: The Blockchain is Your SIEM
 
Daniel Connelly Ethereum Smart Contract Master's Thesis
Daniel Connelly Ethereum Smart Contract Master's ThesisDaniel Connelly Ethereum Smart Contract Master's Thesis
Daniel Connelly Ethereum Smart Contract Master's Thesis
 
Simone Bronzini - Weaknesses of blockchain applications - Codemotion Milan 2018
Simone Bronzini - Weaknesses of blockchain applications - Codemotion Milan 2018Simone Bronzini - Weaknesses of blockchain applications - Codemotion Milan 2018
Simone Bronzini - Weaknesses of blockchain applications - Codemotion Milan 2018
 
Stefano Maestri - Blockchain and smart contracts, what they are and why you s...
Stefano Maestri - Blockchain and smart contracts, what they are and why you s...Stefano Maestri - Blockchain and smart contracts, what they are and why you s...
Stefano Maestri - Blockchain and smart contracts, what they are and why you s...
 
Best practices to build secure smart contracts
Best practices to build secure smart contractsBest practices to build secure smart contracts
Best practices to build secure smart contracts
 
Fluent destry saul
Fluent destry saulFluent destry saul
Fluent destry saul
 
Ethereum
EthereumEthereum
Ethereum
 
Dylan Butler & Oliver Hager - Building a cross platform cryptocurrency app
Dylan Butler & Oliver Hager - Building a cross platform cryptocurrency appDylan Butler & Oliver Hager - Building a cross platform cryptocurrency app
Dylan Butler & Oliver Hager - Building a cross platform cryptocurrency app
 
How to Create Blockchain Products by Fr8 Network Lead Engineer
How to Create Blockchain Products by Fr8 Network Lead EngineerHow to Create Blockchain Products by Fr8 Network Lead Engineer
How to Create Blockchain Products by Fr8 Network Lead Engineer
 
Blockchain architected
Blockchain architectedBlockchain architected
Blockchain architected
 
Building Apps with Ethereum Smart Contract
Building Apps with Ethereum Smart ContractBuilding Apps with Ethereum Smart Contract
Building Apps with Ethereum Smart Contract
 
Blockchain, bitcoin, ethereum and ICOs
Blockchain, bitcoin, ethereum and ICOsBlockchain, bitcoin, ethereum and ICOs
Blockchain, bitcoin, ethereum and ICOs
 
Blockchain Basics
Blockchain BasicsBlockchain Basics
Blockchain Basics
 
BlockChain Basic Concepts
BlockChain Basic ConceptsBlockChain Basic Concepts
BlockChain Basic Concepts
 
Smart contract honeypots for profit (and fun) - bha
Smart contract honeypots for profit (and fun)  - bhaSmart contract honeypots for profit (and fun)  - bha
Smart contract honeypots for profit (and fun) - bha
 
Ergo Hong Kong meetup
Ergo Hong Kong meetupErgo Hong Kong meetup
Ergo Hong Kong meetup
 
How to Create Blockchain Products by Slice.Market CTO
How to Create Blockchain Products by Slice.Market CTOHow to Create Blockchain Products by Slice.Market CTO
How to Create Blockchain Products by Slice.Market CTO
 
Ethereum-Cryptocurrency (All about Ethereum)
Ethereum-Cryptocurrency (All about Ethereum) Ethereum-Cryptocurrency (All about Ethereum)
Ethereum-Cryptocurrency (All about Ethereum)
 
Blockchain Fundamentals for Beginners - 101 Blockchains
Blockchain Fundamentals for Beginners - 101 BlockchainsBlockchain Fundamentals for Beginners - 101 Blockchains
Blockchain Fundamentals for Beginners - 101 Blockchains
 
Blockchain and smart contracts, what they are and why you should really care ...
Blockchain and smart contracts, what they are and why you should really care ...Blockchain and smart contracts, what they are and why you should really care ...
Blockchain and smart contracts, what they are and why you should really care ...
 

More from Tal Be'ery

Give me some (key) space!
Give me some (key) space!Give me some (key) space!
Give me some (key) space!Tal Be'ery
 
Understanding Compound‘s Liquidation
Understanding Compound‘s LiquidationUnderstanding Compound‘s Liquidation
Understanding Compound‘s LiquidationTal Be'ery
 
The Color of Money
The Color of MoneyThe Color of Money
The Color of MoneyTal Be'ery
 
Open Sesame: Picking Locks with Cortana
Open Sesame: Picking Locks with CortanaOpen Sesame: Picking Locks with Cortana
Open Sesame: Picking Locks with CortanaTal Be'ery
 
THE VOICE OF ESAU: HACKING ENTERPRISES THROUGH VOICE INTERFACES
THE VOICE OF ESAU: HACKING ENTERPRISES THROUGH VOICE INTERFACES   THE VOICE OF ESAU: HACKING ENTERPRISES THROUGH VOICE INTERFACES
THE VOICE OF ESAU: HACKING ENTERPRISES THROUGH VOICE INTERFACES Tal Be'ery
 
Automate or Die: How Automation Reshapes Cybersecurity
Automate or Die: How Automation Reshapes CybersecurityAutomate or Die: How Automation Reshapes Cybersecurity
Automate or Die: How Automation Reshapes CybersecurityTal Be'ery
 
The Industrial Revolution of Lateral Movement
The Industrial Revolution of Lateral MovementThe Industrial Revolution of Lateral Movement
The Industrial Revolution of Lateral MovementTal Be'ery
 
The Enemy Within: Stopping Advanced Attacks Against Local Users
The Enemy Within: Stopping Advanced Attacks Against Local UsersThe Enemy Within: Stopping Advanced Attacks Against Local Users
The Enemy Within: Stopping Advanced Attacks Against Local UsersTal Be'ery
 
Target Breach Analysis
Target Breach AnalysisTarget Breach Analysis
Target Breach AnalysisTal Be'ery
 
Battlefield network
Battlefield networkBattlefield network
Battlefield networkTal Be'ery
 
Client sidesec 2013-intro
Client sidesec 2013-introClient sidesec 2013-intro
Client sidesec 2013-introTal Be'ery
 
Client sidesec 2013 - non js
Client sidesec 2013 - non jsClient sidesec 2013 - non js
Client sidesec 2013 - non jsTal Be'ery
 
Client sidesec 2013 - script injection
Client sidesec 2013 - script injectionClient sidesec 2013 - script injection
Client sidesec 2013 - script injectionTal Be'ery
 
One Key to Rule Them All: Detecting the Skeleton Key Malware
One Key to Rule Them All: Detecting the Skeleton Key MalwareOne Key to Rule Them All: Detecting the Skeleton Key Malware
One Key to Rule Them All: Detecting the Skeleton Key MalwareTal Be'ery
 
Skeleton key malware detection owasp
Skeleton key malware detection owaspSkeleton key malware detection owasp
Skeleton key malware detection owaspTal Be'ery
 

More from Tal Be'ery (15)

Give me some (key) space!
Give me some (key) space!Give me some (key) space!
Give me some (key) space!
 
Understanding Compound‘s Liquidation
Understanding Compound‘s LiquidationUnderstanding Compound‘s Liquidation
Understanding Compound‘s Liquidation
 
The Color of Money
The Color of MoneyThe Color of Money
The Color of Money
 
Open Sesame: Picking Locks with Cortana
Open Sesame: Picking Locks with CortanaOpen Sesame: Picking Locks with Cortana
Open Sesame: Picking Locks with Cortana
 
THE VOICE OF ESAU: HACKING ENTERPRISES THROUGH VOICE INTERFACES
THE VOICE OF ESAU: HACKING ENTERPRISES THROUGH VOICE INTERFACES   THE VOICE OF ESAU: HACKING ENTERPRISES THROUGH VOICE INTERFACES
THE VOICE OF ESAU: HACKING ENTERPRISES THROUGH VOICE INTERFACES
 
Automate or Die: How Automation Reshapes Cybersecurity
Automate or Die: How Automation Reshapes CybersecurityAutomate or Die: How Automation Reshapes Cybersecurity
Automate or Die: How Automation Reshapes Cybersecurity
 
The Industrial Revolution of Lateral Movement
The Industrial Revolution of Lateral MovementThe Industrial Revolution of Lateral Movement
The Industrial Revolution of Lateral Movement
 
The Enemy Within: Stopping Advanced Attacks Against Local Users
The Enemy Within: Stopping Advanced Attacks Against Local UsersThe Enemy Within: Stopping Advanced Attacks Against Local Users
The Enemy Within: Stopping Advanced Attacks Against Local Users
 
Target Breach Analysis
Target Breach AnalysisTarget Breach Analysis
Target Breach Analysis
 
Battlefield network
Battlefield networkBattlefield network
Battlefield network
 
Client sidesec 2013-intro
Client sidesec 2013-introClient sidesec 2013-intro
Client sidesec 2013-intro
 
Client sidesec 2013 - non js
Client sidesec 2013 - non jsClient sidesec 2013 - non js
Client sidesec 2013 - non js
 
Client sidesec 2013 - script injection
Client sidesec 2013 - script injectionClient sidesec 2013 - script injection
Client sidesec 2013 - script injection
 
One Key to Rule Them All: Detecting the Skeleton Key Malware
One Key to Rule Them All: Detecting the Skeleton Key MalwareOne Key to Rule Them All: Detecting the Skeleton Key Malware
One Key to Rule Them All: Detecting the Skeleton Key Malware
 
Skeleton key malware detection owasp
Skeleton key malware detection owaspSkeleton key malware detection owasp
Skeleton key malware detection owasp
 

Recently uploaded

Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 

Recently uploaded (20)

Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 

Web3’s red pill: Smashing Web3 transaction simulations for fun and profit

  • 1. 2023 Tal Be’ery Roi Vazan Web3’s red pill: Smashing Web3 transaction simulations for fun and profit
  • 2. 👋 Hi, I’m Tal Be’ery ● Co-Founder, CTO @ ZenGo ● 20 years of cyber security experience ● Former EIR Innov8 VC, VP Research Aorato (acquired by Microsoft) ● @talbeerysec
  • 3. 👋 Hi, I’m Roi Vazan ● Researcher @ ZenGo ● 10 years of cyber security experience
  • 4. Agenda ● Intro on blockchain evolution ○ Bitcoin → Ethereum ○ Ethereum apps ● Ethereum apps power the Web3 revolution ○ The Web3 triangle: user, web3 interface, smart contract ○ Security in the Web3 triangle: The visibility challenge ● Transaction simulation ○ Solving Web3’s visibility problems ● Attacking transaction simulation ○ False visibility is worse than no visibility: Red pills and TOCTOU exploits ○ Vulns, bounties, grants!
  • 5. Good luck from Coinbase 😉
  • 7. Blockchain: In a nutshell ● “Just” a distributed database ○ Reaching a consensus on conflicts is not trivial! ● Messages are authenticated ○ User address corresponds to a public key ○ User signs messages with a private key ○ Private key stored in a wallet ● Very useful for value transfer = digital money! ● Bitcoin (2009) is doing that: ○ “1 built-in program”: “Send(source,dest,amount)” ■ Check authenticity by verifying the user’s signature on the transaction ■ Add amount to dest, subtract amount from source ■ Results are saved in the blockchain
  • 8. Bitcoin is an arcade machine
  • 9. Blockchain: beyond sending money ● Ethereum, co-founded by Vitalik (2015) ○ Has a similar “1 built-in program” for money transfer ○ But also, allows users to upload custom code (smart contract) and interact with it ■ Smart contracts are uploaded into addresses ■ Smart contracts expose callable methods ■ Very similar to a dynamic library (“.dll”, “.so”) ○ When interacting with a contract ■ Destination address is the contract ■ Function name and call parameters are passed as part of the transaction ■ Network fee (“gas”) depends on the complexity of the execution
  • 10. Ethereum is a game console
  • 11. Ethereum Apps: Tokens (ERC20) ● Before: ○ if you wanted your own coin, you needed to create your own blockchain ● After: ○ You just need to implement a smart contract that supports 6 methods (and 2 events)
  • 12. Software eats world: DeFi “Money Lego” ● ERC20 is a standard, so dev developed standard services ○ Exchange in smart contract: DEX ○ Deposits / Loans ○ Derivatives ● Composability ○ Everything is just a function call ○ You can make an app to “mix and match” ■ Example “swap + deposit” app ● Finds the best interest rate for coin ● Switches user coin to it and deposits
  • 13. Ethereum Apps: NFTs ● Current leading use case “Funny JPEGs” ● In future, also more serious use cases: registries, fractional ownership ● All you need to do is to implement 9 functions (and 3 events)
  • 14. NFT in the wild ● The user owns NFTs ○ Ownership is public on blockchain ○ User can transfer via wallet ● Multiple marketplaces ○ For example: Opensea, rarible
  • 17. How can user consume apps? ● (Most) Users cannot interact directly with smart contracts ○ We need to provide UI for this new system ○ We need to tell the wallet what to sign ● We already solved similar problems with Web ● Let’s repurpose Web2 to work with blockchain!
  • 18. Web2
  • 19. Web3 Echosphere: Web + Blockchain
  • 20. Web3 Echosphere: Web + Blockchain
  • 21. The Web3 Triangle 1. Web2 app interface: App UX, suggests transactions to the user 2. Wallet key management, transaction signing and blockchain interaction 3. Blockchain smart contracts (“contracts”) implements the app’s logic.
  • 22. The Web3 Triangle – Demo
  • 23. Web3: Moving apps to the blockchain
  • 24. ZenGo 💕 Ethereum and Web3 ● Ethereum supported since day 1 ○ Polygon added ● ClearSign: ○ Web3 first firewall integrated into the wallet ● Native tokens support ○ ERC20 ○ NFTs gallery ● Ethereum Foundation grant ● Security research ○ Including this talk! :)
  • 25. Rumor has it that Microsoft 💕 Ethereum too…
  • 27. Ethereum: The most(?) secure execution env! ● Trusted execution is a hard problem ○ Integrity of data and code ○ Consider malware, HW supply chain, Operating system supply chain ● Usually “solved” in hardware: SGX, TEE, etc. ● Ethereum ○ Code and inputs are on chain ○ Execution is independently validated by multiple validators ● In Ethereum an attacker will need to compromise the majority of validators to compromise a computation! ● Implicit bug bounty of $200B ● More on this: zengo.com/wagmi-web3-will-be-more-secure-than-web2/
  • 28. If it’s so good, how come it’s so bad? ● If Web3 is so secure, how come there are so many hacks and money loss cases?
  • 29. Answer: because humans make mistakes ● The program (code + input) is executed perfectly, but either code or input (or both) is malicious!
  • 30. Attack scenario #1: Malicious user ● The program (code + input) is executed perfectly, but ○ The smart contract’s code has vulns ○ Malicious user send maliciously crafted inputs to exploit ● Not going to discuss that today
  • 31. Attack #2: Malicious web2 interface ● The program (code + input) is executed perfectly, but: ○ The input is bad for the user ■ Input is suggested by a malicious dapp ● Definitely going to discuss that today
  • 32. Attack #3: Malicious code ● The program (code + input) is executed perfectly, but: ○ The code is malicious ● Definitely going to discuss that today
  • 33. Malicious interfaces in the wild: BadgerDAO ● “Bringing Bitcoin to DeFi” : Earn interest on your BTC ○ via ERC20
  • 34. BadgerDAO hack: injected code to web interface ● BadgerDao web interface infected with injected code ○ [Nov 2021] first version injected ○ Captured by web.archive.org ○ De-obfuscated by ZenGo ● Code Diff (The injected website is in red on left)
  • 35. BadgerDAO Who is $50M fish? ● According to press ○ Celsius ○ Using MetaMask
  • 36. BadgerDAO: IncreaseAllowance vs. Approve ● Usually ERC20 funds access request with Approve() ● Attackers used a lesser known method IncreaseAllowance() ● MM did not recognize IncreaseAllowance() ○ No humanly understandable explanation ○ Not showing user that they are interacting with an ERC20 contract
  • 37. Malicious Smart Contracts in the wild ● The truth is this danger is fairly limited ● Bad contracts can only touch Ethereum ○ Smart contract based assets requires an approve before (as before) ● Ethereum sending is visible as ○ ‘Ethereum has a similar “1 built-in program” for money transfer’ ● Still there could be scams like ○ Give $10 ETH to get $200 ERC-20
  • 38. Is execution (code + input) malicious or benign? ● Visibility is the key: ● Users needs to know before they sign a transaction what would be the outcome of sending this RPC parameters to the contract ● We can try to analyze the code ○ CS theory tells us this problem is undecidable ● However, antivirus has been dealing with this issue for decades ○ VM / sandbox / detonation chamber ● Instead of analyzing what the program does, let’s just execute it in a sandboxes environment! ● and then apply some security logic on it.
  • 40. Ethereum is a state machine ● EVM is the runtime environment for smart contract in Ethereum
  • 41. EVM opcodes ● Predefined instructions ● Smart contract written in High level languages, broken down into EVM codes ● Execution is initiated by a transaction
  • 42. Special variables in the EVM ● Not part of the “regular state”, by definition ○ Some of them are controlled by the user ○ Some of them are “global” variables ● Runtime environment variables: ○ COINBASE - the Account which is going to get the current block fee rewards ○ GASPRICE - Transaction’s gas price ○ BASEFEE - EIP1559 block’s basefee
  • 45. Are we ready to simulate? Not yet! ● The problem: ○ We can execute a smart contract and observe state changes, but how can we explain them to the user? ○ State changes are hard to explain ● Solution: ○ Events to the rescue!
  • 46. Ethereum events ● Invoked by smart contracts during execution ○ Generated on-chain ○ Not stored on-chain - can’t be consumed by smart contracts ● Frequently used by off-chain services ● Any contract can emit any event ● Can we trust events? ○ We can trust good Smart Contract events - as they intend to represent a real on-chain state
  • 47. Common events in ERC20 and ERC721 (NFT’s) ● Approval event ○ Emitted every time the token owner allows another address to access their tokens ■ In ERC721 - ApprovalForAll - all the tokens within the collection ■ In ERC20 - Approve - specific amount of tokens ● Transfer events ○ Emitted every time a token is being transferred from an address to another
  • 48. Simulation flow 1. Transaction is being simulated ○ Potential emitted events are shown to the user 2. Based on the events results the user decides whether to reject or continue the transaction 3. Transaction is broadcasted to the blockchain
  • 49. Preventing BadgerDao with Simulations + FW
  • 51. Red pill & Blue pill
  • 52. ● Find a red pill predicate ○ Am I in a simulation now? ● If in simulation ○ Show benign behavior ● If in non-simulation ○ Attack! Red Pills exploit: A blueprint simulation? non-simulation?
  • 53. Red Pills in Cyber Security ● Traditional Red pills: ○ Malware Vaccination tricks: ■ VM detection ■ isDebuggerPresent ■ SandBox detection ● Web3 Security Red Pills: ○ Malicious smart contract: ■ Can it be aware it runs in simulation?
  • 54. Web3 Red Pills hypothesis: Special variables ● In real environment naturally provided by: ○ The user - User specifies variables (i.e gaslimit) ○ The environment - i.e block base fee ● However in simulation: ○ Being generated by the simulation node provider ● Almost any value is technically valid, however not every value is “reasonable” ● Maybe these are our Red Pills?
  • 55. Validating the hypothesis ● To validate, we need to see the value of special variables in simulation ● Challenge: simulation products are black boxes ○ Just showing simulation results ● Solution: Using standard events in order to debug! ○ Transfer events are restricted to a specific signature ○ Byte by byte debugging ○ Solidity casting
  • 56. Bingo! ● Applying the technique we were able: ○ Easily debug every environment variable of any provider ○ Search for unreasonable values ● Some unreasonable values found ○ COINBASE always the null address (0x000000…000) ○ GASPRICE always 0 ○ GASLIMIT always a constant extremely high values ● Once we discover an unreasonable value provided by a simulation vendor ○ We can create a “red pill” predicate for it: ■ If simulation, then show a good trade ■ If non-simulation, just take the money ● And finally, deploy dedicated exploit contract for every vendor
  • 57. Exploit example: COINBASE null address ● Red pill predicate ○ Is COINBASE == 0 ? ● Exploit ○ Tricks the user to sign a transaction using the simulation: ■ At simulation sends ERC20 token back ■ On chain it will not!
  • 58. Demo - Exploiting Coinbase wallet
  • 60. Bounties, Grants ● Bounties: ○ Coinbase wallet ○ Rabby wallet ● Grants: ○ from the Ethereum Foundation: https://zengo.com/ethereum-foundation-awards- zengo-a-grant-for-web3-security-research/
  • 61. How to fix ● Use the REAL environment variables from the current environment ○ That way a malicious contract can no longer differentiate ● Some of them should be provided by the user: ○ GASPRICE ○ GASLIMIT ● Some of them aren’t known yet: ○ COINBASE - Use the last block’s value (consecutive COINBASE value may appear on-chain)
  • 62. Cat and Mouse - TOCTOU ● Simulating the transaction + confirming it takes time ● Malicious application can leverage it: ○ Dapp checks the timestamp when the tx was craftet ○ Contract checks time elapsed ● Red Pill predicate ○ Is blockDiff > X
  • 63. Demo - Exploiting using TOCTOU
  • 65. Takeaways ● Web3 enables decentralized apps with thrilling use cases ● However, it creates new attack surfaces ○ Rogue contracts ○ Rogue interfaces ● Users have no visibility to what they are signing! ● You cannot fight what you cannot see ● Transaction simulation provides visibility ○ But has some limitations and can be attacked ■ Red Pills! ● Transaction simulation should be implemented securely ● With this new visibility, Web3 firewalls can save the users!

Editor's Notes

  1. What is blockchain [20 mins] Distributed database Private key, public key, signing, address, transaction MPC in a nutshell Fees Explorers Ethereum [25 mins] Ethereum vs. Bitcoin Smart contracts and apps: ERC20 NFTs DeFi Web3 and WalletConnect Web3 security in a nutshell Other chains [5 mins] Honorable mentions for chains ZenGo supports / supported / will support: Tezos, Dogecoin, Terra, Binance, Solana Layer 2 Team [5m] Research team - areas of research: Blockchain, Security, Cryptography and MPC people
  2. https://opensea.io/assets/0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d/2087 https://rarible.com/token/0xaa20f900e24ca7ed897c44d92012158f436ef791:5040?tab=details https://etherscan.io/token/0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d?a=2087#inventory
  3. Can click “connect” to connect a wallet Web2 app suggests Txs Attacker wants to suggest malicious transactions Talk about ERC20
  4. It’s difficult to explain the meaning of state changes in contracts
  5. https://polygonscan.com/tx/0x60405147f7dbab4f183ff7a57eefa317c062f0c7df93bfeab700575d47075b37 - Rabby exploiting tx