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

More Related Content

What's hot (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
42Crunch
 
API Security In Cloud Native Era
API Security In Cloud Native EraAPI Security In Cloud Native Era
API Security In Cloud Native Era
WSO2
 
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 POCs
42Crunch
 
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
42Crunch
 
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
Inon Shkedy
 
API Security: the full story
API Security: the full storyAPI Security: the full story
API Security: the full story
42Crunch
 
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
Apigee | Google Cloud
 
Why you need API Security Automation
Why you need API Security AutomationWhy you need API Security Automation
Why you need API Security Automation
42Crunch
 
API Security in a Microservices World
API Security in a Microservices WorldAPI Security in a Microservices World
API Security in a Microservices World
42Crunch
 
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 Pipelines
42Crunch
 
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
Mohammed Fazuluddin
 
Advanced API Security Patterns
Advanced API Security PatternsAdvanced API Security Patterns
Advanced API Security Patterns
42Crunch
 
Api security
Api security Api security
Api security
teodorcotruta
 
42crunch-API-security-workshop
42crunch-API-security-workshop42crunch-API-security-workshop
42crunch-API-security-workshop
42Crunch
 
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
Isabelle 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 Scale
Nordic APIs
 
Data-driven API Security
Data-driven API SecurityData-driven API Security
Data-driven API Security
Apigee | Google Cloud
 
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
42Crunch
 
API Security In Cloud Native Era
API Security In Cloud Native EraAPI Security In Cloud Native Era
API Security In Cloud Native Era
WSO2
 
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 POCs
42Crunch
 
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
42Crunch
 
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
Inon Shkedy
 
API Security: the full story
API Security: the full storyAPI Security: the full story
API Security: the full story
42Crunch
 
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
Apigee | Google Cloud
 
Why you need API Security Automation
Why you need API Security AutomationWhy you need API Security Automation
Why you need API Security Automation
42Crunch
 
API Security in a Microservices World
API Security in a Microservices WorldAPI Security in a Microservices World
API Security in a Microservices World
42Crunch
 
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 Pipelines
42Crunch
 
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
Mohammed Fazuluddin
 
Advanced API Security Patterns
Advanced API Security PatternsAdvanced API Security Patterns
Advanced API Security Patterns
42Crunch
 
42crunch-API-security-workshop
42crunch-API-security-workshop42crunch-API-security-workshop
42crunch-API-security-workshop
42Crunch
 
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
Isabelle 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 Scale
Nordic APIs
 

Similar to Checkmarx meetup API Security - API Security in depth - Inon Shkedy (20)

Enhancing your Security APIs
Enhancing your Security APIsEnhancing your Security APIs
Enhancing your Security APIs
Apigee | Google Cloud
 
Protecting Your APIs Against Attack & Hijack
Protecting Your APIs Against Attack & Hijack Protecting Your APIs Against Attack & Hijack
Protecting Your APIs Against Attack & Hijack
CA API Management
 
API SECURITY
API SECURITYAPI SECURITY
API SECURITY
Tubagus Rizky Dharmawan
 
APIdays London 2019 - API Security Tips for Developers with Isabelle Mauny, 4...
APIdays London 2019 - API Security Tips for Developers with Isabelle Mauny, 4...APIdays London 2019 - API Security Tips for Developers with Isabelle Mauny, 4...
APIdays London 2019 - API Security Tips for Developers with Isabelle Mauny, 4...
apidays
 
APIDays Paris Security Workshop
APIDays Paris Security WorkshopAPIDays Paris Security Workshop
APIDays Paris Security Workshop
42Crunch
 
apidays LIVE Paris - Protecting financial grade API: adopting the right secur...
apidays LIVE Paris - Protecting financial grade API: adopting the right secur...apidays LIVE Paris - Protecting financial grade API: adopting the right secur...
apidays LIVE Paris - Protecting financial grade API: adopting the right secur...
apidays
 
APIdays Paris 2019 - API Security Tips for Developers by Isabelle Mauny, 42Cr...
APIdays Paris 2019 - API Security Tips for Developers by Isabelle Mauny, 42Cr...APIdays Paris 2019 - API Security Tips for Developers by Isabelle Mauny, 42Cr...
APIdays Paris 2019 - API Security Tips for Developers by Isabelle Mauny, 42Cr...
apidays
 
