SlideShare a Scribd company logo
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

Host-based Security
Host-based SecurityHost-based Security
Host-based Security
secdevmel
 
Python Cryptography & Security
Python Cryptography & SecurityPython Cryptography & Security
Python Cryptography & Security
Jose Manuel Ortega Candel
 
Idea(international data encryption algorithm)
Idea(international data encryption algorithm)Idea(international data encryption algorithm)
Idea(international data encryption algorithm)
SAurabh PRajapati
 
Secret sharing schemes
Secret sharing schemesSecret sharing schemes
Secret sharing schemeswonloser
 
Elliptic Curve Cryptography
Elliptic Curve CryptographyElliptic Curve Cryptography
Elliptic Curve Cryptography
JorgeVillamarin5
 
Cryptography
CryptographyCryptography
Cryptography
EmaSushan
 
Thomvest Ventures Real Estate Tech Review, Fall 2019
Thomvest Ventures Real Estate Tech Review, Fall 2019Thomvest Ventures Real Estate Tech Review, Fall 2019
Thomvest Ventures Real Estate Tech Review, Fall 2019
Thomvest Ventures
 
Ipsec
IpsecIpsec
Blockchain Technology | Blockchain Explained | Blockchain Tutorial | Blockcha...
Blockchain Technology | Blockchain Explained | Blockchain Tutorial | Blockcha...Blockchain Technology | Blockchain Explained | Blockchain Tutorial | Blockcha...
Blockchain Technology | Blockchain Explained | Blockchain Tutorial | Blockcha...
Edureka!
 
Blockchain Technology Explained | Blockchain Technology Tutorial | Blockchain...
Blockchain Technology Explained | Blockchain Technology Tutorial | Blockchain...Blockchain Technology Explained | Blockchain Technology Tutorial | Blockchain...
Blockchain Technology Explained | Blockchain Technology Tutorial | Blockchain...
Simplilearn
 
Cloud Security Demystified
Cloud Security DemystifiedCloud Security Demystified
Cloud Security Demystified
Michael Torres
 
Distributed Ledger PowerPoint Presentation Slides
Distributed Ledger PowerPoint Presentation SlidesDistributed Ledger PowerPoint Presentation Slides
Distributed Ledger PowerPoint Presentation Slides
SlideTeam
 
Cardano-The Third Generation Blockchain Technology.pptx
Cardano-The Third Generation Blockchain Technology.pptxCardano-The Third Generation Blockchain Technology.pptx
Cardano-The Third Generation Blockchain Technology.pptx
RashilaShrestha
 
The Walgreens Story: Putting an API Around Their Stores (Webcast)
The Walgreens Story: Putting an API Around Their Stores (Webcast)The Walgreens Story: Putting an API Around Their Stores (Webcast)
The Walgreens Story: Putting an API Around Their Stores (Webcast)
Apigee | Google Cloud
 
Diffie hellman key exchange algorithm
Diffie hellman key exchange algorithmDiffie hellman key exchange algorithm
Diffie hellman key exchange algorithm
Sunita Kharayat
 
Darknet
DarknetDarknet
Hyperledger Architecture Vol 2 > Smart Contracts
Hyperledger Architecture Vol 2 > Smart ContractsHyperledger Architecture Vol 2 > Smart Contracts
Hyperledger Architecture Vol 2 > Smart Contracts
VIJAY MUTHU
 
Non-fungible tokens (nfts)
Non-fungible tokens (nfts)Non-fungible tokens (nfts)
Non-fungible tokens (nfts)
Gene Leybzon
 
Blockchain
BlockchainBlockchain
Blockchain
Amit Kumar
 
Ethical hacking
Ethical hackingEthical hacking
Ethical hacking
VipinYadav257
 

What's hot (20)

Host-based Security
Host-based SecurityHost-based Security
Host-based Security
 
Python Cryptography & Security
Python Cryptography & SecurityPython Cryptography & Security
Python Cryptography & Security
 
