+ All Categories
Home > Technology > REST API Pentester's perspective

REST API Pentester's perspective

Date post: 21-Jan-2018
Category:
Upload: securing
View: 389 times
Download: 7 times
Share this document with a friend
72
www.securing.pl Mateusz Olejarka REST API Pentester’s perspective 20.10.2017
Transcript
Page 1: REST API Pentester's perspective

www.securing.pl

Mateusz Olejarka

REST APIPentester’s perspective

20.10.2017

Page 2: REST API Pentester's perspective

www.securing.pl

KA-BOOM

Anand Prakash @sehacure

Page 3: REST API Pentester's perspective

www.securing.pl

KA-BOOM

„Whenever a user Forgets his password on Facebook, he has an option to reset the password by entering his phone number/ email address on:

https://www.facebook.com/login/identify?ctx=recover&lwv=110

Facebook will then send a 6 digit code on his phone number/email address which user has to enter in order to set a new password.

I tried to brute the 6 digit code on www.facebook.com and was blocked after 10-12 invalid attempts.”

Page 4: REST API Pentester's perspective

www.securing.pl

KA-BOOM

„Then i looked out for the same issue on beta.facebook.com and mbasic.beta.facebook.com and interestingly rate limiting was missing on forgot password endpoints.”

Page 5: REST API Pentester's perspective

www.securing.pl

Page 6: REST API Pentester's perspective

www.securing.pl

KA-BOOM

Page 7: REST API Pentester's perspective

www.securing.pl

KA-BOOM

Page 8: REST API Pentester's perspective

www.securing.pl

KA-BOOM

Page 9: REST API Pentester's perspective

www.securing.pl

REST API

• Is everywhere (web&mobile)

• Is build on top of existing applications

• More and more companies allow to use it’s API

• Applications are more interconnected

• Microservices

Page 10: REST API Pentester's perspective

www.securing.pl

REST API

https://www.mobapi.com/history-of-rest-apis/

Page 11: REST API Pentester's perspective

www.securing.pl

• Senior IT Security Specialist, SecuRing

• Web & mobile application security

• OWASP Poland member

• Ex developer

• Bug hunter

Who am I

Page 12: REST API Pentester's perspective

www.securing.pl

• REST API 101

• Finding endpoints

• Finding docs

• Finding sample calls

• Finding keys

• 2 more examples

• Q&A

Agenda

Page 13: REST API Pentester's perspective

www.securing.plwww.securing.pl

REST API 101

Page 14: REST API Pentester's perspective

www.securing.pl

REST API 101

• REST – representational state transfer

• Data usually is sent as JSON

• HTTP methods have a meaning (usually):

• GET - list (collection), retrieve data (element)

• PUT – replace (all data is changed)

• PATCH – update

• POST – create (new element)

• DELETE

Page 15: REST API Pentester's perspective

www.securing.pl

REST API 101

Page 16: REST API Pentester's perspective

www.securing.pl

• Get endpoints

• Get docs

• Get keys/credentials

• Get sample calls !!

REST API Pentest

Page 17: REST API Pentester's perspective

www.securing.pl

• Sometimes no known endpoints

• Sometimes no docs

• Sometimes no keys/credentials

• Sometimes no sample calls !!

REST API Bug bounty

Page 18: REST API Pentester's perspective

www.securing.plwww.securing.pl

FINDING ENDPOINTS

Page 19: REST API Pentester's perspective

www.securing.pl

• /

• /api/

• /v1/

• /v1.0/

• /v1.1/

• /api/v1/

• /api/v2

Finding endpoints

Page 20: REST API Pentester's perspective

www.securing.pl

• /

• /api/

• /v1/

• /v1.0/

• /v1.1/

• /api/v1/

• /api/v2

Finding endpoints

Page 21: REST API Pentester's perspective

www.securing.pl

• /

• /api/

• /v1/

• /v1.0/

• /v1.1/

• /api/v1/

• /api/v2

Finding endpoints

Page 22: REST API Pentester's perspective

www.securing.pl

• /ping

• /health

• /status

• …

• Dictionaries for directories and filenames will help

Finding endpoints

Page 23: REST API Pentester's perspective

www.securing.pl

• /ping

• /health

• /status

• …

• Dictionaries for directories and filenames will help

Finding endpoints

Page 24: REST API Pentester's perspective

www.securing.pl