Best Practices You Must Apply to Secure Your APIs - Scott Morrison, SVP & Dis...
Best Practices You Must Apply to Secure Your APIs - Scott Morrison, SVP & Dis...Best Practices You Must Apply to Secure Your APIs - Scott Morrison, SVP & Dis...
Best Practices You Must Apply to Secure Your APIs - Scott Morrison, SVP & Dis...
CA API Management
 
Pentesting Rest API's by :- Gaurang Bhatnagar
Pentesting Rest API's by :- Gaurang BhatnagarPentesting Rest API's by :- Gaurang Bhatnagar
Pentesting Rest API's by :- Gaurang Bhatnagar
OWASP Delhi
 
apidays LIVE LONDON - Protecting financial-grade APIs - Getting the right API...
apidays LIVE LONDON - Protecting financial-grade APIs - Getting the right API...apidays LIVE LONDON - Protecting financial-grade APIs - Getting the right API...
apidays LIVE LONDON - Protecting financial-grade APIs - Getting the right API...
apidays
 
Securing RESTful API
Securing RESTful APISecuring RESTful API
Securing RESTful API
Muhammad Zbeedat
 
APIs: The New Security Layer
APIs: The New Security LayerAPIs: The New Security Layer
APIs: The New Security Layer
Apigee | Google Cloud
 
SecDevOps for API Security
SecDevOps for API SecuritySecDevOps for API Security
SecDevOps for API Security
42Crunch
 
Adapt or Die Sydney - API Security
Adapt or Die Sydney - API SecurityAdapt or Die Sydney - API Security
Adapt or Die Sydney - API Security
Apigee | Google Cloud
 
Black and Blue APIs: Attacker's and Defender's View of API Vulnerabilities
Black and Blue APIs: Attacker's and Defender's View of API VulnerabilitiesBlack and Blue APIs: Attacker's and Defender's View of API Vulnerabilities
Black and Blue APIs: Attacker's and Defender's View of API Vulnerabilities
Matt Tesauro
 
Unit 3_detailed_automotiving_mobiles.pptx
Unit 3_detailed_automotiving_mobiles.pptxUnit 3_detailed_automotiving_mobiles.pptx
Unit 3_detailed_automotiving_mobiles.pptx
VijaySasanM21IT
 
Api security-testing
Api security-testingApi security-testing
Api security-testing
n|u - The Open Security Community
 
Takeaways from API Security Breaches Webinar
Takeaways from API Security Breaches WebinarTakeaways from API Security Breaches Webinar
Takeaways from API Security Breaches Webinar
CA API Management
 
API Security Best Practices and Guidelines
API Security Best Practices and GuidelinesAPI Security Best Practices and Guidelines
API Security Best Practices and Guidelines
WSO2
 
2022 APIsecure_Go Hack Yourself: API Hacking for Beginners
2022 APIsecure_Go Hack Yourself: API Hacking for Beginners2022 APIsecure_Go Hack Yourself: API Hacking for Beginners
2022 APIsecure_Go Hack Yourself: API Hacking for Beginners
APIsecure_ Official
 
Protecting Your APIs Against Attack & Hijack
Protecting Your APIs Against Attack & Hijack Protecting Your APIs Against Attack & Hijack
Protecting Your APIs Against Attack & Hijack
CA API Management
 
APIdays London 2019 - API Security Tips for Developers with Isabelle Mauny, 4...
APIdays London 2019 - API Security Tips for Developers with Isabelle Mauny, 4...APIdays London 2019 - API Security Tips for Developers with Isabelle Mauny, 4...
APIdays London 2019 - API Security Tips for Developers with Isabelle Mauny, 4...
apidays
 
APIDays Paris Security Workshop
APIDays Paris Security WorkshopAPIDays Paris Security Workshop
APIDays Paris Security Workshop
42Crunch
 
apidays LIVE Paris - Protecting financial grade API: adopting the right secur...
apidays LIVE Paris - Protecting financial grade API: adopting the right secur...apidays LIVE Paris - Protecting financial grade API: adopting the right secur...
apidays LIVE Paris - Protecting financial grade API: adopting the right secur...
apidays
 
APIdays Paris 2019 - API Security Tips for Developers by Isabelle Mauny, 42Cr...
APIdays Paris 2019 - API Security Tips for Developers by Isabelle Mauny, 42Cr...APIdays Paris 2019 - API Security Tips for Developers by Isabelle Mauny, 42Cr...
APIdays Paris 2019 - API Security Tips for Developers by Isabelle Mauny, 42Cr...
apidays
 
