SlideShare a Scribd company logo
1 of 18
API Security
n|u - The Open security community
Chennai Meet
Presenter : Vinoth Kumar
Date : 20/05/2017
# About Me
Application security engineer.
Blogger @ http://www.tutorgeeks.net
Email @ vinothpkumar333@gmail.com
https://null.co.in/profile/294-vinothpkumar
What is an API
An API is a list of commands that one program can send to another. It is used, so that individual programs can communicate with one
another directly and use each other's functions.
API allows two different application ( built on two different technologies ) communicate with each other.
Eg : A rails application accessing content from Java application and vice versa.
Need for an API
Let’s see the use cases of accessing contents of “website B” ( Using an API vs without an API )
If “website A” wants to access the content in “website B” , it will be difficult, if it fetches the content by parsing the HTML tags, since
website B may have code changes after few months. However, if website B provide API’s well documented, website A can access the
information without much difficulty by looking into the API documentation.
Using an API
Using username and password combination
Curl -v -u username:password -H “Content-type:application/json” -d ‘{JSON Input}’ -X HTTPMethod ‘API
Endpoint’
Using API Key
Curl -v -u API Key:test -H “Content-type:application/json” -d ‘{JSON Input}’ -X HTTPMethod ‘API Endpoint’
Security issues / Best practices in API
1. XSS / HTML Injection
2. Authorization and Authentication
3. Sensitive information disclosure
4. CORS Misconfiguration
5. API over HTTP
6. CSRF
7. HTTP Verb tampering
XSS and HTML Injection attacks
Vulnerable API Endpoint : api.vimeo.com/channels https://developer.vimeo.com/api/endpoints/channels
Vulnerable parameter : “Name” and “description”
curl -v -u username:password -H “Content-type:application.json”,
-X POST {'name': '<script>alert(document.cookie)</script>',
'description': '<marquee>HTML Injection</marquee>,
'privacy': 'anybody'}}
Reference : https://hackerone.com/reports/42702
Authorization and Authentication
Case study 1 :
Vulnerable API Endpoint : /api/user/
Login into the application using your valid credentials.
POST /login
{ credentials }
The below API call fetches your profile details
Actual request : GET /api/user/me
Intercept the request and modify the API call.
Modified request : GET /api/user/victim
Fetches the victim details .
Case study 2 :
Update the normal user to admin user. Now, normal user will have admin level privileges.
Now again downgrade back to normal user.
Vulnerability : Normal user still has admin level privileges.
Sensitive information disclosure - H1 Reports API
An attacker can disclose any user's private email by creating a sandbox program then adding that user to a report as a participant. Now
if the attacker issued a request to fetch the report through the API , the response will contain the invited user private email at the
activities object.
Steps to reproduce:
Go to any report submitted to your program.
Add the victim username as a participant to your report.
Generate an API token.
Fetch the report through the API
curl "https://api.hackerone.com/v1/reports/[report_id]" -u "api_idetifier:token"
The response will contain the invited user email at the activities object:
"activities":{"data":[{"type":"activity-external-user-invited","id":"1406712","attributes":{"message":null,"created_at":"2017-01-
08T01:57:27.614Z","updated_at":"2017-01-08T01:57:27.614Z","internal":true,"email":"<victim's_email@example.com>"}
Reference : https://hackerone.com/reports/196655
CORS Misconfiguration
Image, in example.com, we have the following header in the configuration
Access-Control-Allow-Origin: hello.com
www.evil.com wants to access the content in example.com
Request Blocked: The Same Origin Policy disallows reading the remote resource at http://www.example.com/. This can be fixed by
moving the resource to the same domain or enabling CORS.
Vulnerable CORS setting.
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
If the victim is logged into the application, the attacker can send an XMLHttpRequest to fetch the details.
Reference : http://blog.portswigger.net/2016/10/exploiting-cors-misconfigurations-for.html
API’s over HTTP
Vulnerable Request : curl -v -u username:password -H "Content-Type: application/json" -X GET
'http://example.com/api/vinoth/creditcard'
Imaging, the above API request is returning the credit card details of vinoth in response.
{“credit card” : 1111 1111 1111 1111, “expiry date”: “09/37”, “CVV”: 343 }
However, if you notice the above API call, it is accepting HTTP endpoint. Hence, it is vulnerable to sniffing attacks.
Remediation : All API requests should hit the secured endpoint i.e. only HTTPS
curl -v -u username:password -H "Content-Type: application/json" -X GET 'https://example.com/api/vinoth/creditcard'
CSRF - Twitter Cards API
POST
https://twitter.com/i/cards/api/v1.json?tweet_id=657629231309041664&card_name=poll2choice_text_only&forward=false&capi_uri=capi%3A%2F
%2Fpassthrough%2F1 HTTP/1.1
Host: twitter.com
Cookie: foo=bar
{"twitter:string:card_uri":"card://657629230759415808","twitter:long:original_tweet_id":"657629231309041664","twitter:string:selected_choice":"2
"}
POST
https://twitter.com/i/cards/api/v1?tweet_id=657629231309041664&card_name=poll2choice_text_only&forward=false&capi_uri=capi%3A%2F%2F
passthrough%2F1 HTTP/1.1
Host: twitter.com
Cookie: foo=bar
{"twitter:string:card_uri":"card://657629230759415808","twitter:long:original_tweet_id":"657629231309041664","twitter:string:selected_choice":"2
"}
Reference : https://hackerone.com/reports/95555
HTTP Verb tampering
HTTP Verb tampering : Trying random HTTP Methods.
API’s often use GET (read), POST (create), PUT (replace/update) and DELETE (to delete a record). Not all of these are valid choices
for every single resource collection, user, or action.
Make sure the incoming HTTP method is valid for the session token/API key and associated resource collection, action, and record.
For example, if you have an RESTful API for a library, it's not okay to allow anonymous users to DELETE book catalog entries, but it's
fine for them to GET a book catalog entry. On the other hand, for the librarian, both of these are valid uses.
Fuzzing - Array worth $500
Generates totally random input for the specified request parameters, hoping to provoke some kind of unexpected results.
Eg : If the API expects a string parameter , input an integer and vice-versa and check how the system responds.
Fuzzing IRCloud API’s
A security researcher discovered an API payload that would send invalid data to their own user process, which would repeatedly fail to
be handled correctly. This error handling loop prevented further access to their user account.
Actual request : {“_reqid”:1234, “cid”:5678, “to”: “#treehouse”, “msg”:”test”, “method”:”say”}
Modified request : {“_reqid”:1234, “cid”:5678, “to”:[“#treehouse”, “#darkscience”] , “msg”:”test”, “method”:”say”}
Reference : https://www.intelisecure.com/fuzzing-for-fun-and-profit/
API Rate limiting
X-RateLimit-Limit – The limit that you cannot surpass in a given amount of time
X-RateLimit-Remaining – The number of calls you have available until a given reset time stamp, or calculated given some sort of
sliding time window.
X-RateLimit-Reset – The timestamp in UTC formatted to HTTP spec per RFC 1123 for when the limits will be reset.
If you exceed the provided rate limit for a given API endpoint, you will receive the 429 Too Many Requests response with the
following message:
{
"message": "Too many requests. Check the X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset headers."
}
API Key - Compromise
It’s always better to mask your API key.
If the account is compromised , the attacker can note down your API key. This is dangerous, because even if the victim
changes his password realising the account compromise, the attacker can still have access to the account using his API
key.
Incase of account compromise, don’t just change the password, reset your API key as well.
API Testing tools
Postman
https://www.getpostman.com/
Fuzzapi [ REST API - JSON ]
https://github.com/nkpanda/fuzzapi
SOAPUI
https://www.soapui.org
Ready API
https://smartbear.com/product/ready-api/overview/
Tips for API Security assessment
API Documentation of the target is the main source for your assessment.
OWASP API Security cheat sheets can be handy
https://www.owasp.org/index.php/OWASP_API_Security_Project
https://www.owasp.org/index.php/REST_Assessment_Cheat_Sheet
https://www.owasp.org/index.php/OWASP_SaaS_Rest_API_Secure_Guide
Thank You

More Related Content

What's hot

OAuth - Open API Authentication
OAuth - Open API AuthenticationOAuth - Open API Authentication
OAuth - Open API Authenticationleahculver
 
Stateless authentication for microservices
Stateless authentication for microservicesStateless authentication for microservices
Stateless authentication for microservicesAlvaro Sanchez-Mariscal
 
Stateless authentication for microservices - GR8Conf 2015
Stateless authentication for microservices - GR8Conf 2015Stateless authentication for microservices - GR8Conf 2015
Stateless authentication for microservices - GR8Conf 2015Alvaro Sanchez-Mariscal
 
Securing RESTful APIs using OAuth 2 and OpenID Connect
Securing RESTful APIs using OAuth 2 and OpenID ConnectSecuring RESTful APIs using OAuth 2 and OpenID Connect
Securing RESTful APIs using OAuth 2 and OpenID ConnectJonathan LeBlanc
 
Secure Your REST API (The Right Way)
Secure Your REST API (The Right Way)Secure Your REST API (The Right Way)
Secure Your REST API (The Right Way)Stormpath
 
Oauth2 and OWSM OAuth2 support
Oauth2 and OWSM OAuth2 supportOauth2 and OWSM OAuth2 support
Oauth2 and OWSM OAuth2 supportGaurav Sharma
 
The Ultimate Guide to Mobile API Security
The Ultimate Guide to Mobile API SecurityThe Ultimate Guide to Mobile API Security
The Ultimate Guide to Mobile API SecurityStormpath
 
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
 
JavaOne 2014 - Securing RESTful Resources with OAuth2
JavaOne 2014 - Securing RESTful Resources with OAuth2JavaOne 2014 - Securing RESTful Resources with OAuth2
JavaOne 2014 - Securing RESTful Resources with OAuth2Rodrigo Cândido da Silva
 
Ruby on Rails Security Guide
Ruby on Rails Security GuideRuby on Rails Security Guide
Ruby on Rails Security Guideihji
 
Securing your apps with OAuth2 and OpenID Connect - Roland Guijt - Codemotion...
Securing your apps with OAuth2 and OpenID Connect - Roland Guijt - Codemotion...Securing your apps with OAuth2 and OpenID Connect - Roland Guijt - Codemotion...
Securing your apps with OAuth2 and OpenID Connect - Roland Guijt - Codemotion...Codemotion
 
OAuth with AngularJS and WebAPI - SoCal Code Camp 2015
OAuth with AngularJS and WebAPI - SoCal Code Camp 2015OAuth with AngularJS and WebAPI - SoCal Code Camp 2015
OAuth with AngularJS and WebAPI - SoCal Code Camp 2015Stuart
 
Single-Page-Application & REST security
Single-Page-Application & REST securitySingle-Page-Application & REST security
Single-Page-Application & REST securityIgor Bossenko
 
Ruby Security
Ruby SecurityRuby Security
Ruby SecuritySHC
 
Token Authentication for Java Applications
Token Authentication for Java ApplicationsToken Authentication for Java Applications
Token Authentication for Java ApplicationsStormpath
 
OAuth2 - Introduction
OAuth2 - IntroductionOAuth2 - Introduction
OAuth2 - IntroductionKnoldus Inc.
 
API Security Best Practices & Guidelines
API Security Best Practices & GuidelinesAPI Security Best Practices & Guidelines
API Security Best Practices & GuidelinesPrabath Siriwardena
 
Watch How the Giants Fall
Watch How the Giants FallWatch How the Giants Fall
Watch How the Giants Falljtmelton
 

What's hot (20)

OAuth2 + API Security
OAuth2 + API SecurityOAuth2 + API Security
OAuth2 + API Security
 
OAuth - Open API Authentication
OAuth - Open API AuthenticationOAuth - Open API Authentication
OAuth - Open API Authentication
 
Stateless authentication for microservices
Stateless authentication for microservicesStateless authentication for microservices
Stateless authentication for microservices
 
Stateless authentication for microservices - GR8Conf 2015
Stateless authentication for microservices - GR8Conf 2015Stateless authentication for microservices - GR8Conf 2015
Stateless authentication for microservices - GR8Conf 2015
 
Securing RESTful APIs using OAuth 2 and OpenID Connect
Securing RESTful APIs using OAuth 2 and OpenID ConnectSecuring RESTful APIs using OAuth 2 and OpenID Connect
Securing RESTful APIs using OAuth 2 and OpenID Connect
 
Secure Your REST API (The Right Way)
Secure Your REST API (The Right Way)Secure Your REST API (The Right Way)
Secure Your REST API (The Right Way)
 
Oauth2 and OWSM OAuth2 support
Oauth2 and OWSM OAuth2 supportOauth2 and OWSM OAuth2 support
Oauth2 and OWSM OAuth2 support
 
The Ultimate Guide to Mobile API Security
The Ultimate Guide to Mobile API SecurityThe Ultimate Guide to Mobile API Security
The Ultimate Guide to Mobile API Security
 
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)
 
JavaOne 2014 - Securing RESTful Resources with OAuth2
JavaOne 2014 - Securing RESTful Resources with OAuth2JavaOne 2014 - Securing RESTful Resources with OAuth2
JavaOne 2014 - Securing RESTful Resources with OAuth2
 
Ruby on Rails Security Guide
Ruby on Rails Security GuideRuby on Rails Security Guide
Ruby on Rails Security Guide
 
Securing your apps with OAuth2 and OpenID Connect - Roland Guijt - Codemotion...
Securing your apps with OAuth2 and OpenID Connect - Roland Guijt - Codemotion...Securing your apps with OAuth2 and OpenID Connect - Roland Guijt - Codemotion...
Securing your apps with OAuth2 and OpenID Connect - Roland Guijt - Codemotion...
 
OAuth with AngularJS and WebAPI - SoCal Code Camp 2015
OAuth with AngularJS and WebAPI - SoCal Code Camp 2015OAuth with AngularJS and WebAPI - SoCal Code Camp 2015
OAuth with AngularJS and WebAPI - SoCal Code Camp 2015
 
Single-Page-Application & REST security
Single-Page-Application & REST securitySingle-Page-Application & REST security
Single-Page-Application & REST security
 
Ruby Security
Ruby SecurityRuby Security
Ruby Security
 
Token Authentication for Java Applications
Token Authentication for Java ApplicationsToken Authentication for Java Applications
Token Authentication for Java Applications
 
OAuth2 - Introduction
OAuth2 - IntroductionOAuth2 - Introduction
OAuth2 - Introduction
 
API Security Best Practices & Guidelines
API Security Best Practices & GuidelinesAPI Security Best Practices & Guidelines
API Security Best Practices & Guidelines
 
Watch How the Giants Fall
Watch How the Giants FallWatch How the Giants Fall
Watch How the Giants Fall
 
D@W REST security
D@W REST securityD@W REST security
D@W REST security
 

Viewers also liked

A Strategic Path from Secure Code Reviews to Threat Modeling (101)
A Strategic Path from Secure Code Reviews to Threat Modeling (101)A Strategic Path from Secure Code Reviews to Threat Modeling (101)
A Strategic Path from Secure Code Reviews to Threat Modeling (101)Deepam Kanjani
 
Yet another talk on bug bounty
Yet another talk on bug bountyYet another talk on bug bounty
Yet another talk on bug bountyvinoth kumar
 
Networking basics by rahul at Null Mumbai
Networking basics by rahul at Null MumbaiNetworking basics by rahul at Null Mumbai
Networking basics by rahul at Null MumbaiAvkash Kathiriya
 
Basics of Cryptography
Basics of CryptographyBasics of Cryptography
Basics of CryptographySunil Kumar
 

Viewers also liked (7)

Nmap and metasploitable
Nmap and metasploitableNmap and metasploitable
Nmap and metasploitable
 
Bit squatting
Bit squattingBit squatting
Bit squatting
 
A Strategic Path from Secure Code Reviews to Threat Modeling (101)
A Strategic Path from Secure Code Reviews to Threat Modeling (101)A Strategic Path from Secure Code Reviews to Threat Modeling (101)
A Strategic Path from Secure Code Reviews to Threat Modeling (101)
 
Metasploit framwork
Metasploit framworkMetasploit framwork
Metasploit framwork
 
Yet another talk on bug bounty
Yet another talk on bug bountyYet another talk on bug bounty
Yet another talk on bug bounty
 
Networking basics by rahul at Null Mumbai
Networking basics by rahul at Null MumbaiNetworking basics by rahul at Null Mumbai
Networking basics by rahul at Null Mumbai
 
Basics of Cryptography
Basics of CryptographyBasics of Cryptography
Basics of Cryptography
 

Similar to API Security - Null meet

Web Apps: APIs' Nightmare
Web Apps: APIs' NightmareWeb Apps: APIs' Nightmare
Web Apps: APIs' NightmarePaulo Silva
 
LF_APIStrat17_OWASP’s Latest Category: API Underprotection
LF_APIStrat17_OWASP’s Latest Category: API UnderprotectionLF_APIStrat17_OWASP’s Latest Category: API Underprotection
LF_APIStrat17_OWASP’s Latest Category: API UnderprotectionLF_APIStrat
 
apidays New York 2023 - Android Applications and APIs Hacking, Gabrielle Botb...
apidays New York 2023 - Android Applications and APIs Hacking, Gabrielle Botb...apidays New York 2023 - Android Applications and APIs Hacking, Gabrielle Botb...
apidays New York 2023 - Android Applications and APIs Hacking, Gabrielle Botb...apidays
 
API Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIsAPI Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIsTom Johnson
 
Apidays Paris 2023 - Securing Microservice-based APIs, Michal Trojanowski, Cu...
Apidays Paris 2023 - Securing Microservice-based APIs, Michal Trojanowski, Cu...Apidays Paris 2023 - Securing Microservice-based APIs, Michal Trojanowski, Cu...
Apidays Paris 2023 - Securing Microservice-based APIs, Michal Trojanowski, Cu...apidays
 
Top 10 Web App Security Risks
Top 10 Web App Security RisksTop 10 Web App Security Risks
Top 10 Web App Security RisksSperasoft
 
HowYourAPIBeMyAPI
HowYourAPIBeMyAPIHowYourAPIBeMyAPI
HowYourAPIBeMyAPIJie Liau
 
Application Server-less Web Applications - Serverless Toronto Meetup
Application Server-less Web Applications - Serverless Toronto Meetup Application Server-less Web Applications - Serverless Toronto Meetup
Application Server-less Web Applications - Serverless Toronto Meetup Daniel Zivkovic
 
Understanding Identity in the World of Web APIs – Ronnie Mitra, API Architec...
Understanding Identity in the World of Web APIs – Ronnie Mitra,  API Architec...Understanding Identity in the World of Web APIs – Ronnie Mitra,  API Architec...
Understanding Identity in the World of Web APIs – Ronnie Mitra, API Architec...CA API Management
 
Federation Evolved: How Cloud, Mobile & APIs Change the Way We Broker Identity
Federation Evolved: How Cloud, Mobile & APIs Change the Way We Broker IdentityFederation Evolved: How Cloud, Mobile & APIs Change the Way We Broker Identity
Federation Evolved: How Cloud, Mobile & APIs Change the Way We Broker IdentityCA API Management
 
5 step plan to securing your APIs
5 step plan to securing your APIs5 step plan to securing your APIs
5 step plan to securing your APIs💻 Javier Garza
 
Z101666 best practices for delivering hybrid cloud capability with apis
Z101666 best practices for delivering hybrid cloud capability with apisZ101666 best practices for delivering hybrid cloud capability with apis
Z101666 best practices for delivering hybrid cloud capability with apisTeodoro Cipresso
 
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
 
Web PenTest Sample Report
Web PenTest Sample ReportWeb PenTest Sample Report
Web PenTest Sample ReportOctogence
 
APIsecure 2023 - Breaking Vulnerable APIs, Tushar Kulkarni
APIsecure 2023 - Breaking Vulnerable APIs, Tushar KulkarniAPIsecure 2023 - Breaking Vulnerable APIs, Tushar Kulkarni
APIsecure 2023 - Breaking Vulnerable APIs, Tushar Kulkarniapidays
 
WEBINAR: OWASP API Security Top 10
WEBINAR: OWASP API Security Top 10WEBINAR: OWASP API Security Top 10
WEBINAR: OWASP API Security Top 1042Crunch
 
Protecting Microservices APIs with 42Crunch API Firewall
Protecting Microservices APIs with 42Crunch API FirewallProtecting Microservices APIs with 42Crunch API Firewall
Protecting Microservices APIs with 42Crunch API Firewall42Crunch
 
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
 
RefCard RESTful API Design
RefCard RESTful API DesignRefCard RESTful API Design
RefCard RESTful API DesignOCTO Technology
 

Similar to API Security - Null meet (20)

Web Apps: APIs' Nightmare
Web Apps: APIs' NightmareWeb Apps: APIs' Nightmare
Web Apps: APIs' Nightmare
 
LF_APIStrat17_OWASP’s Latest Category: API Underprotection
LF_APIStrat17_OWASP’s Latest Category: API UnderprotectionLF_APIStrat17_OWASP’s Latest Category: API Underprotection
LF_APIStrat17_OWASP’s Latest Category: API Underprotection
 
apidays New York 2023 - Android Applications and APIs Hacking, Gabrielle Botb...
apidays New York 2023 - Android Applications and APIs Hacking, Gabrielle Botb...apidays New York 2023 - Android Applications and APIs Hacking, Gabrielle Botb...
apidays New York 2023 - Android Applications and APIs Hacking, Gabrielle Botb...
 
API Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIsAPI Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIs
 
Apidays Paris 2023 - Securing Microservice-based APIs, Michal Trojanowski, Cu...
Apidays Paris 2023 - Securing Microservice-based APIs, Michal Trojanowski, Cu...Apidays Paris 2023 - Securing Microservice-based APIs, Michal Trojanowski, Cu...
Apidays Paris 2023 - Securing Microservice-based APIs, Michal Trojanowski, Cu...
 
Top 10 Web App Security Risks
Top 10 Web App Security RisksTop 10 Web App Security Risks
Top 10 Web App Security Risks
 
HowYourAPIBeMyAPI
HowYourAPIBeMyAPIHowYourAPIBeMyAPI
HowYourAPIBeMyAPI
 
Application Server-less Web Applications - Serverless Toronto Meetup
Application Server-less Web Applications - Serverless Toronto Meetup Application Server-less Web Applications - Serverless Toronto Meetup
Application Server-less Web Applications - Serverless Toronto Meetup
 
testupload
testuploadtestupload
testupload
 
Understanding Identity in the World of Web APIs – Ronnie Mitra, API Architec...
Understanding Identity in the World of Web APIs – Ronnie Mitra,  API Architec...Understanding Identity in the World of Web APIs – Ronnie Mitra,  API Architec...
Understanding Identity in the World of Web APIs – Ronnie Mitra, API Architec...
 
Federation Evolved: How Cloud, Mobile & APIs Change the Way We Broker Identity
Federation Evolved: How Cloud, Mobile & APIs Change the Way We Broker IdentityFederation Evolved: How Cloud, Mobile & APIs Change the Way We Broker Identity
Federation Evolved: How Cloud, Mobile & APIs Change the Way We Broker Identity
 
5 step plan to securing your APIs
5 step plan to securing your APIs5 step plan to securing your APIs
5 step plan to securing your APIs
 
Z101666 best practices for delivering hybrid cloud capability with apis
Z101666 best practices for delivering hybrid cloud capability with apisZ101666 best practices for delivering hybrid cloud capability with apis
Z101666 best practices for delivering hybrid cloud capability with apis
 
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
 
Web PenTest Sample Report
Web PenTest Sample ReportWeb PenTest Sample Report
Web PenTest Sample Report
 
APIsecure 2023 - Breaking Vulnerable APIs, Tushar Kulkarni
APIsecure 2023 - Breaking Vulnerable APIs, Tushar KulkarniAPIsecure 2023 - Breaking Vulnerable APIs, Tushar Kulkarni
APIsecure 2023 - Breaking Vulnerable APIs, Tushar Kulkarni
 
WEBINAR: OWASP API Security Top 10
WEBINAR: OWASP API Security Top 10WEBINAR: OWASP API Security Top 10
WEBINAR: OWASP API Security Top 10
 
Protecting Microservices APIs with 42Crunch API Firewall
Protecting Microservices APIs with 42Crunch API FirewallProtecting Microservices APIs with 42Crunch API Firewall
Protecting Microservices APIs with 42Crunch API Firewall
 
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
 
RefCard RESTful API Design
RefCard RESTful API DesignRefCard RESTful API Design
RefCard RESTful API Design
 

Recently uploaded

Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 

Recently uploaded (20)

Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 

API Security - Null meet

  • 1. API Security n|u - The Open security community Chennai Meet Presenter : Vinoth Kumar Date : 20/05/2017
  • 2. # About Me Application security engineer. Blogger @ http://www.tutorgeeks.net Email @ vinothpkumar333@gmail.com https://null.co.in/profile/294-vinothpkumar
  • 3. What is an API An API is a list of commands that one program can send to another. It is used, so that individual programs can communicate with one another directly and use each other's functions. API allows two different application ( built on two different technologies ) communicate with each other. Eg : A rails application accessing content from Java application and vice versa. Need for an API Let’s see the use cases of accessing contents of “website B” ( Using an API vs without an API ) If “website A” wants to access the content in “website B” , it will be difficult, if it fetches the content by parsing the HTML tags, since website B may have code changes after few months. However, if website B provide API’s well documented, website A can access the information without much difficulty by looking into the API documentation.
  • 4. Using an API Using username and password combination Curl -v -u username:password -H “Content-type:application/json” -d ‘{JSON Input}’ -X HTTPMethod ‘API Endpoint’ Using API Key Curl -v -u API Key:test -H “Content-type:application/json” -d ‘{JSON Input}’ -X HTTPMethod ‘API Endpoint’
  • 5. Security issues / Best practices in API 1. XSS / HTML Injection 2. Authorization and Authentication 3. Sensitive information disclosure 4. CORS Misconfiguration 5. API over HTTP 6. CSRF 7. HTTP Verb tampering
  • 6. XSS and HTML Injection attacks Vulnerable API Endpoint : api.vimeo.com/channels https://developer.vimeo.com/api/endpoints/channels Vulnerable parameter : “Name” and “description” curl -v -u username:password -H “Content-type:application.json”, -X POST {'name': '<script>alert(document.cookie)</script>', 'description': '<marquee>HTML Injection</marquee>, 'privacy': 'anybody'}} Reference : https://hackerone.com/reports/42702
  • 7. Authorization and Authentication Case study 1 : Vulnerable API Endpoint : /api/user/ Login into the application using your valid credentials. POST /login { credentials } The below API call fetches your profile details Actual request : GET /api/user/me Intercept the request and modify the API call. Modified request : GET /api/user/victim Fetches the victim details . Case study 2 : Update the normal user to admin user. Now, normal user will have admin level privileges. Now again downgrade back to normal user. Vulnerability : Normal user still has admin level privileges.
  • 8. Sensitive information disclosure - H1 Reports API An attacker can disclose any user's private email by creating a sandbox program then adding that user to a report as a participant. Now if the attacker issued a request to fetch the report through the API , the response will contain the invited user private email at the activities object. Steps to reproduce: Go to any report submitted to your program. Add the victim username as a participant to your report. Generate an API token. Fetch the report through the API curl "https://api.hackerone.com/v1/reports/[report_id]" -u "api_idetifier:token" The response will contain the invited user email at the activities object: "activities":{"data":[{"type":"activity-external-user-invited","id":"1406712","attributes":{"message":null,"created_at":"2017-01- 08T01:57:27.614Z","updated_at":"2017-01-08T01:57:27.614Z","internal":true,"email":"<victim's_email@example.com>"} Reference : https://hackerone.com/reports/196655
  • 9. CORS Misconfiguration Image, in example.com, we have the following header in the configuration Access-Control-Allow-Origin: hello.com www.evil.com wants to access the content in example.com Request Blocked: The Same Origin Policy disallows reading the remote resource at http://www.example.com/. This can be fixed by moving the resource to the same domain or enabling CORS. Vulnerable CORS setting. Access-Control-Allow-Origin: * Access-Control-Allow-Credentials: true If the victim is logged into the application, the attacker can send an XMLHttpRequest to fetch the details. Reference : http://blog.portswigger.net/2016/10/exploiting-cors-misconfigurations-for.html
  • 10. API’s over HTTP Vulnerable Request : curl -v -u username:password -H "Content-Type: application/json" -X GET 'http://example.com/api/vinoth/creditcard' Imaging, the above API request is returning the credit card details of vinoth in response. {“credit card” : 1111 1111 1111 1111, “expiry date”: “09/37”, “CVV”: 343 } However, if you notice the above API call, it is accepting HTTP endpoint. Hence, it is vulnerable to sniffing attacks. Remediation : All API requests should hit the secured endpoint i.e. only HTTPS curl -v -u username:password -H "Content-Type: application/json" -X GET 'https://example.com/api/vinoth/creditcard'
  • 11. CSRF - Twitter Cards API POST https://twitter.com/i/cards/api/v1.json?tweet_id=657629231309041664&card_name=poll2choice_text_only&forward=false&capi_uri=capi%3A%2F %2Fpassthrough%2F1 HTTP/1.1 Host: twitter.com Cookie: foo=bar {"twitter:string:card_uri":"card://657629230759415808","twitter:long:original_tweet_id":"657629231309041664","twitter:string:selected_choice":"2 "} POST https://twitter.com/i/cards/api/v1?tweet_id=657629231309041664&card_name=poll2choice_text_only&forward=false&capi_uri=capi%3A%2F%2F passthrough%2F1 HTTP/1.1 Host: twitter.com Cookie: foo=bar {"twitter:string:card_uri":"card://657629230759415808","twitter:long:original_tweet_id":"657629231309041664","twitter:string:selected_choice":"2 "} Reference : https://hackerone.com/reports/95555
  • 12. HTTP Verb tampering HTTP Verb tampering : Trying random HTTP Methods. API’s often use GET (read), POST (create), PUT (replace/update) and DELETE (to delete a record). Not all of these are valid choices for every single resource collection, user, or action. Make sure the incoming HTTP method is valid for the session token/API key and associated resource collection, action, and record. For example, if you have an RESTful API for a library, it's not okay to allow anonymous users to DELETE book catalog entries, but it's fine for them to GET a book catalog entry. On the other hand, for the librarian, both of these are valid uses.
  • 13. Fuzzing - Array worth $500 Generates totally random input for the specified request parameters, hoping to provoke some kind of unexpected results. Eg : If the API expects a string parameter , input an integer and vice-versa and check how the system responds. Fuzzing IRCloud API’s A security researcher discovered an API payload that would send invalid data to their own user process, which would repeatedly fail to be handled correctly. This error handling loop prevented further access to their user account. Actual request : {“_reqid”:1234, “cid”:5678, “to”: “#treehouse”, “msg”:”test”, “method”:”say”} Modified request : {“_reqid”:1234, “cid”:5678, “to”:[“#treehouse”, “#darkscience”] , “msg”:”test”, “method”:”say”} Reference : https://www.intelisecure.com/fuzzing-for-fun-and-profit/
  • 14. API Rate limiting X-RateLimit-Limit – The limit that you cannot surpass in a given amount of time X-RateLimit-Remaining – The number of calls you have available until a given reset time stamp, or calculated given some sort of sliding time window. X-RateLimit-Reset – The timestamp in UTC formatted to HTTP spec per RFC 1123 for when the limits will be reset. If you exceed the provided rate limit for a given API endpoint, you will receive the 429 Too Many Requests response with the following message: { "message": "Too many requests. Check the X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset headers." }
  • 15. API Key - Compromise It’s always better to mask your API key. If the account is compromised , the attacker can note down your API key. This is dangerous, because even if the victim changes his password realising the account compromise, the attacker can still have access to the account using his API key. Incase of account compromise, don’t just change the password, reset your API key as well.
  • 16. API Testing tools Postman https://www.getpostman.com/ Fuzzapi [ REST API - JSON ] https://github.com/nkpanda/fuzzapi SOAPUI https://www.soapui.org Ready API https://smartbear.com/product/ready-api/overview/
  • 17. Tips for API Security assessment API Documentation of the target is the main source for your assessment. OWASP API Security cheat sheets can be handy https://www.owasp.org/index.php/OWASP_API_Security_Project https://www.owasp.org/index.php/REST_Assessment_Cheat_Sheet https://www.owasp.org/index.php/OWASP_SaaS_Rest_API_Secure_Guide