SlideShare a Scribd company logo
`
MOHAMMED A. IMRANRESTfulWebServices
Pentesting
Hello
MOHAMMED A. IMRAN
ApplicationSecurityEngineer,CAInc
Null Hyderabad Lead
OWASP Hyderabad Board Member
@MohammedAImran
MI
Created and Designed using
LET’S TALK ABOUT ...
PROBLEMS WITH REST
WS TESTING
TOOLS & TECHNIQUES
WHAT IS RESTful
WEB SERVICES?
METHODOLOGY TO TEST
RESTful WS
DID
YOU
KNOW?
THEUGLYTRUTH SOAP Webservices VS RESTful Webservices
Google Trends
TheyalsorestonRESTAPIs
WhyRESTWebServices?
Easy&Simple
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:Body xmlns:m="http://www.mysite.com/users">
  <m:GetUserDetails>
    <m:UserID>313</m:UserID>
  </m:GetUserDetails>
</soap:Body>
</soap:Envelope>
GET /users/313/
VS
Lightweight
<soap:Body xmlns:m="http://www.mysite.com/users">
  <m:GetUserDetailsResponse>
    <m:UserName>MohammedAImran</m:UserName>
<m:Type>user</m:Type>
<m:SiteAdmin>false</m:SiteAdmin>
<m:UserName>Mohammed A.Imran</m:UserName>
<m:Company>CA Inc</m:Company>
<m:Email> morpheus@null.co.in </m:Email>
  </m:GetUserDetailsResponse>
</soap:Body>
{
"login": "MohammedAImran",
"type": "User",
"site_admin": false,
"name": "Mohammed A. Imran",
"company": "CA Inc",
"email": "morpheus@null.co.in"
}
VS
Note: REST can also use XML as media type
Manymorereasonstouse...
●
Easy to understand & document
●
Easy on limited bandwidth
●
READS can be cached and hence reduces the bandwidth
●
Better browser support since data format mostly is json
●
Can be used by mobile devices
●
Loosely coupled
ButwhatisREST ?
Representational state transfer (REST) is an
architectural style consisting of a coordinated
set of constraints applied to components,
connectors, and data elements, within a
distributed hypermedia system.
“
What?Letmeexplain...
REST is an architectural style with some imposed constraints
in how data is accessed and represented while developing web
services or applications. It uses HTTP 1.1 as inspiration.
Insimpleterms
REST = RFC 2616Well, almost
Insimpleterms...
REST = HTTP Protocol
with constraints
Architectureconstraints
●
Uniform interface
●
Client-server
●
Stateless
●
Cache-able
●
Layered system
●
Code on demand(optional)
RESTStyleconsistsof...
Resources VERBS Media Types Status Codes
RESTStyleconsistsof...
Resource URLs VERBS Media Types Status Codes
RESOURCES
Site.com/users/1
INSTANCE
RESOURCES
Collection
RESOURCES
NOUN
Site.com/users
RESTStyleconsistsof...
Resources VERBS Media Types Status Codes
VERBS
POST
READ
PUT
DELETE
POST = CREATECreate a new some resource
*
* POST can be used for both create and update
POST http://mysite.com/users/
{
"login": "MohammedAImran",
"id": "313",
"name": "Mohammed A. Imran",
"company": "CA Inc",
"email": "MohammedAbdullahImran@gmail.com"
}
GET = READFetch some resource
GET site.com/users/
{ users:[
{
"login": "MohammedAImran",
"id": "313",
"name": "Mohammed A. Imran",
"company": "CA Inc",
"email": "MohammedAbdullahImran@gmail.com"},
{
"login": "Raghunath",
"id": "311",
"name": " G Raghunath",
"company": "X Inc",
"email": "raghu@null.co.in"}]
}
GET site.com/users/313
{
"login": "MohammedAImran",
"id": "313",
"name": "Mohammed A. Imran",
"company": "CA Inc",
"email": "MohammedAbdullahImran@gmail.com"
}
PUT =UPDATE/MODIFYUpdate some resource
* PUT can be used for both create and update
*
DELETE = DELETEDelete a resource
RESTStyleconsistsof...
Resources VERBS Media Types Status Codes
HATEOAS
Hypermedia As The Engine Of Application State
Media TypesParsing RulesSpecifications
+ =
MediaTypeExamples
Application/json
Application/xml
Application/imrans+json;v1
RESTStyleconsistsof...
Resources VERBS Media Types Status Codes
StatusCodes
400 Bad Request
401 Unauthorized
403 Forbidden
404 Not Found
405 Method Not Allowed
409 Conflict
200 OK
201 Created
204 No Content
304 Not Modified
500 Internal Server Error
501 Not Implemented
RESTfulWStestingproblems
DifficultyindoingRESTPT
●
Many JSON variables to fuzz and difficult to find which ones
are optional and to be fuzzed
●
Custom authentication
●
Statelessness
●
Non common HTTP status codes which tools are used to
DifficultyindoingRESTPT...
●
Not so good automated tool support
●
Every API is different from other and hence need custom
tweaking for tools
●
Heavy reliance on Ajax frameworks for creating PUT and
DELETE requests as most browsers don’t support them
RESTWStestingMethodology
Authentication
Badpractices
http://site.com/token/a3b3c2be5f53c8/
https://site.com/token/a3b3c2be5f53c8/
Authentication...
●
REST APIs rely heavily on SSL
●
Often basic authentication is coupled with SSL ( Bruteforce ? )
●
Often custom token authentication schemes are built and used
( a sure recipe for disaster)
●
Never pass username/password, tokens, keys in URL
(use POST instead )
●
Implementing authentication tokens in Headers takes away headache of
having a CSRF token
SessionManagement
●
Check all session based attacks on tokens as well
●
Session timeout
●
Session brute force
●
Generally tokens are stored in local storage of browsers,
make sure you delete the token after log-out and upon
browser window close
●
Invalidate the token at server side upon on logout
Authorization
●
Privilege escalation (Horizontal and Vertical)
●
Make sure there is a tight access control on DELETE, PUT methods
●
Use role based authentication
●
Since usually the consumers of the REST APIs are machines, there
are no checks if service is heavily used, could lead to DoS or
BruteForce.
●
Protect administrative functionality
CVE-2010-0738
JBOSSJMXConsoleVulnerability
NOTE
All attacks which are possible on any web application are possible with
REST APIs as well.
InputValidation
●
SQL Injection
●
XSS
●
Command Injection
●
XPATH Injection
However XSS becomes difficult to fuzz because of JSON
and you might want to scan with sql injection and xss
profiles separately
Outputencoding
●
If you application has a web interface then might want to use
the following headers:
– X-Content-Type-Options: nosniff
– X-Frame-Options: DENY/SAMEORIGIN/ALLOW-FROM
●
JSON Encoding
Cryptography
●
Use TLS with good key size (384 bits preferably)
●
Use client side certificates possible however not usually seen
for APIs
●
Use strong hashing algorithms(scrypt/bcrypt/SHA512)
●
Use strong encryption mechanisms (AES)
Fewnotes...
●
Use proxy to determine the attack surface and to understand
the application
●
Identify URLs, Resources, status codes and data needed
●
Every part of the http protocol is potential for fuzzing in
RESTful APIs (dont forget headers)
●
WAF evasion is possible since json is not well understood by
WAFs
Tools&Techniques
Command-line-Fu
cURLPrimer
cURL
-b or - -cookie ”COOKIE HERE”
-h or - -header “Authorization: Custom SW1yYW5XYXNIZXJlCg==”
-X or - -request PUT/POST/DELETE
-i or - -include //include response headers
-d or - -data “username=imran&password=Imran” or - -data @filecontaining-data
-x or - - proxy 127.0.0.1:8080
-A or - -user-agent ”Firefox 27.0”
cURLPrimer...
●
cURL is great for automation if you know how service works.
●
cURL libraries are available for majority of the languages like php, python
and many more...
●
You can perform complex operations and script them pretty fast.
cURLExamples
#!/bin/bash
users="Imran Jaya Raghu Vinayak"
for dirName in $users
do
curl -i -H “Authorization: Custom SW1yYW5XYXNIZXJlCg==”
"http://www.mysite.com/users/$dirName" --proxy 127.0.0.1:8080
done
GraphicalTools
FirefoxAdd-on
FirefoxAdd-on...
●
If you need graphical interface, browser add-ons provide GUI, however not
as powerful as the cURL command.
●
Specialized developer tools ( SOAP UI ) can also be used for testing.
AutomatedTools
AppScanScan
http://blog.watchfire.com/wfblog/2012/01/testing-restful-services-with-appscan-standard.html
AppScanScan...
Thankyou!
Wanttodiscussmore?
Catch me on
www.twitter.com/MohammedAImran
www.linkedin.com/in/MohammedAImran
Youmightliketheseaswell!
Credits
* All icons are taken from The Noun project, credit goes to
respective artists
* OWASP Cheat sheet series
References
http://www.slideshare.net/SOURCEConference/security-testing-for-rest-applications-ofer-shezaf-source-barcelona-nov-2011
https://www.owasp.org/index.php/REST_Security_Cheat_Sheet
http://securityreliks.wordpress.com/2010/07/28/testing-restful-services-with-appscan/
http://www-01.ibm.com/support/docview.wss?uid=swg21412832
http://blog.watchfire.com/wfblog/2012/01/testing-restful-services-with-appscan-standard.html

More Related Content

PDF
Securty Testing For RESTful Applications
PPTX
Pentesting ReST API
PDF
Pentesting RESTful webservices
PPTX
Getting Started with API Security Testing
PPTX
Secure Your REST API (The Right Way)
PDF
In graph we trust: Microservices, GraphQL and security challenges
PPTX
Automated API pentesting using fuzzapi
PDF
Best Practices in Web Service Design
Securty Testing For RESTful Applications
Pentesting ReST API
Pentesting RESTful webservices
Getting Started with API Security Testing
Secure Your REST API (The Right Way)
In graph we trust: Microservices, GraphQL and security challenges
Automated API pentesting using fuzzapi
Best Practices in Web Service Design

What's hot (20)

PPTX
Secure RESTful API Automation With JavaScript
PPTX
REST API Design & Development
PPTX
Rest API Security
PDF
Secure Web Services
PDF
Pentesting Rest API's by :- Gaurang Bhatnagar
ODP
Attacking REST API
PDF
Building an API Security Ecosystem
ODP
Mohanraj - Securing Your Web Api With OAuth
PPTX
RESTful modules in zf2
PPTX
Best Practices in Building an API Security Ecosystem
PPTX
RESTful API Automation with JavaScript
PDF
Restful api design
PPTX
Introduction to shodan
PPT
Encoded Attacks And Countermeasures
PDF
Securing REST APIs
ODP
Top 10 Web Security Vulnerabilities
PDF
Building Beautiful REST APIs with ASP.NET Core
PDF
Understanding Identity in the World of Web APIs – Ronnie Mitra, API Architec...
PPTX
Rest & RESTful WebServices
PPTX
REST API Design for JAX-RS And Jersey
Secure RESTful API Automation With JavaScript
REST API Design & Development
Rest API Security
Secure Web Services
Pentesting Rest API's by :- Gaurang Bhatnagar
Attacking REST API
Building an API Security Ecosystem
Mohanraj - Securing Your Web Api With OAuth
RESTful modules in zf2
Best Practices in Building an API Security Ecosystem
RESTful API Automation with JavaScript
Restful api design
Introduction to shodan
Encoded Attacks And Countermeasures
Securing REST APIs
Top 10 Web Security Vulnerabilities
Building Beautiful REST APIs with ASP.NET Core
Understanding Identity in the World of Web APIs – Ronnie Mitra, API Architec...
Rest & RESTful WebServices
REST API Design for JAX-RS And Jersey
Ad

Viewers also liked (19)

PPTX
JSON SQL Injection and the Lessons Learned
PPTX
PDF
API Testing
PPTX
Api testing
PPTX
REST API testing with SpecFlow
PPTX
Getting started with CFEngine - Webinar
PPT
WCF And ASMX Web Services
PPTX
WCF security
PPTX
Web Service Workshop - 3 days
PPTX
PPTX
DNS hijacking - null Singapore
PPTX
Humla workshop on Android Security Testing - null Singapore
PDF
C# Advanced L08-Networking+WCF
PDF
Three things that rowhammer taught me by Halvar Flake
PPTX
Wcf security session 1
PDF
Stegano Secrets - Python
JSON SQL Injection and the Lessons Learned
API Testing
Api testing
REST API testing with SpecFlow
Getting started with CFEngine - Webinar
WCF And ASMX Web Services
WCF security
Web Service Workshop - 3 days
DNS hijacking - null Singapore
Humla workshop on Android Security Testing - null Singapore
C# Advanced L08-Networking+WCF
Three things that rowhammer taught me by Halvar Flake
Wcf security session 1
Stegano Secrets - Python
Ad

Similar to Pentesting RESTful WebServices v1.0 (20)

PPTX
Spa Secure Coding Guide
PPTX
2 . web app s canners
PDF
PPS
Hacking Client Side Insecurities
PPTX
04. xss and encoding
PPT
Web Services Security
PDF
Romulus OWASP
PPTX
How to Use Stormpath in angular js
PPT
Using Proxies To Secure Applications And More
PPTX
Hacking mobile apps
PDF
Webservices in SalesForce (part 1)
PPT
Identifying Web Servers: A First-look Into the Future of Web Server Fingerpri...
PDF
zendframework2 restful
PDF
Securing Web Applications with Token Authentication
PDF
How APIs Can Be Secured in Mobile Environments
PPTX
Building Secure User Interfaces With JWTs (JSON Web Tokens)
PPT
AppSec 2007 - .NET Web Services Hacking
PDF
OWASP Portland - OWASP Top 10 For JavaScript Developers
Spa Secure Coding Guide
2 . web app s canners
Hacking Client Side Insecurities
04. xss and encoding
Web Services Security
Romulus OWASP
How to Use Stormpath in angular js
Using Proxies To Secure Applications And More
Hacking mobile apps
Webservices in SalesForce (part 1)
Identifying Web Servers: A First-look Into the Future of Web Server Fingerpri...
zendframework2 restful
Securing Web Applications with Token Authentication
How APIs Can Be Secured in Mobile Environments
Building Secure User Interfaces With JWTs (JSON Web Tokens)
AppSec 2007 - .NET Web Services Hacking
OWASP Portland - OWASP Top 10 For JavaScript Developers

More from n|u - The Open Security Community (20)

PDF
Hardware security testing 101 (Null - Delhi Chapter)
PPTX
SSRF exploit the trust relationship
PDF
PDF
Api security-testing
PDF
Introduction to TLS 1.3
PDF
Gibson 101 -quick_introduction_to_hacking_mainframes_in_2020_null_infosec_gir...
PDF
Talking About SSRF,CRLF
PPTX
Building active directory lab for red teaming
PPTX
Owning a company through their logs
PDF
Detecting persistence in windows
PPTX
Frida - Objection Tool Usage
PDF
OSQuery - Monitoring System Process
PDF
DevSecOps Jenkins Pipeline -Security
PDF
Extensible markup language attacks
PPTX
PDF
PDF
News bytes null 200314121904
Hardware security testing 101 (Null - Delhi Chapter)
SSRF exploit the trust relationship
Api security-testing
Introduction to TLS 1.3
Gibson 101 -quick_introduction_to_hacking_mainframes_in_2020_null_infosec_gir...
Talking About SSRF,CRLF
Building active directory lab for red teaming
Owning a company through their logs
Detecting persistence in windows
Frida - Objection Tool Usage
OSQuery - Monitoring System Process
DevSecOps Jenkins Pipeline -Security
Extensible markup language attacks
News bytes null 200314121904

Pentesting RESTful WebServices v1.0