Best Practices You Must Apply to Secure Your APIs - Scott Morrison, SVP & Dis...
Best Practices You Must Apply to Secure Your APIs - Scott Morrison, SVP & Dis...Best Practices You Must Apply to Secure Your APIs - Scott Morrison, SVP & Dis...
Best Practices You Must Apply to Secure Your APIs - Scott Morrison, SVP & Dis...
CA API Management
 
Pentesting Rest API's by :- Gaurang Bhatnagar
Pentesting Rest API's by :- Gaurang BhatnagarPentesting Rest API's by :- Gaurang Bhatnagar
Pentesting Rest API's by :- Gaurang Bhatnagar
OWASP Delhi
 
apidays LIVE LONDON - Protecting financial-grade APIs - Getting the right API...
apidays LIVE LONDON - Protecting financial-grade APIs - Getting the right API...apidays LIVE LONDON - Protecting financial-grade APIs - Getting the right API...
apidays LIVE LONDON - Protecting financial-grade APIs - Getting the right API...
apidays
 
SecDevOps for API Security
SecDevOps for API SecuritySecDevOps for API Security
SecDevOps for API Security
42Crunch
 
Black and Blue APIs: Attacker's and Defender's View of API Vulnerabilities
Black and Blue APIs: Attacker's and Defender's View of API VulnerabilitiesBlack and Blue APIs: Attacker's and Defender's View of API Vulnerabilities
Black and Blue APIs: Attacker's and Defender's View of API Vulnerabilities
Matt Tesauro
 
Unit 3_detailed_automotiving_mobiles.pptx
Unit 3_detailed_automotiving_mobiles.pptxUnit 3_detailed_automotiving_mobiles.pptx
Unit 3_detailed_automotiving_mobiles.pptx
VijaySasanM21IT
 
Takeaways from API Security Breaches Webinar
Takeaways from API Security Breaches WebinarTakeaways from API Security Breaches Webinar
Takeaways from API Security Breaches Webinar
CA API Management
 
API Security Best Practices and Guidelines
API Security Best Practices and GuidelinesAPI Security Best Practices and Guidelines
API Security Best Practices and Guidelines
WSO2
 
2022 APIsecure_Go Hack Yourself: API Hacking for Beginners
2022 APIsecure_Go Hack Yourself: API Hacking for Beginners2022 APIsecure_Go Hack Yourself: API Hacking for Beginners
2022 APIsecure_Go Hack Yourself: API Hacking for Beginners
APIsecure_ Official
 
Ad

Recently uploaded (20)

Revolutionize Your Insurance Workflow with Claims Management Software
Revolutionize Your Insurance Workflow with Claims Management SoftwareRevolutionize Your Insurance Workflow with Claims Management Software
Revolutionize Your Insurance Workflow with Claims Management Software
Insurance Tech Services
 
Build enterprise-ready applications using skills you already have!
Build enterprise-ready applications using skills you already have!Build enterprise-ready applications using skills you already have!
Build enterprise-ready applications using skills you already have!
PhilMeredith3
 
Scaling FME Flow on Demand with Kubernetes: A Case Study At Cadac Group SaaS ...
Scaling FME Flow on Demand with Kubernetes: A Case Study At Cadac Group SaaS ...Scaling FME Flow on Demand with Kubernetes: A Case Study At Cadac Group SaaS ...
Scaling FME Flow on Demand with Kubernetes: A Case Study At Cadac Group SaaS ...
Safe Software
 
Rebuilding Cadabra Studio: AI as Our Core Foundation
Rebuilding Cadabra Studio: AI as Our Core FoundationRebuilding Cadabra Studio: AI as Our Core Foundation
Rebuilding Cadabra Studio: AI as Our Core Foundation
Cadabra Studio
 
Generative Artificial Intelligence and its Applications
Generative Artificial Intelligence and its ApplicationsGenerative Artificial Intelligence and its Applications
Generative Artificial Intelligence and its Applications
SandeepKS52
 
Software Engineering Process, Notation & Tools Introduction - Part 3
Software Engineering Process, Notation & Tools Introduction - Part 3Software Engineering Process, Notation & Tools Introduction - Part 3
Software Engineering Process, Notation & Tools Introduction - Part 3
Gaurav Sharma
 
How Insurance Policy Administration Streamlines Policy Lifecycle for Agile Op...
How Insurance Policy Administration Streamlines Policy Lifecycle for Agile Op...How Insurance Policy Administration Streamlines Policy Lifecycle for Agile Op...
How Insurance Policy Administration Streamlines Policy Lifecycle for Agile Op...
Insurance Tech Services
 
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptxIMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
usmanch7829
 