Idea(international data encryption algorithm)
Idea(international data encryption algorithm)Idea(international data encryption algorithm)
Idea(international data encryption algorithm)
 
Secret sharing schemes
Secret sharing schemesSecret sharing schemes
Secret sharing schemes
 
Elliptic Curve Cryptography
Elliptic Curve CryptographyElliptic Curve Cryptography
Elliptic Curve Cryptography
 
Cryptography
CryptographyCryptography
Cryptography
 
Thomvest Ventures Real Estate Tech Review, Fall 2019
Thomvest Ventures Real Estate Tech Review, Fall 2019Thomvest Ventures Real Estate Tech Review, Fall 2019
Thomvest Ventures Real Estate Tech Review, Fall 2019
 
Ipsec
IpsecIpsec
Ipsec
 
Blockchain Technology | Blockchain Explained | Blockchain Tutorial | Blockcha...
Blockchain Technology | Blockchain Explained | Blockchain Tutorial | Blockcha...Blockchain Technology | Blockchain Explained | Blockchain Tutorial | Blockcha...
Blockchain Technology | Blockchain Explained | Blockchain Tutorial | Blockcha...
 
Blockchain Technology Explained | Blockchain Technology Tutorial | Blockchain...
Blockchain Technology Explained | Blockchain Technology Tutorial | Blockchain...Blockchain Technology Explained | Blockchain Technology Tutorial | Blockchain...
Blockchain Technology Explained | Blockchain Technology Tutorial | Blockchain...
 
Cloud Security Demystified
Cloud Security DemystifiedCloud Security Demystified
Cloud Security Demystified
 
Distributed Ledger PowerPoint Presentation Slides
Distributed Ledger PowerPoint Presentation SlidesDistributed Ledger PowerPoint Presentation Slides
Distributed Ledger PowerPoint Presentation Slides
 
Cardano-The Third Generation Blockchain Technology.pptx
Cardano-The Third Generation Blockchain Technology.pptxCardano-The Third Generation Blockchain Technology.pptx
Cardano-The Third Generation Blockchain Technology.pptx
 
The Walgreens Story: Putting an API Around Their Stores (Webcast)
The Walgreens Story: Putting an API Around Their Stores (Webcast)The Walgreens Story: Putting an API Around Their Stores (Webcast)
The Walgreens Story: Putting an API Around Their Stores (Webcast)
 
Diffie hellman key exchange algorithm
Diffie hellman key exchange algorithmDiffie hellman key exchange algorithm
Diffie hellman key exchange algorithm
 
Darknet
DarknetDarknet
Darknet
 
Hyperledger Architecture Vol 2 > Smart Contracts
Hyperledger Architecture Vol 2 > Smart ContractsHyperledger Architecture Vol 2 > Smart Contracts
Hyperledger Architecture Vol 2 > Smart Contracts
 
Non-fungible tokens (nfts)
Non-fungible tokens (nfts)Non-fungible tokens (nfts)
Non-fungible tokens (nfts)
 
Blockchain
BlockchainBlockchain
Blockchain
 
Ethical hacking
Ethical hackingEthical hacking
Ethical hacking
 

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

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
Daniel 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 2018
Codemotion
 
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 contracts
Gautam Anand
 
Fluent destry saul
Fluent destry saulFluent destry saul
Fluent destry saul
Destry Saul
 
Ethereum
EthereumEthereum
Ethereum
Brian Yap
 
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
DevCamp 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 Engineer
Product School
 
Blockchain architected
Blockchain architectedBlockchain architected
Blockchain architected
IBM Sverige
 
Building Apps with Ethereum Smart Contract
Building Apps with Ethereum Smart ContractBuilding Apps with Ethereum Smart Contract
Building Apps with Ethereum Smart Contract
Vaideeswaran Sethuraman
 
Blockchain, bitcoin, ethereum and ICOs
Blockchain, bitcoin, ethereum and ICOsBlockchain, bitcoin, ethereum and ICOs
Blockchain, bitcoin, ethereum and ICOs
Bogdan Fiedur
 