• /ping

• /health

• /status

• …

• Dictionaries for directories and filenames will help

Finding endpoints

Page 25: REST API Pentester's perspective

www.securing.pl

• /ping

• /health

• /status

• …

• Dictionaries for directories and filenames will help

Finding endpoints

Page 26: REST API Pentester's perspective

www.securing.pl

Spring Boot Actuator

Page 27: REST API Pentester's perspective

www.securing.pl

Spring Boot Actuator

Page 28: REST API Pentester's perspective

www.securing.pl

• Interesting endpoints:

• /actuator

• /health

• /trace

• /logfile

• /metrics

• /heapdump (Spring MVC)

Spring Boot Actuator

Page 29: REST API Pentester's perspective

www.securing.pl

• Interesting endpoints:

• /actuator

• /health

• /trace

• /logfile

• /metrics

• /heapdump (Spring MVC)

Spring Boot Actuator

Page 30: REST API Pentester's perspective

www.securing.pl

• Interesting endpoints:

• /actuator

• /health

• /trace

• /logfile

• /metrics

• /heapdump (Spring MVC)

Spring Boot Actuator

Page 31: REST API Pentester's perspective

www.securing.plwww.securing.pl

HEAP DUMP LIVE DEMO

Page 32: REST API Pentester's perspective

www.securing.plwww.securing.pl

Page 33: REST API Pentester's perspective

www.securing.plwww.securing.pl

FINDING DOCS

Page 34: REST API Pentester's perspective

www.securing.pl

• /api-docs

• /application.wadl

• /doc

• /docs

• /swagger-ui.html

• /swagger.json

Finding docs:

Page 35: REST API Pentester's perspective

www.securing.pl

• /api-docs

• /application.wadl

• /doc

• /docs

• /swagger-ui.html

• /swagger.json

Finding docs:

Page 36: REST API Pentester's perspective

www.securing.plwww.securing.pl

SOAP UI LIVE DEMO

Page 37: REST API Pentester's perspective

www.securing.pl

• /api-docs

• /application.wadl

• /doc

• /docs

• /swagger-ui.html

• /swagger.json

Finding docs:

Page 38: REST API Pentester's perspective

www.securing.pl

• /api-docs

• /application.wadl

• /doc

• /docs

• /swagger-ui.html

• /swagger.json

Finding docs:

Page 39: REST API Pentester's perspective

www.securing.plwww.securing.pl

SWAGGER LIVE DEMO

Page 40: REST API Pentester's perspective

www.securing.plwww.securing.pl

FINDING SAMPLE CALLS

Page 41: REST API Pentester's perspective

www.securing.pl

• Still no docs?

• Error messages to the rescue!

Finding sample calls

Page 42: REST API Pentester's perspective

www.securing.pl

• Still no docs?

• Error messages to the rescue!

Finding sample calls

Page 43: REST API Pentester's perspective

www.securing.pl

• Still no docs?

• Error messages to the rescue!

Finding sample calls

Page 44: REST API Pentester's perspective

www.securing.pl

• Still no docs?

• Error messages to the rescue!

Finding sample calls

Page 45: REST API Pentester's perspective

www.securing.pl

• Still no docs?

• Error messages to the rescue!

Finding sample calls

Page 46: REST API Pentester's perspective

www.securing.pl

• Still no docs?

• Error messages to the rescue!

Finding sample calls

Page 47: REST API Pentester's perspective

www.securing.pl

• Still no docs?

• Error messages to the rescue!

• Brute force parameter names!

Finding sample calls

Page 48: REST API Pentester's perspective

www.securing.pl

• Still no docs?

• Error messages to the rescue!

• Brute force parameter names!

• Analyze JS code (see JS-Scan)

• Dissect mobile app ( Apk-Scan for Android apps hadrcoded URL’s)

Finding sample calls

Page 49: REST API Pentester's perspective

www.securing.plwww.securing.pl

FINDING KEYS

Page 50: REST API Pentester's perspective

www.securing.pl

Finding keys

• Check mobile application

• Check GitHub (truffleHog to the rescue):

• Scan public repos of a company

• Scan public repos of a company devs

Page 51: REST API Pentester's perspective

www.securing.pl

Finding keys

Page 52: REST API Pentester's perspective

www.securing.pl

Finding keys

• Check mobile application

• Check GitHub (truffleHog to the rescue):

