SlideShare une entreprise Scribd logo
1  sur  34
Télécharger pour lire hors ligne
Agenda
● Modern AppSec challenges
● Real examples
● How to fix
Startups, Tier 1 Companies
Single Page Apps, Cloud, CI/CD,
Mostly APIs
Government, Military,
Financial
Multi Page Apps, On Prem, Waterfall,
Less APIs
Whoami
● Head of Research @ Traceable.ai
● 8 Years of experience in AppSec
● I’ve grown up with APIs
Authz in APIs - The Challenge
Object Level Function Level
Code (Almost every
controller)
Code, Configuration,
API-gateway
● Decentralized Mechanism
● Complex Users & Roles
Hierarchies
Riders Drivers Admins
Hugo
Sub
#1
Sub
#2
Bugo
Jon
Jack
Inon
A1 - BOLA (Broken Object-Level Authorization)
POST api/trips/rate_trip
{“trip_id”:718492, “rate”:5}
API DB
NotLyft
Trip.find_by_id(718492).update
UPDATE trips …
WHERE ID = 718492
BOLA - 2 types
Based on user_id
● Easy to protect
○ If (params[:user_id] == current_user.id)
Based on object_id
● Challenging
○ A trip with a co-rider
What is a good authorization mechanism?
Decision Engine
User #232 User #585 Admin #616
Receipts
Controller
Profile
Controller
Admin Panel
Controller
User #232 has
access to view
receipt #777?
User #585 has
access to update
profile #616?
Admin #616
Has access to
delete user
#888?
1
2
BOLA - Why So Common?
● More IDs are sent from the clients to the APIs
● REST standard encourages developers to send IDs in URLs
○ /users/717/details
● Even though there’s an authz mechanism, developers just don’t use it
BOLA - Why Not IDOR
● IDOR - Insecure Direct Object Reference
● C00L name, not accurate
● The problem is not about the IDs !
BOLA - Solutions that don’t solve the problem
● GUIDs instead of numbers
● Indirect Object Reference
● Relying on IDs from JWT tokens
● OAuth
BOLA - Solutions that solve the problem
● Good authorization mechanism
● Make sure that developers actually use it in every controller
BOLA - Uber - Full Account Takeover
Request Response
Found by Anand Prakash,
AppSecure
Real Attack #1: Food Delivery App
● Background:
○ Food delivery app
○ API seemed to be pretty secured
● Attack Steps:
○ Downloaded an old version of the app
○ Found a niche feature hidden in the GUI – update user’s phone number
○ Includes 2 steps
Step API endpoint BOLA
1. Send an SMS with a
token
Vulnerable
2. Verify Code POST
/api/v/api/v3/<user_phone_num>/verify_update_number
Not
Vulnerable
Attack steps
How
I felt
Step
#1 😈 Found that the token could be used for the login mechanism
as well:
#2 😞 “login_with_code” verifies also the device GUID
#3 🤔 Double verification?
Sounds like a feature that might have been added recently
#4 🤓 Scanned for old versions of endpoint (v0.0 - v5.0 in the URL)
#5 😈 Found that V2.7 was exposed and didn’t verify the device GUID
#6 | Full Account Takeover |
POST /api/v3.1/login_with_code
A5 - BFLA
(Broken Function Level Authorization)
DELETE /users/717
DELETE /users/717
Admin
API
APIRiders
API
Drivers
aPI
Why in APIs
● Easier to detect in APIs
Fetch User’s Profile
(not sensitive function)
Delete user
(admin function)
Traditional
App
GET
/app/users_view.aspx?user_id=1337
POST app/admin_panel/users_mgmt.aspx
action=delete&user_id=1337
API GET /api/users/1337 DELETE /api/users/1337
HARD topredict :(
VeryPredictable
Function Level Authorization
● Various ways to implement:
○ Code
○ Configuration
○ API Gateway
● Comlex Roles:
○ Admins / Super-admins / supervisors / riders / drivers
Real Attack #2: Social Network
● Background:
○ Large social network
○ Haven’t found interesting in the Web App
○ Endpoint that exposes the user resource
from the evaluation phase:
GET /V3/users/<USER_GUID>
POST /app/api/old_mobile/users
{“user”: <USER_GUID>}
● Attack Steps:
○ Expanded the attack surface
■ old android version from apkpure.com
○ Found an older implementation of “user” resource
Different EP structure.
Potentially trigger
different code
PUT
○ Tried to change the method from “POST” to “PUT”
○ Created a request to update my own user
PUT /app/api/old_mobile/users
{“user”:<MY_GUID>,
“email”:”inon@traceable.ai”,
“full_name”:”Hugo Bugo”}
○ Received 403 ==
They implemented “function level authorization”
Real Attack #2: Social Network
● Attack Steps #2:
○ Expanded the attack surface
■ Used VirusTotal to find sub domains
��
○ “beta-prod” exposes the same API endpoint from previous steps
/app/api/old_mobile/users
○ The API behaves differently (different headers & error handling)
■ Different behavior == different build / deployment / network flow
○ The “funcion-level authorization” isn’t active on “beta-prod”
■ API Is vulnerable to A5 (BFLA)
○ Used the API call from previous step to update any user’s email
PUT /app/api/old_mobile/users
{“user”:”ANY_USER_ID”,
“email”:”inon@traceable.ai”}
○ Used the “forgot password” feature to reset the password ==
| FULL ACCOUNT TAKEOVER |
A6 - Mass Assignment
“Create_user” flow in traditional apps
APP
Server
create_user
fname=inon&
lname=shkedy&
pass=123456
ORM
{first_name=Inon
last_name=shkedy
pass=123456}
A6 - Mass Assignment
APP
Server
POST /users/create
{“user”:{“lname”:”Inon”,”fname”:
”shkedy”,”pass”:”123456”}}
(ORM Black Magic) ORM
{JSON
AS IS}
A6 - Mass Assignment
POST /api/users/new
{“username”:”Inon”, ”pass”:”123456”}
Legit
POST /api/users/new
{“username”:”Inon”, ”pass”:”123456”, ”role”:”admin”}
M
alicious
A6 - Why in APIs
● Mass Assignment Ain’t New
● Easier to exploit in APIs
○ Always try with POST, PUT & PATCH
● Don’t guess object properties
○ Just find a GET method which returns them
● Use Mass Assignment to bypass other security controls
A6 - Example
Found by
James Kettle,
Port Swigger
Mass Assignment + CSRF -
Reset User’s Password
App Server
Legacy multi-page app
/app/home
Mobile API
/mobile/api
session_id cookie
based
Authorization
Header
Auth settings are shared ==
API supports cookies ==
Potential CSRF
★ Let’s exploit it to change user’s email!
★ “POST /api/update_email” endpoint requires password 😞
★ Anyhow, “PUT /mobile/api/users/me” is
vulnerable to Mass Assignment
We can update every
user’s property, including
email! 😈
Exploitation
★ Target a victim who uses the old app (cookies are stored in his browser)
★ Create a malicious HTML page to exploit the CSRF and call
★ Send it to the victim, change his email address and reset his password ☺
How to hack APIs?
Pentesters Methodology -
API Mindfulness
● Beginner’s mind (Shoshin) -
Always be curious about APIs
Understand the business logic by asking meaningful questions
● Wean yourself off GUI
Don’t let fear stop you from generating API calls from scratch
● Use the evaluation phases
High-Level Evaluation
Learn:
● REST based ride sharing app
● Has a carpooling feature
Ask:
● What is “VIN”??
Drill Down Evaluation
Learn:
● Trips & users - Numeric ID
● Drivers & payment - GUID
Ask:
● More than one version?
● Payment splitting?!
● Maybe soap?
Do:
● Cause an error:
/v2/trips/aaa555
● Find the payment splitting feature
Access Control Evaluation
Learn:
● Different user types
Ask:
● Should the last name be
exposed?
● Can I be a driver & a rider?
● Support for cookies authz?
Do:
● Identify the session label
Got Stuck?
Expanding the attack surface
● Find more API endpoints!
Wet Endpoints Dry Endpoints
Source Active traffic from active clients Full / Partial documentation
Pros Easier to work with Easier to find a large amount of
them
Cons You’re limited to the endpoints
your clients have access to
Hard to work with them
API
Find more endpoints
★ Use multiple clients (mobile/web/web for
mobile)
★ Use older versions of each client
○ APK Pure (Android)
○ Archive.com (Web Apps)
★ Use different hosts that run the same
API
○ Use VirusTotal and Censys to find
more hosts
★ Use different environments
(QA/Staging/beta)
★ Use Burp “Site View” feature
★ Scan client files for strings that look like
URLs
○ .js (JS-Scan tool) /.ipa / .apk files
★ Look for swagger / WADL files:
/swagger.json; /api-docs;
/application.wadl; etc..
★ Look for exposed API documentation for
developers
Wet Endpoints Dry Endpoints
Bypass Security Controls
★ Sometimes non-prod environments (QA, Staging, etc)
don’t implement basic security mechanisms
★ Different protocols == different implementations.
○ An app can expose REST, SOAP, ElasticSearch, GraphQL and websockets at the same time.
○ Don’t assume they implement the same security mechanisms.
★ Find different hosts that expose the same API;
They might be deployed with different configurations / versions
Find vulnerable endpoints
★ Always look for the most niche features
★ Interesting features that tend to be vulnerable:
○ Export mechanism (look for Export Injection)
○ User management, sub-users
○ Custom views of a dashboard
○ Object sharing among users (like sharing a post / receipt)

Contenu connexe

Tendances

OWASP API Security Top 10 - Austin DevSecOps Days
OWASP API Security Top 10 - Austin DevSecOps DaysOWASP API Security Top 10 - Austin DevSecOps Days
OWASP API Security Top 10 - Austin DevSecOps Days42Crunch
 
API Security In Cloud Native Era
API Security In Cloud Native EraAPI Security In Cloud Native Era
API Security In Cloud Native EraWSO2
 
WEBINAR: Positive Security for APIs: What it is and why you need it!
 WEBINAR: Positive Security for APIs: What it is and why you need it! WEBINAR: Positive Security for APIs: What it is and why you need it!
WEBINAR: Positive Security for APIs: What it is and why you need it!42Crunch
 
Top API Security Issues Found During POCs
Top API Security Issues Found During POCsTop API Security Issues Found During POCs
Top API Security Issues Found During POCs42Crunch
 
The Dev, Sec and Ops of API Security - API World
The Dev, Sec and Ops of API Security - API WorldThe Dev, Sec and Ops of API Security - API World
The Dev, Sec and Ops of API Security - API World42Crunch
 
API Security - OWASP top 10 for APIs + tips for pentesters
API Security - OWASP top 10 for APIs + tips for pentestersAPI Security - OWASP top 10 for APIs + tips for pentesters
API Security - OWASP top 10 for APIs + tips for pentestersInon Shkedy
 
API Security: the full story
API Security: the full storyAPI Security: the full story
API Security: the full story42Crunch
 
Managing Identities in the World of APIs
Managing Identities in the World of APIsManaging Identities in the World of APIs
Managing Identities in the World of APIsApigee | Google Cloud
 
Why you need API Security Automation
Why you need API Security AutomationWhy you need API Security Automation
Why you need API Security Automation42Crunch
 
API Security in a Microservices World
API Security in a Microservices WorldAPI Security in a Microservices World
API Security in a Microservices World42Crunch
 
API Security from the DevOps and CSO Perspectives (Webcast)
API Security from the DevOps and CSO Perspectives (Webcast)API Security from the DevOps and CSO Perspectives (Webcast)
API Security from the DevOps and CSO Perspectives (Webcast)Apigee | Google Cloud
 
REST API Security by Design with Azure Pipelines
REST API Security by Design with Azure PipelinesREST API Security by Design with Azure Pipelines
REST API Security by Design with Azure Pipelines42Crunch
 
Rest API Security - A quick understanding of Rest API Security
Rest API Security - A quick understanding of Rest API SecurityRest API Security - A quick understanding of Rest API Security
Rest API Security - A quick understanding of Rest API SecurityMohammed Fazuluddin
 
Advanced API Security Patterns
Advanced API Security PatternsAdvanced API Security Patterns
Advanced API Security Patterns42Crunch
 
42crunch-API-security-workshop
42crunch-API-security-workshop42crunch-API-security-workshop
42crunch-API-security-workshop42Crunch
 
Guidelines to protect your APIs from threats
Guidelines to protect your APIs from threatsGuidelines to protect your APIs from threats
Guidelines to protect your APIs from threatsIsabelle Mauny
 
OAuth - Don’t Throw the Baby Out with the Bathwater
OAuth - Don’t Throw the Baby Out with the Bathwater OAuth - Don’t Throw the Baby Out with the Bathwater
OAuth - Don’t Throw the Baby Out with the Bathwater Apigee | Google Cloud
 
Applying API Security at Scale
Applying API Security at ScaleApplying API Security at Scale
Applying API Security at ScaleNordic APIs
 

Tendances (20)

OWASP API Security Top 10 - Austin DevSecOps Days
OWASP API Security Top 10 - Austin DevSecOps DaysOWASP API Security Top 10 - Austin DevSecOps Days
OWASP API Security Top 10 - Austin DevSecOps Days
 
API Security In Cloud Native Era
API Security In Cloud Native EraAPI Security In Cloud Native Era
API Security In Cloud Native Era
 
WEBINAR: Positive Security for APIs: What it is and why you need it!
 WEBINAR: Positive Security for APIs: What it is and why you need it! WEBINAR: Positive Security for APIs: What it is and why you need it!
WEBINAR: Positive Security for APIs: What it is and why you need it!
 
Top API Security Issues Found During POCs
Top API Security Issues Found During POCsTop API Security Issues Found During POCs
Top API Security Issues Found During POCs
 
The Dev, Sec and Ops of API Security - API World
The Dev, Sec and Ops of API Security - API WorldThe Dev, Sec and Ops of API Security - API World
The Dev, Sec and Ops of API Security - API World
 
API Security - OWASP top 10 for APIs + tips for pentesters
API Security - OWASP top 10 for APIs + tips for pentestersAPI Security - OWASP top 10 for APIs + tips for pentesters
API Security - OWASP top 10 for APIs + tips for pentesters
 
API Security: the full story
API Security: the full storyAPI Security: the full story
API Security: the full story
 
Managing Identities in the World of APIs
Managing Identities in the World of APIsManaging Identities in the World of APIs
Managing Identities in the World of APIs
 
Why you need API Security Automation
Why you need API Security AutomationWhy you need API Security Automation
Why you need API Security Automation
 
API Security in a Microservices World
API Security in a Microservices WorldAPI Security in a Microservices World
API Security in a Microservices World
 
API Security from the DevOps and CSO Perspectives (Webcast)
API Security from the DevOps and CSO Perspectives (Webcast)API Security from the DevOps and CSO Perspectives (Webcast)
API Security from the DevOps and CSO Perspectives (Webcast)
 
REST API Security by Design with Azure Pipelines
REST API Security by Design with Azure PipelinesREST API Security by Design with Azure Pipelines
REST API Security by Design with Azure Pipelines
 
Rest API Security - A quick understanding of Rest API Security
Rest API Security - A quick understanding of Rest API SecurityRest API Security - A quick understanding of Rest API Security
Rest API Security - A quick understanding of Rest API Security
 
Advanced API Security Patterns
Advanced API Security PatternsAdvanced API Security Patterns
Advanced API Security Patterns
 
Api security
Api security Api security
Api security
 
42crunch-API-security-workshop
42crunch-API-security-workshop42crunch-API-security-workshop
42crunch-API-security-workshop
 
Guidelines to protect your APIs from threats
Guidelines to protect your APIs from threatsGuidelines to protect your APIs from threats
Guidelines to protect your APIs from threats
 
OAuth - Don’t Throw the Baby Out with the Bathwater
OAuth - Don’t Throw the Baby Out with the Bathwater OAuth - Don’t Throw the Baby Out with the Bathwater
OAuth - Don’t Throw the Baby Out with the Bathwater
 
Applying API Security at Scale
Applying API Security at ScaleApplying API Security at Scale
Applying API Security at Scale
 
Data-driven API Security
Data-driven API SecurityData-driven API Security
Data-driven API Security
 

Similaire à Checkmarx meetup API Security - API Security in depth - Inon Shkedy

How to build Simple yet powerful API.pptx
How to build Simple yet powerful API.pptxHow to build Simple yet powerful API.pptx
How to build Simple yet powerful API.pptxChanna Ly
 
Araport Workshop Tutorial 2: Authentication and the Agave Profiles Service
Araport Workshop Tutorial 2: Authentication and the Agave Profiles ServiceAraport Workshop Tutorial 2: Authentication and the Agave Profiles Service
Araport Workshop Tutorial 2: Authentication and the Agave Profiles Servicestevemock
 
Using API platform to build ticketing system (translations, time zones, ...) ...
Using API platform to build ticketing system (translations, time zones, ...) ...Using API platform to build ticketing system (translations, time zones, ...) ...
Using API platform to build ticketing system (translations, time zones, ...) ...Antonio Peric-Mazar
 
Exploring Google APIs 102: Cloud vs. non-GCP Google APIs
Exploring Google APIs 102: Cloud vs. non-GCP Google APIsExploring Google APIs 102: Cloud vs. non-GCP Google APIs
Exploring Google APIs 102: Cloud vs. non-GCP Google APIswesley chun
 
Using API Platform to build ticketing system #symfonycon
Using API Platform to build ticketing system #symfonyconUsing API Platform to build ticketing system #symfonycon
Using API Platform to build ticketing system #symfonyconAntonio Peric-Mazar
 
Building Mobile Friendly APIs in Rails
Building Mobile Friendly APIs in RailsBuilding Mobile Friendly APIs in Rails
Building Mobile Friendly APIs in RailsJim Jeffers
 
How LinkedIn changed its security model in order to offer an API
How LinkedIn changed its security model  in order to offer an APIHow LinkedIn changed its security model  in order to offer an API
How LinkedIn changed its security model in order to offer an APILinkedIn
 
API Testing and Hacking (1).pdf
API Testing and Hacking (1).pdfAPI Testing and Hacking (1).pdf
API Testing and Hacking (1).pdfVishwas N
 
API Testing and Hacking.pdf
API Testing and Hacking.pdfAPI Testing and Hacking.pdf
API Testing and Hacking.pdfVishwas N
 
API Testing and Hacking.pdf
API Testing and Hacking.pdfAPI Testing and Hacking.pdf
API Testing and Hacking.pdfVishwasN6
 
High Availability by Design
High Availability by DesignHigh Availability by Design
High Availability by DesignDavid Prinzing
 
apidays LIVE Australia - Contract-first API development with Spot by Francois...
apidays LIVE Australia - Contract-first API development with Spot by Francois...apidays LIVE Australia - Contract-first API development with Spot by Francois...
apidays LIVE Australia - Contract-first API development with Spot by Francois...apidays
 
Azure API Management - why should I care?
Azure API Management - why should I care?Azure API Management - why should I care?
Azure API Management - why should I care?Jouni Heikniemi
 
2022 APIsecure_Securing APIs with Open Standards
2022 APIsecure_Securing APIs with Open Standards2022 APIsecure_Securing APIs with Open Standards
2022 APIsecure_Securing APIs with Open StandardsAPIsecure_ Official
 
Live Identity Services Drilldown - PDC 2008
Live Identity Services Drilldown - PDC 2008Live Identity Services Drilldown - PDC 2008
Live Identity Services Drilldown - PDC 2008Jorgen Thelin
 
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram VaswaniCreating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswanivvaswani
 
Build an AI/ML-driven image archive processing workflow: Image archive, analy...
Build an AI/ML-driven image archive processing workflow: Image archive, analy...Build an AI/ML-driven image archive processing workflow: Image archive, analy...
Build an AI/ML-driven image archive processing workflow: Image archive, analy...wesley chun
 
Good practices for debugging Selenium and Appium tests
Good practices for debugging Selenium and Appium testsGood practices for debugging Selenium and Appium tests
Good practices for debugging Selenium and Appium testsAbhijeet Vaikar
 
Pwning mobile apps without root or jailbreak
Pwning mobile apps without root or jailbreakPwning mobile apps without root or jailbreak
Pwning mobile apps without root or jailbreakAbraham Aranguren
 

Similaire à Checkmarx meetup API Security - API Security in depth - Inon Shkedy (20)

How to build Simple yet powerful API.pptx
How to build Simple yet powerful API.pptxHow to build Simple yet powerful API.pptx
How to build Simple yet powerful API.pptx
 
Araport Workshop Tutorial 2: Authentication and the Agave Profiles Service
Araport Workshop Tutorial 2: Authentication and the Agave Profiles ServiceAraport Workshop Tutorial 2: Authentication and the Agave Profiles Service
Araport Workshop Tutorial 2: Authentication and the Agave Profiles Service
 
Using API platform to build ticketing system (translations, time zones, ...) ...
Using API platform to build ticketing system (translations, time zones, ...) ...Using API platform to build ticketing system (translations, time zones, ...) ...
Using API platform to build ticketing system (translations, time zones, ...) ...
 
Exploring Google APIs 102: Cloud vs. non-GCP Google APIs
Exploring Google APIs 102: Cloud vs. non-GCP Google APIsExploring Google APIs 102: Cloud vs. non-GCP Google APIs
Exploring Google APIs 102: Cloud vs. non-GCP Google APIs
 
Using API Platform to build ticketing system #symfonycon
Using API Platform to build ticketing system #symfonyconUsing API Platform to build ticketing system #symfonycon
Using API Platform to build ticketing system #symfonycon
 
Building Mobile Friendly APIs in Rails
Building Mobile Friendly APIs in RailsBuilding Mobile Friendly APIs in Rails
Building Mobile Friendly APIs in Rails
 
How LinkedIn changed its security model in order to offer an API
How LinkedIn changed its security model  in order to offer an APIHow LinkedIn changed its security model  in order to offer an API
How LinkedIn changed its security model in order to offer an API
 
API Testing and Hacking (1).pdf
API Testing and Hacking (1).pdfAPI Testing and Hacking (1).pdf
API Testing and Hacking (1).pdf
 
API Testing and Hacking.pdf
API Testing and Hacking.pdfAPI Testing and Hacking.pdf
API Testing and Hacking.pdf
 
API Testing and Hacking.pdf
API Testing and Hacking.pdfAPI Testing and Hacking.pdf
API Testing and Hacking.pdf
 
High Availability by Design
High Availability by DesignHigh Availability by Design
High Availability by Design
 
apidays LIVE Australia - Contract-first API development with Spot by Francois...
apidays LIVE Australia - Contract-first API development with Spot by Francois...apidays LIVE Australia - Contract-first API development with Spot by Francois...
apidays LIVE Australia - Contract-first API development with Spot by Francois...
 
AOR-outline-2
AOR-outline-2AOR-outline-2
AOR-outline-2
 
Azure API Management - why should I care?
Azure API Management - why should I care?Azure API Management - why should I care?
Azure API Management - why should I care?
 
2022 APIsecure_Securing APIs with Open Standards
2022 APIsecure_Securing APIs with Open Standards2022 APIsecure_Securing APIs with Open Standards
2022 APIsecure_Securing APIs with Open Standards
 
Live Identity Services Drilldown - PDC 2008
Live Identity Services Drilldown - PDC 2008Live Identity Services Drilldown - PDC 2008
Live Identity Services Drilldown - PDC 2008
 
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram VaswaniCreating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
 
Build an AI/ML-driven image archive processing workflow: Image archive, analy...
Build an AI/ML-driven image archive processing workflow: Image archive, analy...Build an AI/ML-driven image archive processing workflow: Image archive, analy...
Build an AI/ML-driven image archive processing workflow: Image archive, analy...
 
Good practices for debugging Selenium and Appium tests
Good practices for debugging Selenium and Appium testsGood practices for debugging Selenium and Appium tests
Good practices for debugging Selenium and Appium tests
 
Pwning mobile apps without root or jailbreak
Pwning mobile apps without root or jailbreakPwning mobile apps without root or jailbreak
Pwning mobile apps without root or jailbreak
 

Dernier

Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Intelisync
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 

Dernier (20)

Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 

Checkmarx meetup API Security - API Security in depth - Inon Shkedy

  • 1. Agenda ● Modern AppSec challenges ● Real examples ● How to fix
  • 2. Startups, Tier 1 Companies Single Page Apps, Cloud, CI/CD, Mostly APIs Government, Military, Financial Multi Page Apps, On Prem, Waterfall, Less APIs Whoami ● Head of Research @ Traceable.ai ● 8 Years of experience in AppSec ● I’ve grown up with APIs
  • 3. Authz in APIs - The Challenge Object Level Function Level Code (Almost every controller) Code, Configuration, API-gateway ● Decentralized Mechanism ● Complex Users & Roles Hierarchies Riders Drivers Admins Hugo Sub #1 Sub #2 Bugo Jon Jack Inon
  • 4. A1 - BOLA (Broken Object-Level Authorization) POST api/trips/rate_trip {“trip_id”:718492, “rate”:5} API DB NotLyft Trip.find_by_id(718492).update UPDATE trips … WHERE ID = 718492
  • 5. BOLA - 2 types Based on user_id ● Easy to protect ○ If (params[:user_id] == current_user.id) Based on object_id ● Challenging ○ A trip with a co-rider
  • 6. What is a good authorization mechanism? Decision Engine User #232 User #585 Admin #616 Receipts Controller Profile Controller Admin Panel Controller User #232 has access to view receipt #777? User #585 has access to update profile #616? Admin #616 Has access to delete user #888? 1 2
  • 7. BOLA - Why So Common? ● More IDs are sent from the clients to the APIs ● REST standard encourages developers to send IDs in URLs ○ /users/717/details ● Even though there’s an authz mechanism, developers just don’t use it
  • 8. BOLA - Why Not IDOR ● IDOR - Insecure Direct Object Reference ● C00L name, not accurate ● The problem is not about the IDs !
  • 9. BOLA - Solutions that don’t solve the problem ● GUIDs instead of numbers ● Indirect Object Reference ● Relying on IDs from JWT tokens ● OAuth BOLA - Solutions that solve the problem ● Good authorization mechanism ● Make sure that developers actually use it in every controller
  • 10. BOLA - Uber - Full Account Takeover Request Response Found by Anand Prakash, AppSecure
  • 11. Real Attack #1: Food Delivery App ● Background: ○ Food delivery app ○ API seemed to be pretty secured ● Attack Steps: ○ Downloaded an old version of the app ○ Found a niche feature hidden in the GUI – update user’s phone number ○ Includes 2 steps Step API endpoint BOLA 1. Send an SMS with a token Vulnerable 2. Verify Code POST /api/v/api/v3/<user_phone_num>/verify_update_number Not Vulnerable
  • 12. Attack steps How I felt Step #1 😈 Found that the token could be used for the login mechanism as well: #2 😞 “login_with_code” verifies also the device GUID #3 🤔 Double verification? Sounds like a feature that might have been added recently #4 🤓 Scanned for old versions of endpoint (v0.0 - v5.0 in the URL) #5 😈 Found that V2.7 was exposed and didn’t verify the device GUID #6 | Full Account Takeover | POST /api/v3.1/login_with_code
  • 13. A5 - BFLA (Broken Function Level Authorization) DELETE /users/717 DELETE /users/717 Admin API APIRiders API Drivers aPI
  • 14. Why in APIs ● Easier to detect in APIs Fetch User’s Profile (not sensitive function) Delete user (admin function) Traditional App GET /app/users_view.aspx?user_id=1337 POST app/admin_panel/users_mgmt.aspx action=delete&user_id=1337 API GET /api/users/1337 DELETE /api/users/1337 HARD topredict :( VeryPredictable
  • 15. Function Level Authorization ● Various ways to implement: ○ Code ○ Configuration ○ API Gateway ● Comlex Roles: ○ Admins / Super-admins / supervisors / riders / drivers
  • 16. Real Attack #2: Social Network ● Background: ○ Large social network ○ Haven’t found interesting in the Web App ○ Endpoint that exposes the user resource from the evaluation phase: GET /V3/users/<USER_GUID> POST /app/api/old_mobile/users {“user”: <USER_GUID>} ● Attack Steps: ○ Expanded the attack surface ■ old android version from apkpure.com ○ Found an older implementation of “user” resource Different EP structure. Potentially trigger different code PUT ○ Tried to change the method from “POST” to “PUT” ○ Created a request to update my own user PUT /app/api/old_mobile/users {“user”:<MY_GUID>, “email”:”inon@traceable.ai”, “full_name”:”Hugo Bugo”} ○ Received 403 == They implemented “function level authorization”
  • 17. Real Attack #2: Social Network ● Attack Steps #2: ○ Expanded the attack surface ■ Used VirusTotal to find sub domains �� ○ “beta-prod” exposes the same API endpoint from previous steps /app/api/old_mobile/users ○ The API behaves differently (different headers & error handling) ■ Different behavior == different build / deployment / network flow ○ The “funcion-level authorization” isn’t active on “beta-prod” ■ API Is vulnerable to A5 (BFLA) ○ Used the API call from previous step to update any user’s email PUT /app/api/old_mobile/users {“user”:”ANY_USER_ID”, “email”:”inon@traceable.ai”} ○ Used the “forgot password” feature to reset the password == | FULL ACCOUNT TAKEOVER |
  • 18. A6 - Mass Assignment “Create_user” flow in traditional apps APP Server create_user fname=inon& lname=shkedy& pass=123456 ORM {first_name=Inon last_name=shkedy pass=123456}
  • 19. A6 - Mass Assignment APP Server POST /users/create {“user”:{“lname”:”Inon”,”fname”: ”shkedy”,”pass”:”123456”}} (ORM Black Magic) ORM {JSON AS IS}
  • 20. A6 - Mass Assignment POST /api/users/new {“username”:”Inon”, ”pass”:”123456”} Legit POST /api/users/new {“username”:”Inon”, ”pass”:”123456”, ”role”:”admin”} M alicious
  • 21. A6 - Why in APIs ● Mass Assignment Ain’t New ● Easier to exploit in APIs ○ Always try with POST, PUT & PATCH ● Don’t guess object properties ○ Just find a GET method which returns them ● Use Mass Assignment to bypass other security controls
  • 22. A6 - Example Found by James Kettle, Port Swigger
  • 23. Mass Assignment + CSRF - Reset User’s Password App Server Legacy multi-page app /app/home Mobile API /mobile/api session_id cookie based Authorization Header Auth settings are shared == API supports cookies == Potential CSRF ★ Let’s exploit it to change user’s email! ★ “POST /api/update_email” endpoint requires password 😞 ★ Anyhow, “PUT /mobile/api/users/me” is vulnerable to Mass Assignment We can update every user’s property, including email! 😈
  • 24. Exploitation ★ Target a victim who uses the old app (cookies are stored in his browser) ★ Create a malicious HTML page to exploit the CSRF and call ★ Send it to the victim, change his email address and reset his password ☺
  • 25. How to hack APIs?
  • 26. Pentesters Methodology - API Mindfulness ● Beginner’s mind (Shoshin) - Always be curious about APIs Understand the business logic by asking meaningful questions ● Wean yourself off GUI Don’t let fear stop you from generating API calls from scratch ● Use the evaluation phases
  • 27. High-Level Evaluation Learn: ● REST based ride sharing app ● Has a carpooling feature Ask: ● What is “VIN”??
  • 28. Drill Down Evaluation Learn: ● Trips & users - Numeric ID ● Drivers & payment - GUID Ask: ● More than one version? ● Payment splitting?! ● Maybe soap? Do: ● Cause an error: /v2/trips/aaa555 ● Find the payment splitting feature
  • 29. Access Control Evaluation Learn: ● Different user types Ask: ● Should the last name be exposed? ● Can I be a driver & a rider? ● Support for cookies authz? Do: ● Identify the session label
  • 31. Expanding the attack surface ● Find more API endpoints! Wet Endpoints Dry Endpoints Source Active traffic from active clients Full / Partial documentation Pros Easier to work with Easier to find a large amount of them Cons You’re limited to the endpoints your clients have access to Hard to work with them API
  • 32. Find more endpoints ★ Use multiple clients (mobile/web/web for mobile) ★ Use older versions of each client ○ APK Pure (Android) ○ Archive.com (Web Apps) ★ Use different hosts that run the same API ○ Use VirusTotal and Censys to find more hosts ★ Use different environments (QA/Staging/beta) ★ Use Burp “Site View” feature ★ Scan client files for strings that look like URLs ○ .js (JS-Scan tool) /.ipa / .apk files ★ Look for swagger / WADL files: /swagger.json; /api-docs; /application.wadl; etc.. ★ Look for exposed API documentation for developers Wet Endpoints Dry Endpoints
  • 33. Bypass Security Controls ★ Sometimes non-prod environments (QA, Staging, etc) don’t implement basic security mechanisms ★ Different protocols == different implementations. ○ An app can expose REST, SOAP, ElasticSearch, GraphQL and websockets at the same time. ○ Don’t assume they implement the same security mechanisms. ★ Find different hosts that expose the same API; They might be deployed with different configurations / versions
  • 34. Find vulnerable endpoints ★ Always look for the most niche features ★ Interesting features that tend to be vulnerable: ○ Export mechanism (look for Export Injection) ○ User management, sub-users ○ Custom views of a dashboard ○ Object sharing among users (like sharing a post / receipt)