qcon sp 2015 - segurança em apis rest

22
Segurança em APIs REST

Upload: heitor-vital

Post on 29-Jul-2015

124 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: QCon SP 2015 - Segurança em APIs REST

Segurança em APIs REST

Page 2: QCon SP 2015 - Segurança em APIs REST

Heitor Vital

● Áreas de Atuação o Cloud Computing o Segurança Informação o Jogos o Dispositivos Móveis o …

● Acadêmico o MBA FGV o Mestrado UFPE o Graduação UFPE

twitter.com/heitorvital

slideshare.net/HeitorVital

labs.siteblindado.com

Kadu

[email protected]

Page 3: QCon SP 2015 - Segurança em APIs REST

More info: 2014 Global Report on the Cost of Cyber Crime

Stop Looking for the Silver Bullet: Start Thinking Like a Bad Guy

2014 Global Report on the Cost of Cyber Crime

257 Empresas

2.081 Entrevistas

1.717 Incidentes

$7.6M Média prejuízo

10.4% Crescimento Incidentes

Page 4: QCon SP 2015 - Segurança em APIs REST
Page 5: QCon SP 2015 - Segurança em APIs REST
Page 6: QCon SP 2015 - Segurança em APIs REST
Page 7: QCon SP 2015 - Segurança em APIs REST

Fonte: http://cloudtweaks.com/2013/10/cloud-infographic-2013-cyber-security-intelligence-index/

Page 8: QCon SP 2015 - Segurança em APIs REST

Attack Vector by Organizational Size

TOPs

1. Web-based attacks 2. Denial of services 3. Malicious insiders

Page 9: QCon SP 2015 - Segurança em APIs REST

Site vs Plataforma

Page 10: QCon SP 2015 - Segurança em APIs REST

Let’s [try to] attack ...

Page 11: QCon SP 2015 - Segurança em APIs REST

Search Surface Detection● Metadata/Doc

o Swagger o RAML o API-Blueprint o I/O Docs

● Discovery ● Brute Force

o Invalid dataExemplo: http://petstore.swagger.io/#!/pet/updatePet(type, size, length, null, HTTP header, XML bomb, upload file...)

Page 12: QCon SP 2015 - Segurança em APIs REST

Protocolo - HTTP

Page 14: QCon SP 2015 - Segurança em APIs REST

Authentication/Authorization

API Keys

Abstract OAuth 2.0 flow

Page 15: QCon SP 2015 - Segurança em APIs REST

Assessments

Page 16: QCon SP 2015 - Segurança em APIs REST

InjectionNormal http://petstore.com/api/v1/pet/123 “SELECT  *  FROM  pets  WHERE  petID='”  +  petId  +”‘”;  “SELECT  *  FROM  pets  WHERE  petID  =  ‘123’”  

Injection http://petstore.com/api/v1/pet/’%20or%20’1’=’1  “SELECT  *  FROM  pets  WHERE  petID='”  +  petId  +”‘”;  SELECT  *  FROM  pets  WHERE  petID  =  ‘’  or  ‘1’  =  ‘1’

Page 17: QCon SP 2015 - Segurança em APIs REST

XSS (cross site scripting)

Solução Header response com

● Content-type: application/json ● x-content-type-options: nosniff

Referencias: http://www.w2spconf.com/2013/papers/s3p1.pdf http://stackoverflow.com/questions/3146324/is-it-possible-to-xss-exploit-json-responses-with-proper-javascript-string-escap http://security.stackexchange.com/questions/42093/xss-prevention-for-restful-services

Page 18: QCon SP 2015 - Segurança em APIs REST

CSRF (cross site request forgery)

Referências: http://www.twobotechnologies.com/blog/2014/02/importance-of-state-in-oauth2.html e http://hasselba.ch/blog/?p=1854

Solução OAuth state

Page 19: QCon SP 2015 - Segurança em APIs REST

DoS/DDoS

WAF ● Package Analysis ● IP Blacklist ● Region Blacklist

API Gateway ● Call quotas

o Calendar Period o Rolling Window

● Invalid Inputs o XML Schema o Blacklist Keywords o Blacklist patterns o Malformed messages

Page 20: QCon SP 2015 - Segurança em APIs REST
Page 21: QCon SP 2015 - Segurança em APIs REST

Plataforma Separation of Concerns

● Authentication / Authorization

● Logging ● Analytics ● Audit ● Rate Limit ● Payload ● Address Restrictions ● Invalid Inputs

o XML Schema o Blacklist Keywords o Blacklist patterns o Malformed messages

Page 22: QCon SP 2015 - Segurança em APIs REST

Heitor Vital

OBRIGADO !!!

twitter.com/heitorvital

slideshare.net/HeitorVital

labs.siteblindado.com

Kadu

[email protected]