• Scan public repos of a company

• Scan public repos of a company devs

Page 53: REST API Pentester's perspective

www.securing.pl

Finding keys

• Check mobile application

• Check GitHub (truffleHog to the rescue):

• Scan public repos of a company

• Scan public repos of a company devs

Page 54: REST API Pentester's perspective

www.securing.pl

Finding keys

Page 55: REST API Pentester's perspective

www.securing.plwww.securing.pl

2 MORE EXAMPLES

Page 56: REST API Pentester's perspective

www.securing.pl

#1 Jolokia

Page 57: REST API Pentester's perspective

www.securing.pl

„Jolokia is a JMX-HTTP bridge giving an alternative to JSR-160 connectors. It is an agent based approach with support for many platforms. In addition to basic JMX operations it enhances JMX remoting with unique features like bulk requests and fine grained security policies.”

#1 Jolokia

Page 58: REST API Pentester's perspective

www.securing.pl

„Jolokia is a JMX-HTTP bridge giving an alternative to JSR-160 connectors. It is an agent based approach with support for many platforms. In addition to basic JMX operations it enhances JMX remoting with unique features like bulk requests and fine grained security policies.”

https://example.com/jolokia/write/Tomcat:port=19880,type=Connector/xpoweredBy/true

#1 Jolokia

Page 59: REST API Pentester's perspective

www.securing.pl

„Jolokia is a JMX-HTTP bridge giving an alternative to JSR-160 connectors. It is an agent based approach with support for many platforms. In addition to basic JMX operations it enhances JMX remoting with unique features like bulk requests and fine grained security policies.”

https://example.com/jolokia/write/Tomcat:port=19880,type=Connector/xpoweredBy/true

X-Powered-By:Servlet/3.1 JSP/2.3 (Apache Tomcat/8.0.20 Java/Oracle Corporation/1.8.0_60-b27)

#1 Jolokia

Page 60: REST API Pentester's perspective

www.securing.pl

#1 Jolokia

Page 61: REST API Pentester's perspective

www.securing.pl

#2 REST API wrongly placed

Page 62: REST API Pentester's perspective

www.securing.pl

#2 REST API wrongly placed

• A form

Page 63: REST API Pentester's perspective

www.securing.pl

#2 REST API wrongly placed

• A form

• Putting ID and solving CAPTCHA

Page 64: REST API Pentester's perspective

www.securing.pl

#2 REST API wrongly placed

• A form

• Putting ID and solving CAPTCHA

• Secured (no way to brute force ID)

Page 65: REST API Pentester's perspective

www.securing.pl

#2 REST API wrongly placed

• A form

• Putting ID and solving CAPTCHA

• Secured (no way to brute force ID)

• A mobile app with the same feature

Page 66: REST API Pentester's perspective

www.securing.pl

#2 REST API wrongly placed

• A form

• Putting ID and solving CAPTCHA

• Secured (no way to brute force ID)

• A mobile app with the same feature

• No CAPTCHA

Page 67: REST API Pentester's perspective

www.securing.pl

#2 REST API wrongly placed

• A form

• Putting ID and solving CAPTCHA

• Secured (no way to brute force ID)

• A mobile app with the same feature

• No CAPTCHA

• No rate limiting

Page 68: REST API Pentester's perspective

www.securing.pl

#2 REST API wrongly placed

• A form

• Putting ID and solving CAPTCHA

• Secured (no way to brute force ID)

• A mobile app with the same feature

• No CAPTCHA

• No rate limiting

• Brute force &profit report to client !

Page 69: REST API Pentester's perspective

www.securing.pl

Summary

• Find endpoints

• Find docs

• Find sample calls

• Find keys

• Fuzz

Page 70: REST API Pentester's perspective

www.securing.plwww.securing.pl

Page 71: REST API Pentester's perspective

www.securing.pl

• SOAP UI https://www.soapui.org/

• Postman https://www.getpostman.com/

• Fuzzapi https://github.com/Fuzzapi/fuzzapi

• Swagger Parser (Burp Suite plugin)

• TruffleHog https://github.com/dxa4481/truffleHog

• JS-Scan https://github.com/zseano/JS-Scan

• Apk – Scan https://apkscan.nviso.be/

Tools

Page 72: REST API Pentester's perspective

www.securing.pl

That’s all folks

[email protected] / @molejarka


Recommended