SlideShare a Scribd company logo
www.securing.pldrdr_zz
Damian Rusinek
Web Apps vs Blockchain
dApps (Smart Contracts):
tools, vulns and standards
OWASP Poland Day, Wrocław 2019
16th of October 2019
www.securing.pldrdr_zzdrdr_zz
Damian Rusinek
damianrusinek @ github
• Pentester
• Researcher
• Focused on blockchain and smart contracts
Security Researcher & Pentester
Assistant Professor
Introducing Decentralized Applications by analogy to Web Apps
https://bit.ly/2kpfKkm
Last year on AppSec EU London
& OWASP Poland Day Warsaw
drdr_zz
www.securing.pldrdr_zzdrdr_zz
Web 3.0
They are using Decentralized Applications or Platforms
www.securing.pldrdr_zz www.securing.pldrdr_zz
Decentralized Apps
And why are they becoming important?
WHAT IS IT?
www.securing.pldrdr_zzdrdr_zz
What are Decentralized Applications?
• Decentralized Application are like Web Applications with decentralized
storage and governance.
• Web Apps
• Facebook
• Reddit
• Decentralized Apps
• Steemit (a kind of decentralized Reddit)
www.securing.pldrdr_zzdrdr_zz
Why are Decentralized Applications important?
• There exist great projects already:
• Augur (decentralized oracle and prediction market),
• Gnosis (prediction platform),
• MakerDAO (decentralized finance).
• The market is worth billions of $ in cryptocurrencies.
• A chance for new technologies (e.g. financial technology)
• Easy decentralized banking,
• No brokers (direct payments).
• Big players:
• Hyperledger (Linux Foundation, IBM, Intel, SAP),
• Libra (Facebook).
www.securing.pldrdr_zzdrdr_zz
What is so special about Decentralized Apps?
• Trustlessness: Use blockchain to store code and data (state).
• No one can turn it off permanently (anyone can bring it to live).
• Everyone can have it (like keeping the database of FB or Reddit locally).
www.securing.pldrdr_zzdrdr_zz
Where is the main difference?
Architecture
Decentralized ApplicationWeb Application
www.securing.pldrdr_zzdrdr_zz
Where is the main difference?
Architecture
Web Application Hybrid Decentralized Application
www.securing.pldrdr_zz www.securing.pldrdr_zz
Decentralized Apps
ARE THOSE SECURE?
www.securing.pldrdr_zzdrdr_zz
Are Decentralized Apps secure?
• Undestroyable: No one can turn it off
• Cryptographically secure: All transactions are digitally signed
• Publicly verifiable: Anyone can verify the code of smart contracts
• But still….
www.securing.pldrdr_zzdrdr_zz
Are Decentralized Apps secure?
• Undestroyable: No one can turn it off
• Cryptographically secure: All transactions are digitally signed
• Publicly verifiable: Anyone can verify the code of smart contracts
• But still….
www.securing.pldrdr_zzdrdr_zz
Are Decentralized Apps secure?
• Undestroyable: No one can turn it off
• Cryptographically secure: All transactions are digitally signed
• Publicly verifiable: Anyone can verify the code of smart contracts
• But still….
Expectations Reality
www.securing.pldrdr_zz www.securing.pldrdr_zz
Web Apps vs Decentralized Apps
WE NEED SECURITY!
www.securing.pldrdr_zzdrdr_zz
Security Projects & Standards
Web Apps
• Most common vulnerabilities?
• OWASP Top 10
• The knowledge base about the
weaknesses?
• Mitre CWE (Common Weakness
Enumeration)
• The end to end security checklist to
perform an audit?
• OWASP ASVS (Application
Security Verification Standard)
Decentralized Apps
• Most common vulnerabilities?
• DASP Top 10 (https://dasp.co)
• The knowledge base about the
weaknesses?
• SWC Registry
(https://smartcontractsecurity.github.io/SWC-registry/)
• The end to end security checklist to
perform an audit?
www.securing.pldrdr_zz www.securing.pldrdr_zz
SCSVS
- Smart Contracts Security Verification Standard
www.securing.pldrdr_zzdrdr_zz
• Objectives:
• Provide a checklist for architects, developers and security
reviewers.
• Help to mitigate known vulnerabilities by design.
• Help to develop high quality code of the smart contracts.
• Provide a clear and reliable assessment of how secure the
smart contract is in relation to the percentage of SCSVS
coverage.
• Format similar to ASVS.
SCSVS - Objectives
www.securing.pldrdr_zzdrdr_zz
SCSVS - Categrories
V8: Business Logic
V9: Denial of Service
V10: Token
V11: Code Clarity
V12: Test Coverage
V13: Known Attacks
V1: Architecture, Design
and Threat Modelling
V2: Access Control
V3: Blockchain Data
V4: Communications
V5: Arithmetic
V6: Malicious Input
Handling
V7: Gas Usage & Limitations
www.securing.pldrdr_zzdrdr_zz
Software Development Life Cycle
SCSVS covers all stages
of SDLC process.
www.securing.pldrdr_zzdrdr_zz
• Approaches
• OWASP SAMM
• SDL (Security Development
Lifecycle)
• BSIMM (Builing Secuirty in Maturity
Model)
Software Development Life Cycle
DISCLAIMER
This is not a presentation about how
to introduce security to your SDLC.
www.securing.pldrdr_zz www.securing.pldrdr_zz
Web Apps vs Decentralized Apps
- Analysis & Requirements
SDLC
www.securing.pldrdr_zzdrdr_zz
Similiarities
• Threat modelling
SDLC – Analysis & Requirements
1.1 Verify that the every introduced design change is preceded by an earlier threat
modelling.
1.2 Verify that the documentation clearly and precisely defines all trust boundaries
in the contract (trusted relations with other contracts and significant data flows).
www.securing.pldrdr_zzdrdr_zz
Differences – Sensitive data
SDLC – Analysis & Requirements
Web Apps
• Stored in protected database
Decentralized Apps
• Stored on public blockchain
• Forever
• Anyone can read
3.1 Verify that any data saved in the contracts is not considered safe or private
(even private variables).
3.2 Verify that no confidential data is stored in the blockchain (passwords, personal
data, token etc.).
www.securing.pldrdr_zzdrdr_zz
Differences – Public access
SDLC – Analysis & Requirements
Web Apps
• Allowed only to part of application
• Frontend
• API
Decentralized Apps
• Allowed to the whole application
• Code is public
• Functions are public by default
www.securing.pldrdr_zzdrdr_zz
Differences – Public access
SDLC – Analysis & Requirements
• Parity Wallet hack
• 150k ETH stolen (~30kk $)
• https://bit.ly/2kpfKkm
2.7 Verify that visibility of all functions is specified.
www.securing.pldrdr_zzdrdr_zz
Differences – Randomness
SDLC – Analysis & Requirements
Web Apps
• A matter of a function call
Decentralized Apps
• Not trivially achieved in the
decentralized computer
• No local parameters can be used
www.securing.pldrdr_zzdrdr_zz
Differences – Randomness
SDLC – Analysis & Requirements
• EOSPlay hack
• 30k EOS stolen (~100k USD)
• SmartBillions Lottery hack
• 400 ETH stolen (~80k USD)
• https://bit.ly/2jJEKPd
7.5 Verify that the contract does not generate pseudorandom numbers trivially
basing on the information from blockchain (e.g. seeding with the block number).
www.securing.pldrdr_zzdrdr_zz
New threat actors for Decentralized Apps
SDLC – Requirements & Analysis
• Miners/Validators
• Validate transactions and add new blocks
www.securing.pldrdr_zzdrdr_zz
New threat actors for Decentralized Apps
SDLC – Requirements & Analysis
• Augur vulnerability
• DoS on smart contract
• Business logic abuse by miner
• 5k $ bounty
https://hackerone.com/reports/377398
www.securing.pldrdr_zzdrdr_zz
New threat actors for Decentralized Apps
SDLC – Requirements & Analysis
8.1 Verify that the contract logic implementation corresponds to the
documentation.
8.3 Verify that the contract has business limits and correctly enforces it.
9.3 Verify that the contract logic does not disincentivize users to use contracts (e.g.
the cost of transaction is higher than the profit).
www.securing.pldrdr_zz www.securing.pldrdr_zz
Web Apps vs Decentralized Apps
- Design
SDLC
www.securing.pldrdr_zzdrdr_zz
Similiarities
• Least privilege rule
• Access control
• Public and known to everyone
• Centralized and simple
SDLC – Design
2.3 Verify that the creator of the contract complies with the rule of least privilege and
his rights strictly follow the documentation.
2.11 Verify that all user and data attributes used by access controls are kept in trusted
contract and cannot be manipulated by other contracts unless specifically authorized.
www.securing.pldrdr_zzdrdr_zz
Differences – Loops
SDLC – Design
Web Apps
• Infinite loops -> DoS
Decentralized Apps
• Unbound loops -> DoS
www.securing.pldrdr_zzdrdr_zz
Differences – Loops
SDLC – Design
• GovernMentals
• A ponzi scheme
• Iteration over a huge array
• 1100 ETH frozen
• https://bit.ly/2kVXwaj
7.3 Verify that the contract does not iterate over unbound loops.
8.8 Verify that the contract does not send funds automatically but it lets
users withdraw funds on their own in separate transaction instead.
www.securing.pldrdr_zzdrdr_zz
Decreasing the risk
SDLC – Design
• Decentralized Applications keep cryptocurrencies
• The higher the amount the bigger the incentive for hackers
1.8 Verify that the amount of cryptocurrencies kept on contract is controlled and at
the minimal acceptable level.
www.securing.pldrdr_zz www.securing.pldrdr_zz
Web Apps vs Decentralized Apps
- Implementation
SDLC
www.securing.pldrdr_zzdrdr_zz
• Great tools
• Perform basic security analysis
• But we still make bugs.
• Sounds familiar? ☺
SDLC – Implementation
www.securing.pldrdr_zzdrdr_zz
Similarities – Arithmetic bugs
SDLC – Implementation
Web Apps
• Not that common
Decentralized Apps
• Overflows and underflows
www.securing.pldrdr_zzdrdr_zz
Similarities – Arithmetic bugs
SDLC – Implementation
• Multiple ERC20 Smart Contracts
• Allow to transfer more than
decillions (10^60) of tokens
• https://bit.ly/2lWa9ma
• https://bit.ly/2ksNEF1
www.securing.pldrdr_zzdrdr_zz
Similarities – Arithmetic bugs
SDLC – Implementation
5.1 Verify that the values and math operations are resistant to integer
overflows. Use SafeMath library for arithmetic operations.
5.2 Verify that the extreme values (e.g. maximum and minimum values of the
variable type) are considered and does change the logic flow of the contract.
5.3 Verify that non-strict inequality is used for balance equality.
www.securing.pldrdr_zzdrdr_zz
Differences – Recursive calls
SDLC – Implementation
Web Apps
• Must be explicitly included in the
logic
Decentralized Apps
• Executing some logic multiple times
in one call
• The DAO hack
• Recursive withdrawals
• 3.6 mln ETH stolen
• https://bit.ly/2hBQjKq
4.5 Verify that re-entrancy attack is mitigated by blocking recursive calls from
other contracts. Do not use call and send function unless it is a must.
4.6 Verify that the result of low-level function calls (e.g. send, delegatecall,
call) from another contracts is checked.
www.securing.pldrdr_zz www.securing.pldrdr_zz
Web Apps vs Decentralized Apps
- Testing
SDLC
www.securing.pldrdr_zzdrdr_zz
Similarities – Great tools for automatic scans
SDLC – Testing
Web Apps Decentralized Apps
1.11 Verify that code analysis tools are in use that
can detect potentially malicious code.
https://securify.ch https://bit.ly/2mpaL3U
https://tool.smartdec.net
https://mythx.io/
www.securing.pldrdr_zzdrdr_zz
Similiarities – Ensuring the testing takes place
• including manual security tests
SDLC – Analysis & Requirements
12.1 Verify that all functions of verified contract are covered with tests in the
development phase.
12.2 Verify that the implementation of verified contract has been checked for
security vulnerabilities using static and dynamic analysis.
12.3 Verify that the specification of smart contract has been formally verified.
12.4 Verify that the specification and the result of formal verification is included in
the documentation.
1.3 Verify that the SCSVS, security requirements or policy is available to all
developers and testers.
www.securing.pldrdr_zzdrdr_zz
Similiarities – Business logic errors
• Hard to find using automated scans
• MakerDAO vulnerability
• Allows to create DAI
cryptocurrency without
coverage
• 25k $ bounty
SDLC – Analysis & Requirements
1.10 Verify that the business logic in contracts is consistent. Important changes in the logic
should be allowed for all or none of the contracts.
8.2 Verify that the business logic flows of smart contracts proceed in a sequential step order
and it is not possible to skip any part of it or to do it in a different order than designed.
https://hackerone.com/reports/672664
www.securing.pldrdr_zz www.securing.pldrdr_zz
Web Apps vs Decentralized Apps
- Deployment
SDLC
www.securing.pldrdr_zzdrdr_zz
Differences – Initialization stage
SDLC – Deployment
Web Apps
• Setting up configurations and
integrations
• Performed once during deployment
Decentralized Apps
• Setting up configurations and
integrations
• What if one can (re-)initialize the
contract?
www.securing.pldrdr_zzdrdr_zz
Differences – Initialization stage
SDLC – Deployment
• Parity Wallet hack (2nd):
• Kill contract shared by hundreds
of other contracts
• 500k ETH frozen (~100kk USD)
• https://bit.ly/2kIBYhA
• https://bit.ly/2kpfKkm
www.securing.pldrdr_zzdrdr_zz
Differences – Initialization stage
SDLC – Deployment
11.7 Verify that all storage variables are initialised.
2.8 Verify that the initialization functions are marked
internal and cannot be executed twice.
9.1 Verify that the self-destruct functionality is used only
if necessary.
www.securing.pldrdr_zz www.securing.pldrdr_zz
Web Apps vs Decentralized Apps
- Maintenance
SDLC
www.securing.pldrdr_zzdrdr_zz
Similarities – Logs
SDLC – Maintenance
Web Apps
• Kept safe on the server
Decentralized Apps
• Public events
3.4 Verify that there is a component that monitors access to sensitive
contract data using events.
www.securing.pldrdr_zzdrdr_zz
Differences – Security Alert and Fix
SDLC – Maintenance
Web Apps
• Application goes down
• The bug is fixed (patch)
• Application redeployed
Decentralized Apps
• Smart contract goes down
• The bug is fixed (patch)
• Smart contract deployed again
1.6 Verify that there exists a mechanism that can temporarily stop the sensitive functionalities of the contract in
case of a new attack. This mechanism should not block access to the assets (e.g. tokens) for the owners.
1.4 Verify that there exists an upgrade process for the contract which allows
to deploy the security fixes.
www.securing.pldrdr_zzdrdr_zz
Security Projects & Standards
Web Apps
• Most common vulnerabilities?
• OWASP Top 10
• The knowledge base about the
weaknesses?
• Mitre CWE (Common Weakness
Enumeration)
• The end to end security checklist to
perform an audit?
• OWASP ASVS (Application
Security Verification Standard)
Decentralized Apps
• Most common vulnerabilities?
• DASP Top 10 (https://dasp.co)
• The knowledge base about the
weaknesses?
• SWC Registry
(https://smartcontractsecurity.github.io/SWC-registry/)
• The end to end security checklist to
perform an audit?
SCSVS
www.securing.pldrdr_zzdrdr_zz
V13: Known attacks
SCSVS – The special category
• Quick check for well known attacks
13.4 Verify that the contract is not vulnerable to Silent Failing Sends and
Unchecked-Send attacks.
[4.6] Verify that the result of low-level function calls (e.g. send, delegatecall, call)
from another contracts is checked.
[4.7] Verify that the third party contracts do not shadow special functions (e.g.
revert).
13.2 Verify that the contract is not vulnerable to Reentrancy attack.
[4.5] Verify that the re-entrancy attack is mitigated by blocking recursive calls from
the other contracts. Do not use call and send functions unless it is a must.
www.securing.pldrdr_zz
Thank you!
Damian.Rusinek@securing.pl
@drdr_zz
Free 13-part
security checklist
Want a security audit
of smart contract?
Go for SCSVS!

More Related Content

PPTX
[OPD 2019] Inter-application vulnerabilities
PDF
[OPD 2019] Threat modeling at scale
PDF
[OPD 2019] .NET Core Security
PPTX
[OPD 2019] AST Platform and the importance of multi-layered application secu...
PDF
[OPD 2019] Automated Defense with Serverless computing
PDF
[OPD 2019] Storm Busters: Auditing & Securing AWS Infrastructure
PDF
[OPD 2019] Trusted types and the end of DOM XSS
PPTX
Security in microservices architectures
[OPD 2019] Inter-application vulnerabilities
[OPD 2019] Threat modeling at scale
[OPD 2019] .NET Core Security
[OPD 2019] AST Platform and the importance of multi-layered application secu...
[OPD 2019] Automated Defense with Serverless computing
[OPD 2019] Storm Busters: Auditing & Securing AWS Infrastructure
[OPD 2019] Trusted types and the end of DOM XSS
Security in microservices architectures

What's hot (20)

PDF
Microservices Security: dos and don'ts
PPTX
AppSec EU 2016: Automated Mobile Application Security Assessment with MobSF
PPTX
Zero trust Architecture
PDF
API Security in a Microservices World
PPTX
G4H Webcast: Automated Security Analysis of Mobile Applications with Mobile S...
PPTX
Owasp Mobile Risk Series : M4 : Unintended Data Leakage
PDF
Beyond the mcse red teaming active directory
PDF
Are You Properly Using JWTs?
PDF
WEBINAR: Positive Security for APIs: What it is and why you need it!
PDF
Dev secops on the offense automating amazon web services account takeover
PDF
(SACON) Pradyumn Nand & Mrinal Pande - Metron & Blitz, Building and scaling y...
PDF
Red Team vs. Blue Team on AWS
PDF
Building layers of defense for your application
PDF
Checkmarx meetup API Security - API Security top 10 - Erez Yalon
PDF
WebApps vs Blockchain dApps (SmartContracts): tools, vulns and standards
PDF
Acunetix Training and ScanAssist
PDF
A Deep Dive into Spring Application Events
PPTX
Vulnerabilities in modern web applications
PDF
Application Security Workshop
PDF
BlueHat v18 || software supply chain attacks in 2018 - predictions vs reality
Microservices Security: dos and don'ts
AppSec EU 2016: Automated Mobile Application Security Assessment with MobSF
Zero trust Architecture
API Security in a Microservices World
G4H Webcast: Automated Security Analysis of Mobile Applications with Mobile S...
Owasp Mobile Risk Series : M4 : Unintended Data Leakage
Beyond the mcse red teaming active directory
Are You Properly Using JWTs?
WEBINAR: Positive Security for APIs: What it is and why you need it!
Dev secops on the offense automating amazon web services account takeover
(SACON) Pradyumn Nand & Mrinal Pande - Metron & Blitz, Building and scaling y...
Red Team vs. Blue Team on AWS
Building layers of defense for your application
Checkmarx meetup API Security - API Security top 10 - Erez Yalon
WebApps vs Blockchain dApps (SmartContracts): tools, vulns and standards
Acunetix Training and ScanAssist
A Deep Dive into Spring Application Events
Vulnerabilities in modern web applications
Application Security Workshop
BlueHat v18 || software supply chain attacks in 2018 - predictions vs reality
Ad

Similar to [OPD 2019] Web Apps vs Blockchain dApps (20)

PDF
WebApps vs Blockchain dApps (SmartContracts): tools, vulns and standards
PDF
Web Apps vs Blockchain dApps (Smart Contracts): tools, vulns and standards
PDF
Distributed Ledger Security in the Enterprise Environment
PDF
Attacking and Exploiting Ethereum Smart Contracts: Auditing 101
PDF
DWeb and Civil Society: An Introduction For Makers
PPTX
DECENTRALIZED APPLICATIONS USING BLOCKCHAING TECHNOLOGY.pptx
PDF
Blockchain-based Applications
PPTX
Exploring Popular Platforms for Decentralized Application (dApp) Development
PDF
What are DApps.pdf
PPTX
DApps_ Security Issues, Hacks, and Preventive Measures.pptx
PDF
Alternative Consensus & Enterprise Blockchain
PPTX
Practical Challenges for Public Blockchains
PPTX
Practical Challenges for Public Blockchains
PDF
Decentralized applications 101: How and why to build a DApp
PDF
Introduction to Ethereum Blockchain & Smart Contract
PPTX
Overcoming the Barriers to Blockchain Adoption
PPTX
MongoDB and BlockChain
PPTX
Is Blockchain Right for You? The Million Dollar Question
PPTX
Blockchain 101
PPTX
Blockchain Advances & its Applications.pptx
WebApps vs Blockchain dApps (SmartContracts): tools, vulns and standards
Web Apps vs Blockchain dApps (Smart Contracts): tools, vulns and standards
Distributed Ledger Security in the Enterprise Environment
Attacking and Exploiting Ethereum Smart Contracts: Auditing 101
DWeb and Civil Society: An Introduction For Makers
DECENTRALIZED APPLICATIONS USING BLOCKCHAING TECHNOLOGY.pptx
Blockchain-based Applications
Exploring Popular Platforms for Decentralized Application (dApp) Development
What are DApps.pdf
DApps_ Security Issues, Hacks, and Preventive Measures.pptx
Alternative Consensus & Enterprise Blockchain
Practical Challenges for Public Blockchains
Practical Challenges for Public Blockchains
Decentralized applications 101: How and why to build a DApp
Introduction to Ethereum Blockchain & Smart Contract
Overcoming the Barriers to Blockchain Adoption
MongoDB and BlockChain
Is Blockchain Right for You? The Million Dollar Question
Blockchain 101
Blockchain Advances & its Applications.pptx
Ad

More from OWASP (20)

PDF
[OPD 2019] Life after pentest
PDF
[OPD 2019] Top 10 Security Facts of 2020
PDF
[OPD 2019] Governance as a missing part of IT security architecture
PPTX
[OPD 2019] Side-Channels on the Web:
Attacks and Defenses
PDF
[OPD 2019] Advanced Data Analysis in RegSOC
PDF
[OPD 2019] Attacking JWT tokens
PDF
[OPD 2019] Rumpkernels meet fuzzing
PDF
[Wroclaw #9] The purge - dealing with secrets in Opera Software
PDF
[Wroclaw #9] To be or Not To Be - Threat Modeling in Security World
PDF
OWASP Poland 13 November 2018 - Martin Knobloch - Building Secure Software
PDF
OWASP Poland Day 2018 - Amir Shladovsky - Crypto-mining
PDF
OWASP Poland Day 2018 - Damian Rusinek - Outsmarting smart contracts
PDF
OWASP Poland Day 2018 - Frans Rosen - Attacking modern web technologies
PDF
OWASP Poland Day 2018 - Dani Ramirez - IPMI hacking
PPTX
OWASP Poland Day 2018 - Pedro Fortuna - Are your Java Script based protection...
PPTX
OWASP Poland Day 2018 - Omer Levi Hevroni - Secure the Pipeline
PDF
OWASP Poland Day 2018 - Kuai Hinojosa - Key tips to build resilient software
PPTX
OWASP Poland Day 2018 - Ralf Kempf - SAP Security - Detecting the hand still ...
PDF
OWASP Poland Day 2018 - Johan Peeters - Designing access control with OAuth a...
PDF
OWASP Poland Day 2018 - Anthony Fielding and William Jardine - Common App Vulns
[OPD 2019] Life after pentest
[OPD 2019] Top 10 Security Facts of 2020
[OPD 2019] Governance as a missing part of IT security architecture
[OPD 2019] Side-Channels on the Web:
Attacks and Defenses
[OPD 2019] Advanced Data Analysis in RegSOC
[OPD 2019] Attacking JWT tokens
[OPD 2019] Rumpkernels meet fuzzing
[Wroclaw #9] The purge - dealing with secrets in Opera Software
[Wroclaw #9] To be or Not To Be - Threat Modeling in Security World
OWASP Poland 13 November 2018 - Martin Knobloch - Building Secure Software
OWASP Poland Day 2018 - Amir Shladovsky - Crypto-mining
OWASP Poland Day 2018 - Damian Rusinek - Outsmarting smart contracts
OWASP Poland Day 2018 - Frans Rosen - Attacking modern web technologies
OWASP Poland Day 2018 - Dani Ramirez - IPMI hacking
OWASP Poland Day 2018 - Pedro Fortuna - Are your Java Script based protection...
OWASP Poland Day 2018 - Omer Levi Hevroni - Secure the Pipeline
OWASP Poland Day 2018 - Kuai Hinojosa - Key tips to build resilient software
OWASP Poland Day 2018 - Ralf Kempf - SAP Security - Detecting the hand still ...
OWASP Poland Day 2018 - Johan Peeters - Designing access control with OAuth a...
OWASP Poland Day 2018 - Anthony Fielding and William Jardine - Common App Vulns

Recently uploaded (20)

PDF
RPKI Status Update, presented by Makito Lay at IDNOG 10
PPT
tcp ip networks nd ip layering assotred slides
DOCX
Unit-3 cyber security network security of internet system
PPTX
Power Point - Lesson 3_2.pptx grad school presentation
PPTX
PptxGenJS_Demo_Chart_20250317130215833.pptx
PPTX
Digital Literacy And Online Safety on internet
PPTX
Slides PPTX World Game (s) Eco Economic Epochs.pptx
PPTX
Job_Card_System_Styled_lorem_ipsum_.pptx
PDF
Testing WebRTC applications at scale.pdf
PDF
Unit-1 introduction to cyber security discuss about how to secure a system
PPTX
innovation process that make everything different.pptx
PDF
The New Creative Director: How AI Tools for Social Media Content Creation Are...
PPTX
Introuction about WHO-FIC in ICD-10.pptx
PDF
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
PDF
SASE Traffic Flow - ZTNA Connector-1.pdf
PDF
Tenda Login Guide: Access Your Router in 5 Easy Steps
PDF
How to Ensure Data Integrity During Shopify Migration_ Best Practices for Sec...
PPTX
522797556-Unit-2-Temperature-measurement-1-1.pptx
PPTX
Introduction about ICD -10 and ICD11 on 5.8.25.pptx
PPTX
artificial intelligence overview of it and more
RPKI Status Update, presented by Makito Lay at IDNOG 10
tcp ip networks nd ip layering assotred slides
Unit-3 cyber security network security of internet system
Power Point - Lesson 3_2.pptx grad school presentation
PptxGenJS_Demo_Chart_20250317130215833.pptx
Digital Literacy And Online Safety on internet
Slides PPTX World Game (s) Eco Economic Epochs.pptx
Job_Card_System_Styled_lorem_ipsum_.pptx
Testing WebRTC applications at scale.pdf
Unit-1 introduction to cyber security discuss about how to secure a system
innovation process that make everything different.pptx
The New Creative Director: How AI Tools for Social Media Content Creation Are...
Introuction about WHO-FIC in ICD-10.pptx
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
SASE Traffic Flow - ZTNA Connector-1.pdf
Tenda Login Guide: Access Your Router in 5 Easy Steps
How to Ensure Data Integrity During Shopify Migration_ Best Practices for Sec...
522797556-Unit-2-Temperature-measurement-1-1.pptx
Introduction about ICD -10 and ICD11 on 5.8.25.pptx
artificial intelligence overview of it and more

[OPD 2019] Web Apps vs Blockchain dApps

  • 1. www.securing.pldrdr_zz Damian Rusinek Web Apps vs Blockchain dApps (Smart Contracts): tools, vulns and standards OWASP Poland Day, Wrocław 2019 16th of October 2019
  • 2. www.securing.pldrdr_zzdrdr_zz Damian Rusinek damianrusinek @ github • Pentester • Researcher • Focused on blockchain and smart contracts Security Researcher & Pentester Assistant Professor Introducing Decentralized Applications by analogy to Web Apps https://bit.ly/2kpfKkm Last year on AppSec EU London & OWASP Poland Day Warsaw drdr_zz
  • 3. www.securing.pldrdr_zzdrdr_zz Web 3.0 They are using Decentralized Applications or Platforms
  • 4. www.securing.pldrdr_zz www.securing.pldrdr_zz Decentralized Apps And why are they becoming important? WHAT IS IT?
  • 5. www.securing.pldrdr_zzdrdr_zz What are Decentralized Applications? • Decentralized Application are like Web Applications with decentralized storage and governance. • Web Apps • Facebook • Reddit • Decentralized Apps • Steemit (a kind of decentralized Reddit)
  • 6. www.securing.pldrdr_zzdrdr_zz Why are Decentralized Applications important? • There exist great projects already: • Augur (decentralized oracle and prediction market), • Gnosis (prediction platform), • MakerDAO (decentralized finance). • The market is worth billions of $ in cryptocurrencies. • A chance for new technologies (e.g. financial technology) • Easy decentralized banking, • No brokers (direct payments). • Big players: • Hyperledger (Linux Foundation, IBM, Intel, SAP), • Libra (Facebook).
  • 7. www.securing.pldrdr_zzdrdr_zz What is so special about Decentralized Apps? • Trustlessness: Use blockchain to store code and data (state). • No one can turn it off permanently (anyone can bring it to live). • Everyone can have it (like keeping the database of FB or Reddit locally).
  • 8. www.securing.pldrdr_zzdrdr_zz Where is the main difference? Architecture Decentralized ApplicationWeb Application
  • 9. www.securing.pldrdr_zzdrdr_zz Where is the main difference? Architecture Web Application Hybrid Decentralized Application
  • 11. www.securing.pldrdr_zzdrdr_zz Are Decentralized Apps secure? • Undestroyable: No one can turn it off • Cryptographically secure: All transactions are digitally signed • Publicly verifiable: Anyone can verify the code of smart contracts • But still….
  • 12. www.securing.pldrdr_zzdrdr_zz Are Decentralized Apps secure? • Undestroyable: No one can turn it off • Cryptographically secure: All transactions are digitally signed • Publicly verifiable: Anyone can verify the code of smart contracts • But still….
  • 13. www.securing.pldrdr_zzdrdr_zz Are Decentralized Apps secure? • Undestroyable: No one can turn it off • Cryptographically secure: All transactions are digitally signed • Publicly verifiable: Anyone can verify the code of smart contracts • But still…. Expectations Reality
  • 14. www.securing.pldrdr_zz www.securing.pldrdr_zz Web Apps vs Decentralized Apps WE NEED SECURITY!
  • 15. www.securing.pldrdr_zzdrdr_zz Security Projects & Standards Web Apps • Most common vulnerabilities? • OWASP Top 10 • The knowledge base about the weaknesses? • Mitre CWE (Common Weakness Enumeration) • The end to end security checklist to perform an audit? • OWASP ASVS (Application Security Verification Standard) Decentralized Apps • Most common vulnerabilities? • DASP Top 10 (https://dasp.co) • The knowledge base about the weaknesses? • SWC Registry (https://smartcontractsecurity.github.io/SWC-registry/) • The end to end security checklist to perform an audit?
  • 16. www.securing.pldrdr_zz www.securing.pldrdr_zz SCSVS - Smart Contracts Security Verification Standard
  • 17. www.securing.pldrdr_zzdrdr_zz • Objectives: • Provide a checklist for architects, developers and security reviewers. • Help to mitigate known vulnerabilities by design. • Help to develop high quality code of the smart contracts. • Provide a clear and reliable assessment of how secure the smart contract is in relation to the percentage of SCSVS coverage. • Format similar to ASVS. SCSVS - Objectives
  • 18. www.securing.pldrdr_zzdrdr_zz SCSVS - Categrories V8: Business Logic V9: Denial of Service V10: Token V11: Code Clarity V12: Test Coverage V13: Known Attacks V1: Architecture, Design and Threat Modelling V2: Access Control V3: Blockchain Data V4: Communications V5: Arithmetic V6: Malicious Input Handling V7: Gas Usage & Limitations
  • 19. www.securing.pldrdr_zzdrdr_zz Software Development Life Cycle SCSVS covers all stages of SDLC process.
  • 20. www.securing.pldrdr_zzdrdr_zz • Approaches • OWASP SAMM • SDL (Security Development Lifecycle) • BSIMM (Builing Secuirty in Maturity Model) Software Development Life Cycle DISCLAIMER This is not a presentation about how to introduce security to your SDLC.
  • 21. www.securing.pldrdr_zz www.securing.pldrdr_zz Web Apps vs Decentralized Apps - Analysis & Requirements SDLC
  • 22. www.securing.pldrdr_zzdrdr_zz Similiarities • Threat modelling SDLC – Analysis & Requirements 1.1 Verify that the every introduced design change is preceded by an earlier threat modelling. 1.2 Verify that the documentation clearly and precisely defines all trust boundaries in the contract (trusted relations with other contracts and significant data flows).
  • 23. www.securing.pldrdr_zzdrdr_zz Differences – Sensitive data SDLC – Analysis & Requirements Web Apps • Stored in protected database Decentralized Apps • Stored on public blockchain • Forever • Anyone can read 3.1 Verify that any data saved in the contracts is not considered safe or private (even private variables). 3.2 Verify that no confidential data is stored in the blockchain (passwords, personal data, token etc.).
  • 24. www.securing.pldrdr_zzdrdr_zz Differences – Public access SDLC – Analysis & Requirements Web Apps • Allowed only to part of application • Frontend • API Decentralized Apps • Allowed to the whole application • Code is public • Functions are public by default
  • 25. www.securing.pldrdr_zzdrdr_zz Differences – Public access SDLC – Analysis & Requirements • Parity Wallet hack • 150k ETH stolen (~30kk $) • https://bit.ly/2kpfKkm 2.7 Verify that visibility of all functions is specified.
  • 26. www.securing.pldrdr_zzdrdr_zz Differences – Randomness SDLC – Analysis & Requirements Web Apps • A matter of a function call Decentralized Apps • Not trivially achieved in the decentralized computer • No local parameters can be used
  • 27. www.securing.pldrdr_zzdrdr_zz Differences – Randomness SDLC – Analysis & Requirements • EOSPlay hack • 30k EOS stolen (~100k USD) • SmartBillions Lottery hack • 400 ETH stolen (~80k USD) • https://bit.ly/2jJEKPd 7.5 Verify that the contract does not generate pseudorandom numbers trivially basing on the information from blockchain (e.g. seeding with the block number).
  • 28. www.securing.pldrdr_zzdrdr_zz New threat actors for Decentralized Apps SDLC – Requirements & Analysis • Miners/Validators • Validate transactions and add new blocks
  • 29. www.securing.pldrdr_zzdrdr_zz New threat actors for Decentralized Apps SDLC – Requirements & Analysis • Augur vulnerability • DoS on smart contract • Business logic abuse by miner • 5k $ bounty https://hackerone.com/reports/377398
  • 30. www.securing.pldrdr_zzdrdr_zz New threat actors for Decentralized Apps SDLC – Requirements & Analysis 8.1 Verify that the contract logic implementation corresponds to the documentation. 8.3 Verify that the contract has business limits and correctly enforces it. 9.3 Verify that the contract logic does not disincentivize users to use contracts (e.g. the cost of transaction is higher than the profit).
  • 31. www.securing.pldrdr_zz www.securing.pldrdr_zz Web Apps vs Decentralized Apps - Design SDLC
  • 32. www.securing.pldrdr_zzdrdr_zz Similiarities • Least privilege rule • Access control • Public and known to everyone • Centralized and simple SDLC – Design 2.3 Verify that the creator of the contract complies with the rule of least privilege and his rights strictly follow the documentation. 2.11 Verify that all user and data attributes used by access controls are kept in trusted contract and cannot be manipulated by other contracts unless specifically authorized.
  • 33. www.securing.pldrdr_zzdrdr_zz Differences – Loops SDLC – Design Web Apps • Infinite loops -> DoS Decentralized Apps • Unbound loops -> DoS
  • 34. www.securing.pldrdr_zzdrdr_zz Differences – Loops SDLC – Design • GovernMentals • A ponzi scheme • Iteration over a huge array • 1100 ETH frozen • https://bit.ly/2kVXwaj 7.3 Verify that the contract does not iterate over unbound loops. 8.8 Verify that the contract does not send funds automatically but it lets users withdraw funds on their own in separate transaction instead.
  • 35. www.securing.pldrdr_zzdrdr_zz Decreasing the risk SDLC – Design • Decentralized Applications keep cryptocurrencies • The higher the amount the bigger the incentive for hackers 1.8 Verify that the amount of cryptocurrencies kept on contract is controlled and at the minimal acceptable level.
  • 36. www.securing.pldrdr_zz www.securing.pldrdr_zz Web Apps vs Decentralized Apps - Implementation SDLC
  • 37. www.securing.pldrdr_zzdrdr_zz • Great tools • Perform basic security analysis • But we still make bugs. • Sounds familiar? ☺ SDLC – Implementation
  • 38. www.securing.pldrdr_zzdrdr_zz Similarities – Arithmetic bugs SDLC – Implementation Web Apps • Not that common Decentralized Apps • Overflows and underflows
  • 39. www.securing.pldrdr_zzdrdr_zz Similarities – Arithmetic bugs SDLC – Implementation • Multiple ERC20 Smart Contracts • Allow to transfer more than decillions (10^60) of tokens • https://bit.ly/2lWa9ma • https://bit.ly/2ksNEF1
  • 40. www.securing.pldrdr_zzdrdr_zz Similarities – Arithmetic bugs SDLC – Implementation 5.1 Verify that the values and math operations are resistant to integer overflows. Use SafeMath library for arithmetic operations. 5.2 Verify that the extreme values (e.g. maximum and minimum values of the variable type) are considered and does change the logic flow of the contract. 5.3 Verify that non-strict inequality is used for balance equality.
  • 41. www.securing.pldrdr_zzdrdr_zz Differences – Recursive calls SDLC – Implementation Web Apps • Must be explicitly included in the logic Decentralized Apps • Executing some logic multiple times in one call • The DAO hack • Recursive withdrawals • 3.6 mln ETH stolen • https://bit.ly/2hBQjKq 4.5 Verify that re-entrancy attack is mitigated by blocking recursive calls from other contracts. Do not use call and send function unless it is a must. 4.6 Verify that the result of low-level function calls (e.g. send, delegatecall, call) from another contracts is checked.
  • 42. www.securing.pldrdr_zz www.securing.pldrdr_zz Web Apps vs Decentralized Apps - Testing SDLC
  • 43. www.securing.pldrdr_zzdrdr_zz Similarities – Great tools for automatic scans SDLC – Testing Web Apps Decentralized Apps 1.11 Verify that code analysis tools are in use that can detect potentially malicious code. https://securify.ch https://bit.ly/2mpaL3U https://tool.smartdec.net https://mythx.io/
  • 44. www.securing.pldrdr_zzdrdr_zz Similiarities – Ensuring the testing takes place • including manual security tests SDLC – Analysis & Requirements 12.1 Verify that all functions of verified contract are covered with tests in the development phase. 12.2 Verify that the implementation of verified contract has been checked for security vulnerabilities using static and dynamic analysis. 12.3 Verify that the specification of smart contract has been formally verified. 12.4 Verify that the specification and the result of formal verification is included in the documentation. 1.3 Verify that the SCSVS, security requirements or policy is available to all developers and testers.
  • 45. www.securing.pldrdr_zzdrdr_zz Similiarities – Business logic errors • Hard to find using automated scans • MakerDAO vulnerability • Allows to create DAI cryptocurrency without coverage • 25k $ bounty SDLC – Analysis & Requirements 1.10 Verify that the business logic in contracts is consistent. Important changes in the logic should be allowed for all or none of the contracts. 8.2 Verify that the business logic flows of smart contracts proceed in a sequential step order and it is not possible to skip any part of it or to do it in a different order than designed. https://hackerone.com/reports/672664
  • 46. www.securing.pldrdr_zz www.securing.pldrdr_zz Web Apps vs Decentralized Apps - Deployment SDLC
  • 47. www.securing.pldrdr_zzdrdr_zz Differences – Initialization stage SDLC – Deployment Web Apps • Setting up configurations and integrations • Performed once during deployment Decentralized Apps • Setting up configurations and integrations • What if one can (re-)initialize the contract?
  • 48. www.securing.pldrdr_zzdrdr_zz Differences – Initialization stage SDLC – Deployment • Parity Wallet hack (2nd): • Kill contract shared by hundreds of other contracts • 500k ETH frozen (~100kk USD) • https://bit.ly/2kIBYhA • https://bit.ly/2kpfKkm
  • 49. www.securing.pldrdr_zzdrdr_zz Differences – Initialization stage SDLC – Deployment 11.7 Verify that all storage variables are initialised. 2.8 Verify that the initialization functions are marked internal and cannot be executed twice. 9.1 Verify that the self-destruct functionality is used only if necessary.
  • 50. www.securing.pldrdr_zz www.securing.pldrdr_zz Web Apps vs Decentralized Apps - Maintenance SDLC
  • 51. www.securing.pldrdr_zzdrdr_zz Similarities – Logs SDLC – Maintenance Web Apps • Kept safe on the server Decentralized Apps • Public events 3.4 Verify that there is a component that monitors access to sensitive contract data using events.
  • 52. www.securing.pldrdr_zzdrdr_zz Differences – Security Alert and Fix SDLC – Maintenance Web Apps • Application goes down • The bug is fixed (patch) • Application redeployed Decentralized Apps • Smart contract goes down • The bug is fixed (patch) • Smart contract deployed again 1.6 Verify that there exists a mechanism that can temporarily stop the sensitive functionalities of the contract in case of a new attack. This mechanism should not block access to the assets (e.g. tokens) for the owners. 1.4 Verify that there exists an upgrade process for the contract which allows to deploy the security fixes.
  • 53. www.securing.pldrdr_zzdrdr_zz Security Projects & Standards Web Apps • Most common vulnerabilities? • OWASP Top 10 • The knowledge base about the weaknesses? • Mitre CWE (Common Weakness Enumeration) • The end to end security checklist to perform an audit? • OWASP ASVS (Application Security Verification Standard) Decentralized Apps • Most common vulnerabilities? • DASP Top 10 (https://dasp.co) • The knowledge base about the weaknesses? • SWC Registry (https://smartcontractsecurity.github.io/SWC-registry/) • The end to end security checklist to perform an audit? SCSVS
  • 54. www.securing.pldrdr_zzdrdr_zz V13: Known attacks SCSVS – The special category • Quick check for well known attacks 13.4 Verify that the contract is not vulnerable to Silent Failing Sends and Unchecked-Send attacks. [4.6] Verify that the result of low-level function calls (e.g. send, delegatecall, call) from another contracts is checked. [4.7] Verify that the third party contracts do not shadow special functions (e.g. revert). 13.2 Verify that the contract is not vulnerable to Reentrancy attack. [4.5] Verify that the re-entrancy attack is mitigated by blocking recursive calls from the other contracts. Do not use call and send functions unless it is a must.
  • 55. www.securing.pldrdr_zz Thank you! Damian.Rusinek@securing.pl @drdr_zz Free 13-part security checklist Want a security audit of smart contract? Go for SCSVS!