How AI Can Improve Media Quality Testing Across Platforms (1).pptx
How AI Can Improve Media Quality Testing Across Platforms (1).pptxHow AI Can Improve Media Quality Testing Across Platforms (1).pptx
How AI Can Improve Media Quality Testing Across Platforms (1).pptx
kalichargn70th171
 
COBOL Programming with VSCode - IBM Certificate
COBOL Programming with VSCode - IBM CertificateCOBOL Programming with VSCode - IBM Certificate
COBOL Programming with VSCode - IBM Certificate
VICTOR MAESTRE RAMIREZ
 
Marketo & Dynamics can be Most Excellent to Each Other – The Sequel
Marketo & Dynamics can be Most Excellent to Each Other – The SequelMarketo & Dynamics can be Most Excellent to Each Other – The Sequel
Marketo & Dynamics can be Most Excellent to Each Other – The Sequel
BradBedford3
 
Topic 26 Security Testing Considerations.pptx
Topic 26 Security Testing Considerations.pptxTopic 26 Security Testing Considerations.pptx
Topic 26 Security Testing Considerations.pptx
marutnand8
 
How to purchase, license and subscribe to Microsoft Azure_PDF.pdf
How to purchase, license and subscribe to Microsoft Azure_PDF.pdfHow to purchase, license and subscribe to Microsoft Azure_PDF.pdf
How to purchase, license and subscribe to Microsoft Azure_PDF.pdf
victordsane
 
Integration Ignited Redefining Event-Driven Architecture at Wix - EventCentric
Integration Ignited Redefining Event-Driven Architecture at Wix - EventCentricIntegration Ignited Redefining Event-Driven Architecture at Wix - EventCentric
Integration Ignited Redefining Event-Driven Architecture at Wix - EventCentric
Natan Silnitsky
 
Providing Better Biodiversity Through Better Data
Providing Better Biodiversity Through Better DataProviding Better Biodiversity Through Better Data
Providing Better Biodiversity Through Better Data
Safe Software
 
Design by Contract - Building Robust Software with Contract-First Development
Design by Contract - Building Robust Software with Contract-First DevelopmentDesign by Contract - Building Robust Software with Contract-First Development
Design by Contract - Building Robust Software with Contract-First Development
Par-Tec S.p.A.
 
Best Inbound Call Tracking Software for Small Businesses
Best Inbound Call Tracking Software for Small BusinessesBest Inbound Call Tracking Software for Small Businesses
Best Inbound Call Tracking Software for Small Businesses
TheTelephony
 
Top 11 Fleet Management Software Providers in 2025 (2).pdf
Top 11 Fleet Management Software Providers in 2025 (2).pdfTop 11 Fleet Management Software Providers in 2025 (2).pdf
Top 11 Fleet Management Software Providers in 2025 (2).pdf
Trackobit
 
Automating Map Production With FME and Python
Automating Map Production With FME and PythonAutomating Map Production With FME and Python
Automating Map Production With FME and Python
Safe Software
 
14 Years of Developing nCine - An Open Source 2D Game Framework
14 Years of Developing nCine - An Open Source 2D Game Framework14 Years of Developing nCine - An Open Source 2D Game Framework
14 Years of Developing nCine - An Open Source 2D Game Framework
Angelo Theodorou
 
Revolutionize Your Insurance Workflow with Claims Management Software
Revolutionize Your Insurance Workflow with Claims Management SoftwareRevolutionize Your Insurance Workflow with Claims Management Software
Revolutionize Your Insurance Workflow with Claims Management Software
Insurance Tech Services
 
Build enterprise-ready applications using skills you already have!
Build enterprise-ready applications using skills you already have!Build enterprise-ready applications using skills you already have!
Build enterprise-ready applications using skills you already have!
PhilMeredith3
 
Scaling FME Flow on Demand with Kubernetes: A Case Study At Cadac Group SaaS ...
Scaling FME Flow on Demand with Kubernetes: A Case Study At Cadac Group SaaS ...Scaling FME Flow on Demand with Kubernetes: A Case Study At Cadac Group SaaS ...
Scaling FME Flow on Demand with Kubernetes: A Case Study At Cadac Group SaaS ...
Safe Software
 
Rebuilding Cadabra Studio: AI as Our Core Foundation
Rebuilding Cadabra Studio: AI as Our Core FoundationRebuilding Cadabra Studio: AI as Our Core Foundation
Rebuilding Cadabra Studio: AI as Our Core Foundation
Cadabra Studio
 
