Hacking Web Apps and Apis
Total Page:16
File Type:pdf, Size:1020Kb
CISO Platform Virtual Summit 2020 Hacking Web Apps & APIs Trend and Risk Kyle Lai CISSP, CDPSE, CSSLP, CISA, CIPP/US, CIPP/G CISO KLC Consulting July 18, 2020 All rights reserved. www.klcconsulting.net Kyle Lai Founder and CEO of KLC Consulting (CISSP, CSSLP, CISA, CIPP/US, CIPP/G, ISO 27001 LA) LinkedIn: https://www.linkedin.com/in/kylelai Twitter: @KyleOnCyber • 25+ years in IT | 20 years in Information Security (Pentest, • Former CISO & CPO of Pactera Third-party Risk, Compliance, Privacy, Engineering…) • Former CISO of Brandeis University – Heller School • Security Advisor for Fortune 500 firms • Former Penetration Tester for Fortune 500 firms • Experience in Software, DoD, Financial, Energy, Healthcare, • Author of SMAC MAC Address Changer Tool – Over 2.5 million High Tech, Consulting industries users worldwide • Provided consulting services for Microsoft, PwC, Boeing, HP, • Run 3 LinkedIn Groups (i.e. Cybersecurity Community) Fidelity Investment, Akamai, ExxonMobil, and DoD • Based in Texas, Massachusetts All rights reserved. 1 www.klcconsulting.net Why Talk About Web Application / API Security • According to the Akamai State of Internet Security report 2019 - 83% of web traffic is API traffic. • According to the Verizon Data Breach Investigation Report (DBIR) 43% of all breaches were attacks on web applications, more than double the results from last year. • ~90% of hacking related breaches are via Web Applications (Increased 20% from 2019) 70% DBIR 2020 (DBIR 2019) 90% All rights reserved. 2 www.klcconsulting.net Recent Data Breaches on Web Application / API Hack Airtel - API based vulnerability in the MyAirtel Starbucks - Security researcher found a directory application exposed details like IMEI number, Connection traversal flaw of an internally exposed API in the gift Type, Device Information, Personal Information such as card ordering web page potentially exposed the records First name, Last name, Contact Address, Gender, and of up to 100 million customers. Email, left 300 million users at risk USPS – A weakness in Web API allowed an attacker to Google - admitted that a bug in its Google Plus query the USPS website and scrape a database of over 60 API exposed private data of up to 500,000 Google Plus million corporate users, email addresses, account user accounts. Vulnerability led Google to shutdown numbers, addresses, campaign data, and phone numbers Google Plus service. Facebook – Attackers used a vulnerability in Facebook’s Panera Bread - Attackers exposed 37 million customer Developer API and Photo book API to expose tens of records via its API and ignored the vulnerability millions of users. All rights reserved. 3 www.klcconsulting.net Example of Modern Web Application Architecture • Focus on Web API and Microservices Source: https://docs.microsoft.com/en-us/dotnet/architecture/microservices/multi-container-microservice-net-applications/implement-api-gateways-with-ocelot All rights reserved. 4 www.klcconsulting.net OWASP Top 10 Web App Vulnerabilities and API Vulnerabilities OWASP Top 10 Web Application Security Risks (2017) OWASP Top 10 API Security Risks (2019) 1. Injection 1. Broken Object Level Authorization 2. Broken Authentication 2. Broken User Authentication 3. Sensitive Data Exposure 3. Excessive Data Exposure 4. XML External Entities (XXE) 4. Lack of Resources & Rate Limiting 5. Broken Access Control 5. Broken Function Level Authorization 6. Security Misconfiguration 6. Mass Assignment 7. Cross-Site Scripting (XSS) 7. Security Misconfiguration 8. Insecure Deserialization 8. Injection 9. Using Components with Known Vulnerabilities 9. Improper Assets Management 10. Insufficient Logging & Monitoring 10. Insufficient Logging & Monitoring All rights reserved. 5 www.klcconsulting.net Trending Vulnerabilities on Web App / API oAuth - Misconfiguration or Insecure Implementation Based on KLC’s analysis on: - Access token, URL redirect 1. Observation from Fortune 500 clients 2. Observation from SaaS clients Over Permission on Data Access - Misconfigured authentication (lack of auth), oAuth Scope issue, API access control 3. Public disclosed vulnerabilities from bug bounty firms Insecure Direct Object Reference (IDOR) 4. Common Vulnerabilities & Exposures - Lack of proper authentication and authorization (CVE) Missing API Security – - Rate Limiting, Cross Origin Resource Sharing (CORS) Note: Cross-Site Scripting (XSS) and SQL Injection (SQLi) still exists in most Secret in Code or Configuration Files (i.e. Github) applications but not really trending up Server Side Request Forgery (SSRF) Third-Party / Open Source Component Vulnerabilities All rights reserved. 6 www.klcconsulting.net oAuth Vulnerabilities • oAuth is complex, very widely used • Redirect_URI not validated (Trending up) • Access Token Protection (Seen more issues) • Many attack methods OAuth parameters registry containing the initial contents: Sr.No. Parameter Name & Usage Location Sr.No. Parameter Name & Usage Location 1 client_id 9 error_uri authorization request, token request authorization response, token response 2 client_secret 10 grant_type token request token request 3 response_type 11 access_token authorization_request authorization response, token response 4 redirect_uri authorization request, authorization 12 token_type authorization response, token response 5 scope authorization request or response, token 13 expires_in request or response authorization response, token response 6 state 14 username authorization request or response token request 7 code 15 password token request, authorization response token request 8 error_description 16 refresh_token authorization response, token response token request, token response All rights reserved. 7 www.klcconsulting.net oAuth Attacks and Mitigations 1. Insufficient Redirect URI Validation 2. Credential Leakage via Referer Headers 3. Credential Leakage via Browser History 4. Mix-Up Attacks 5. Authorization Code InJection 6. Access Token InJection 7. Cross Site Request Forgery 8. Access Token Leakage at the Resource Server 9. Open Redirection 10. 307 Redirect 11. TLS Terminating Reverse Proxies 12. Refresh Token Protection 13. Client Impersonating Resource Owner 14. ClickJacking Source: oAuth 2.0 Security Best Current Practices – Attacks and Mitigation by IETF All rights reserved. 8 www.klcconsulting.net Open Source Component Vulnerabilities - Challenges 99%: Proportion of 1,253 • OWASP Top 10 issue (2017) commercial codebases analyzed in 2019 from across 17 industries with • Open source components used by developers – A LOT open-source code (2020 Open Source Security and Risk Analysis • Lack of process, tools and dedicated people to examine / approve Report, Synopsys) new open source components (based on known vulnerabilities) 33%: Percentage of application • Many new open source components are puBlished every day security vulnerabilities stemming from embeddable open-source and • third-party components Many new vulneraBilities are discovered everyday on open (2019 Application Security Statistics source components Report, WhiteHat Security) • Lack of good tools to identify and prioritize open source 39% of firms surveyed plan on doing software composition analysis vulneraBilities to address when you have thousands of (SCA) only during the testing phase, vulneraBilities 37% during development, where remediation is much harder. (The • Security team doesn’t want to get in the way of developers and State of Application Security 2020, Forrester Research) hinder revenue generation; allows more unauthorized and vulneraBle open source components into the organization All rights reserved. 9 www.klcconsulting.net Insecure Direct Object Reference (IDOR) Vulnerability • Existed since OWASP Top 10 - 2007 • Web Applications are getting more complex with increasing number of APIs • Automated Static and Dynamic Vulnerability Scanning Tools cannot effectively find IDOR issues because it lacks the context of Web Apps and APIs • Lack of Manual Pentesting / Vulnerability Testing • Most likely, IDOR will still be a problem in the next few years Source: https://spanning.com/blog/insecure-direct-object-reference- web-based-application-security-part-6/ All rights reserved. 10 www.klcconsulting.net Trends in Misconfiguration 70% of Errors (including • DBIR: About 10% of data breaches caused by Misconfiguration Misconfiguration) Discovered by External Parties. • Misconfiguration has increased year by year for the last few years Consider Private Bug Bounty Program? • Due to increasing complexity of technology and tools 40% of all errors 17% Source: Verizon DBIR Report 2020 All rights reserved. 11 www.klcconsulting.net Misconfiguration - Technology Complexity • Cloud – more new features everyday, but lack of understanding to securely configuring and implementing them • More technology, tools and platforms used, but lack of guidance on secure configuration and implementation • Developers and engineers re not trained on the technologies, tools and platforms All rights reserved. 12 www.klcconsulting.net Why # of Web Application Vulnerabilities Is Growing? • Growing Complexity in Software infrastructure, technology and tools • Insufficient training on Modern Authentication (oAuth, OIDC) and secure handling of access tokens • Many insecure implementation of oAuth lead to access token leak and account take over • Insufficient training on new technologies and platforms • Cloud, Serverless, Key Vault, API Management, WAF, Database, Storage, Secure Configuration • Lack of training for developers on secure coding practices