Blockchain Basics
Blockchain BasicsBlockchain Basics
Blockchain Basics
Ali Ayyash
 
BlockChain Basic Concepts
BlockChain Basic ConceptsBlockChain Basic Concepts
BlockChain Basic Concepts
MuLearn
 
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
PolySwarm
 
Ergo Hong Kong meetup
Ergo Hong Kong meetupErgo Hong Kong meetup
Ergo Hong Kong meetup
Dmitry Meshkov
 
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
Product School
 
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
101 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
 
Deployablockchainwebappwithhyperledgerfabricpresentation 190820170703
Deployablockchainwebappwithhyperledgerfabricpresentation 190820170703Deployablockchainwebappwithhyperledgerfabricpresentation 190820170703
Deployablockchainwebappwithhyperledgerfabricpresentation 190820170703
Nevruz Mesut Sahin
 

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

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 ...
 
Deployablockchainwebappwithhyperledgerfabricpresentation 190820170703
Deployablockchainwebappwithhyperledgerfabricpresentation 190820170703Deployablockchainwebappwithhyperledgerfabricpresentation 190820170703
Deployablockchainwebappwithhyperledgerfabricpresentation 190820170703
 

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 Liquidation
Tal Be'ery
 
The Color of Money
The Color of MoneyThe Color of Money
The Color of Money
Tal Be'ery
 
Open Sesame: Picking Locks with Cortana
Open Sesame: Picking Locks with CortanaOpen Sesame: Picking Locks with Cortana
Open Sesame: Picking Locks with Cortana
Tal 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 Cybersecurity
Tal Be'ery
 
The Industrial Revolution of Lateral Movement
The Industrial Revolution of Lateral MovementThe Industrial Revolution of Lateral Movement
The Industrial Revolution of Lateral Movement
Tal 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 Users
Tal Be'ery
 
Target Breach Analysis
Target Breach AnalysisTarget Breach Analysis
Target Breach Analysis
Tal Be'ery
 
Battlefield network
Battlefield networkBattlefield network
Battlefield network
Tal Be'ery
 
Client sidesec 2013-intro
Client sidesec 2013-introClient sidesec 2013-intro
Client sidesec 2013-intro
Tal Be'ery
 
Client sidesec 2013 - non js
Client sidesec 2013 - non jsClient sidesec 2013 - non js
Client sidesec 2013 - non js
Tal Be'ery
 
Client sidesec 2013 - script injection
Client sidesec 2013 - script injectionClient sidesec 2013 - script injection
Client sidesec 2013 - script injection
Tal 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 Malware
Tal 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

Enterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptxEnterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptx
QuickwayInfoSystems3
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
abdulrafaychaudhry
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
lorraineandreiamcidl
 
Game Development with Unity3D (Game Development lecture 3)
Game Development  with Unity3D (Game Development lecture 3)Game Development  with Unity3D (Game Development lecture 3)
Game Development with Unity3D (Game Development lecture 3)
abdulrafaychaudhry
 
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptxText-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
ShamsuddeenMuhammadA
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Nidhi Software Price. Fact , Costs, Tips
Nidhi Software Price. Fact , Costs, TipsNidhi Software Price. Fact , Costs, Tips
Nidhi Software Price. Fact , Costs, Tips
vrstrong314
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
Deuglo Infosystem Pvt Ltd
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni García
 

Recently uploaded (20)

Enterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptxEnterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptx
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
 
Game Development with Unity3D (Game Development lecture 3)
Game Development  with Unity3D (Game Development lecture 3)Game Development  with Unity3D (Game Development lecture 3)
Game Development with Unity3D (Game Development lecture 3)
 
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptxText-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Nidhi Software Price. Fact , Costs, Tips
Nidhi Software Price. Fact , Costs, TipsNidhi Software Price. Fact , Costs, Tips
Nidhi Software Price. Fact , Costs, Tips
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
 

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