Generative Artificial Intelligence and its Applications
Generative Artificial Intelligence and its ApplicationsGenerative Artificial Intelligence and its Applications
Generative Artificial Intelligence and its Applications
SandeepKS52
 
Software Engineering Process, Notation & Tools Introduction - Part 3
Software Engineering Process, Notation & Tools Introduction - Part 3Software Engineering Process, Notation & Tools Introduction - Part 3
Software Engineering Process, Notation & Tools Introduction - Part 3
Gaurav Sharma
 
How Insurance Policy Administration Streamlines Policy Lifecycle for Agile Op...
How Insurance Policy Administration Streamlines Policy Lifecycle for Agile Op...How Insurance Policy Administration Streamlines Policy Lifecycle for Agile Op...
How Insurance Policy Administration Streamlines Policy Lifecycle for Agile Op...
Insurance Tech Services
 
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptxIMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
usmanch7829
 
How AI Can Improve Media Quality Testing Across Platforms (1).pptx
How AI Can Improve Media Quality Testing Across Platforms (1).pptxHow AI Can Improve Media Quality Testing Across Platforms (1).pptx
How AI Can Improve Media Quality Testing Across Platforms (1).pptx
kalichargn70th171
 
COBOL Programming with VSCode - IBM Certificate
COBOL Programming with VSCode - IBM CertificateCOBOL Programming with VSCode - IBM Certificate
COBOL Programming with VSCode - IBM Certificate
VICTOR MAESTRE RAMIREZ
 
Marketo & Dynamics can be Most Excellent to Each Other – The Sequel
Marketo & Dynamics can be Most Excellent to Each Other – The SequelMarketo & Dynamics can be Most Excellent to Each Other – The Sequel
Marketo & Dynamics can be Most Excellent to Each Other – The Sequel
BradBedford3
 
Topic 26 Security Testing Considerations.pptx
Topic 26 Security Testing Considerations.pptxTopic 26 Security Testing Considerations.pptx
Topic 26 Security Testing Considerations.pptx
marutnand8
 
How to purchase, license and subscribe to Microsoft Azure_PDF.pdf
How to purchase, license and subscribe to Microsoft Azure_PDF.pdfHow to purchase, license and subscribe to Microsoft Azure_PDF.pdf
How to purchase, license and subscribe to Microsoft Azure_PDF.pdf
victordsane
 
Integration Ignited Redefining Event-Driven Architecture at Wix - EventCentric
Integration Ignited Redefining Event-Driven Architecture at Wix - EventCentricIntegration Ignited Redefining Event-Driven Architecture at Wix - EventCentric
Integration Ignited Redefining Event-Driven Architecture at Wix - EventCentric
Natan Silnitsky
 
Providing Better Biodiversity Through Better Data
Providing Better Biodiversity Through Better DataProviding Better Biodiversity Through Better Data
Providing Better Biodiversity Through Better Data
Safe Software
 
Design by Contract - Building Robust Software with Contract-First Development
Design by Contract - Building Robust Software with Contract-First DevelopmentDesign by Contract - Building Robust Software with Contract-First Development
Design by Contract - Building Robust Software with Contract-First Development
Par-Tec S.p.A.
 
Best Inbound Call Tracking Software for Small Businesses
Best Inbound Call Tracking Software for Small BusinessesBest Inbound Call Tracking Software for Small Businesses
Best Inbound Call Tracking Software for Small Businesses
TheTelephony
 
Top 11 Fleet Management Software Providers in 2025 (2).pdf
Top 11 Fleet Management Software Providers in 2025 (2).pdfTop 11 Fleet Management Software Providers in 2025 (2).pdf
Top 11 Fleet Management Software Providers in 2025 (2).pdf
Trackobit
 
Automating Map Production With FME and Python
Automating Map Production With FME and PythonAutomating Map Production With FME and Python
Automating Map Production With FME and Python
Safe Software
 
14 Years of Developing nCine - An Open Source 2D Game Framework
14 Years of Developing nCine - An Open Source 2D Game Framework14 Years of Developing nCine - An Open Source 2D Game Framework
14 Years of Developing nCine - An Open Source 2D Game Framework
Angelo Theodorou
 
Ad

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//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/ POST /app/api/old_mobile/users {“user”: } ● 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”:, “email”:”[email protected]”, “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”:”[email protected]”} ○ 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)