SlideShare a Scribd company logo
API security: an insider’s point of view
APIDays Paris • 2017/01/30
Jean-Baptiste Aviat
CTO & Co-founder at Sqreen
Former hacker at Apple (Red Team)
jb@sqreen.io
@jbaviat
Who Am I?
What should I do for security?
You MUST do

EVERYTHING, NOW!
You do that, right?
Don’t you?
Api days 2018 - API Security by Sqreen
Just kidding.
Where should I even start?
The OWASP top 10
Web?! WTF I do APIs dude
No worries. This is security sanity.
It works for APIs as well.
•Injection
•Broken authentication
•Sensitive Data Exposure
•XML External Entities (XXE)
•Broken Access Control
•Security Misconfiguration
•Cross Site Scripting (XSS)
•Insecure Deserialisation
•Using components with known vulnerabilities
•Injection
•Broken authentication
•Sensitive Data Exposure
•XML External Entities (XXE)
•Broken Access Control
•Security Misconfiguration
•Cross Site Scripting (XSS)
•Insecure Deserialisation
•Using components with known vulnerabilities
•Injection
•Broken authentication
•Sensitive Data Exposure
•XML External Entities (XXE)
•Broken Access Control
•Security Misconfiguration
•Cross Site Scripting (XSS)
•Insecure Deserialisation
•Using components with known vulnerabilities
•Injection
•Broken authentication
•Sensitive Data Exposure
•XML External Entities (XXE)
•Broken Access Control
•Security Misconfiguration
•Cross Site Scripting (XSS)
•Insecure Deserialisation
•Using components with known vulnerabilities
An HTTP server with a debugger
(byebug) thread list
+ 1 #<Thread:/webrick/server.rb:283 run> ...
2 #<WEBrick::TimeoutHandler::Thread/webrick/utils.rb:162 sleep> ...
3 #<Thread:sleep>/webrick/server.rb:174
(byebug) thread switch 3
[168, 177] in 2.2.0/webrick/server.rb
173: begin
=> 174: if svrs = IO.select([shutdown_pipe[0], *@listeners], …)
175: if svrs[0].include? shutdown_pipe[0]
176: break
At first sight
OWASP: injections
SQL injection vulnerability
•injection vuln = using data in an other context, without proper
preparation









•basically, anything can be retrieved from the database
(byebug) break ActiveRecord::SQLite3Adapter.exec_query
[283, 292] in …/active_record/…/sqlite3_adapter.rb
287:
=> 288: def exec_query(sql, name = nil, …)
[...]
(byebug) var local
[…]
sql = SELECT * FROM posts WHERE id=3
Database access: from the inside
0 ActiveRecord::SQLite3Adapter.exec_query(sql#String, …)
…
7 PostsController.set_post
…
27 ActionController.dispatch(request#ActionDispatch::Request, …)
…
40 ActionDispatch::ParamsParser.call(env#Hash)
…
76 WEBrick::GenericServer.start_thread(sock#TCPSocket, …)
Database access: a closer look
(byebug) var local
[…]
sql = SELECT * FROM posts WHERE id=3 UNION SELECT
password from users
params = { ‘q’ => ‘3 UNION SELECT password from users’}
Database access: from the inside
Take aways
•Injections vulnerabilities lies in your code
•They can be detected at runtime, hooking e.g. SQL drivers
•Ruby on Rails:
ActiveRecord::ConnectionAdapters::AbstractAdapter::log
OWASP: broken authentication
class SessionsController < ApplicationController
def create
user = login(params[:email], params[:password])
JWT.encode(user.email, hmac_secret)
end
end
User authentication
Api days 2018 - API Security by Sqreen
Take aways
•Authentication related vulnerabilities happen (or lies) in the code
•Many can be detected at runtime, hooking authentication
frameworks
•Ruby on Rails:
Devise::Strategies::DatabaseAuthenticatable.authenticate!
OWASP: business vulnerabilities
Stripe::Charge.create(
:amount => 2000,
:currency => "usd",
:description => "Charge for jb@sqreen.io“
)
Payment monitoring
Take aways
•Business vulnerabilities… are triggered in your code!
•Even if you have no vulnerability
•They can be measured during runtime
•And analysed (realtime or not) then
•What to monitor? You know your business!
OWASP: Components with Known Vulnerabilities
irb(main):001:0> Gem.loaded_specs.map do |k, v|
puts "%20st%st%s " % [k, v.version, v.homepage]
end
rake 10.4.2
erubis 2.7.0 http://www.kuwata-lab.com/erubis/
nokogiri 1.6.6.2 http://nokogiri.org
actionview 4.2.3 http://www.rubyonrails.org
sqlite3 1.3.10 https://github.com/sparklemotion/sqlite3-ruby
execjs 2.6.0 https://github.com/rails/execjs
...
CVE-2015-1819
CVE-2015-7941
CVE-2015-7942
CVE-2015-8035
An application
dependencies
Take aways
•Defined in your code - or in your configuration files
anyway
•So important even GitHub does it nowadays
•Runtime allows to check all deployments are fine
Meta take aways (OMG)
•Bug happens
•Some of them are security related
•Be aware of in-code vulnerabilities
•And business vulnerabilities
•It will be on you (you, as an API builder) some day
Questions?
OWASP top 10 2017:
https://www.owasp.org/images/7/72/OWASP_Top_10-2017_%28en%29.pdf.pdf
CTO security checklist:
https://cto-security-checklist.sqreen.io/

More Related Content

PDF
Open source iam value, benefits, and risks
PDF
API Security In Cloud Native Era
PDF
[APIdays INTERFACE 2021] The Evolution of API Security for Client-side Applic...
PDF
Checkmarx meetup API Security - API Security in depth - Inon Shkedy
PPTX
Building better security for your API platform using Azure API Management
PDF
42Crunch Security Audit for WSO2 API Manager 3.1
PDF
Building layers of defense for your application
PDF
[OPD 2019] Threat modeling at scale
Open source iam value, benefits, and risks
API Security In Cloud Native Era
[APIdays INTERFACE 2021] The Evolution of API Security for Client-side Applic...
Checkmarx meetup API Security - API Security in depth - Inon Shkedy
Building better security for your API platform using Azure API Management
42Crunch Security Audit for WSO2 API Manager 3.1
Building layers of defense for your application
[OPD 2019] Threat modeling at scale

What's hot (20)

PDF
API Security: the full story
PPTX
Security in microservices architectures
PPTX
OpenId Connect Protocol
PDF
[OPD 2019] Web Apps vs Blockchain dApps
PDF
OAuth based reference architecture for API Management
PDF
42crunch-API-security-workshop
PDF
Identiverse - Microservices Security
PDF
How WSO2 API Manager Supports the Ministry of Hajj and Umrah
PDF
Better API Security with Automation
PDF
Web security and OWASP
PPTX
RSA Conference 2016: Don't Use Two-Factor Authentication... Unless You Need It!
PDF
Advanced API Security Patterns
PDF
apidays LIVE New York 2021 - Solving API security through holistic obervabili...
PDF
Using a Third Party Key Management System with WSO2 API Manager
PDF
Why upgrade your MFA to Adaptive Authentication?
PDF
Microservices Security: dos and don'ts
PDF
SecDevOps for API Security
PDF
Trust Elevation: Implementing an OAuth2 Infrastructure using OpenID Connect &...
PPTX
apidays LIVE Paris - Principles for API security by Alan Glickenhouse
PDF
OIDF Workshop at Verizon Media -- 9/30/2019 -- OpenID Connect Federation Update
API Security: the full story
Security in microservices architectures
OpenId Connect Protocol
[OPD 2019] Web Apps vs Blockchain dApps
OAuth based reference architecture for API Management
42crunch-API-security-workshop
Identiverse - Microservices Security
How WSO2 API Manager Supports the Ministry of Hajj and Umrah
Better API Security with Automation
Web security and OWASP
RSA Conference 2016: Don't Use Two-Factor Authentication... Unless You Need It!
Advanced API Security Patterns
apidays LIVE New York 2021 - Solving API security through holistic obervabili...
Using a Third Party Key Management System with WSO2 API Manager
Why upgrade your MFA to Adaptive Authentication?
Microservices Security: dos and don'ts
SecDevOps for API Security
Trust Elevation: Implementing an OAuth2 Infrastructure using OpenID Connect &...
apidays LIVE Paris - Principles for API security by Alan Glickenhouse
OIDF Workshop at Verizon Media -- 9/30/2019 -- OpenID Connect Federation Update
Ad

Similar to Api days 2018 - API Security by Sqreen (20)

PDF
Application Security from the Inside - OWASP
PDF
Securing Rails
PPTX
Securing your web applications a pragmatic approach
PDF
owasp_meetup_12_10
PDF
OWASP Top 10 and Securing Rails - Sean Todd - PayNearMe.com
PDF
Rails Security
PDF
APIDays Paris Security Workshop
PDF
Enhancing your Security APIs
ODP
Security on Rails
PPT
Ruby Security
 
PDF
PwnSchool: Exploiting Web APIs
PDF
DevSecCon London 2018: Securing a web app: business security VS the OWASP top 10
PDF
WebApp_to_Container_Security.pdf
PDF
How to code securely: a crash course for non-coders
PDF
Designing Secure APIs
PDF
PDF
RailsConf 2015 - Metasecurity: Beyond Patching Vulnerabilities
PDF
Secure coding presentation Oct 3 2020
PDF
Checkmarx meetup API Security - API Security top 10 - Erez Yalon
PDF
Protecting Your APIs Against Attack & Hijack
Application Security from the Inside - OWASP
Securing Rails
Securing your web applications a pragmatic approach
owasp_meetup_12_10
OWASP Top 10 and Securing Rails - Sean Todd - PayNearMe.com
Rails Security
APIDays Paris Security Workshop
Enhancing your Security APIs
Security on Rails
Ruby Security
 
PwnSchool: Exploiting Web APIs
DevSecCon London 2018: Securing a web app: business security VS the OWASP top 10
WebApp_to_Container_Security.pdf
How to code securely: a crash course for non-coders
Designing Secure APIs
RailsConf 2015 - Metasecurity: Beyond Patching Vulnerabilities
Secure coding presentation Oct 3 2020
Checkmarx meetup API Security - API Security top 10 - Erez Yalon
Protecting Your APIs Against Attack & Hijack
Ad

More from Sqreen (7)

PDF
Protecting against injections at scale
PDF
Serverless security - how to protect what you don't see?
PDF
Writing a Python C extension
PDF
NoSQL Injections in Node.js - The case of MongoDB
PDF
Tune your App Perf (and get fit for summer)
PDF
Instrument Rack to visualize
 Rails requests processing
PDF
Ruby on Rails security in your Continuous Integration
Protecting against injections at scale
Serverless security - how to protect what you don't see?
Writing a Python C extension
NoSQL Injections in Node.js - The case of MongoDB
Tune your App Perf (and get fit for summer)
Instrument Rack to visualize
 Rails requests processing
Ruby on Rails security in your Continuous Integration

Recently uploaded (20)

PPTX
2. Earth - The Living Planet earth and life
PPTX
Introduction to Fisheries Biotechnology_Lesson 1.pptx
PPTX
microscope-Lecturecjchchchchcuvuvhc.pptx
PPTX
Derivatives of integument scales, beaks, horns,.pptx
PDF
SEHH2274 Organic Chemistry Notes 1 Structure and Bonding.pdf
PDF
Biophysics 2.pdffffffffffffffffffffffffff
PDF
VARICELLA VACCINATION: A POTENTIAL STRATEGY FOR PREVENTING MULTIPLE SCLEROSIS
PDF
Unveiling a 36 billion solar mass black hole at the centre of the Cosmic Hors...
PPTX
DRUG THERAPY FOR SHOCK gjjjgfhhhhh.pptx.
PPTX
G5Q1W8 PPT SCIENCE.pptx 2025-2026 GRADE 5
PPTX
INTRODUCTION TO EVS | Concept of sustainability
PPTX
GEN. BIO 1 - CELL TYPES & CELL MODIFICATIONS
PPTX
Comparative Structure of Integument in Vertebrates.pptx
PPTX
The KM-GBF monitoring framework – status & key messages.pptx
PPT
The World of Physical Science, • Labs: Safety Simulation, Measurement Practice
PPTX
Vitamins & Minerals: Complete Guide to Functions, Food Sources, Deficiency Si...
PDF
MIRIDeepImagingSurvey(MIDIS)oftheHubbleUltraDeepField
PPTX
famous lake in india and its disturibution and importance
PDF
AlphaEarth Foundations and the Satellite Embedding dataset
PPT
Chemical bonding and molecular structure
2. Earth - The Living Planet earth and life
Introduction to Fisheries Biotechnology_Lesson 1.pptx
microscope-Lecturecjchchchchcuvuvhc.pptx
Derivatives of integument scales, beaks, horns,.pptx
SEHH2274 Organic Chemistry Notes 1 Structure and Bonding.pdf
Biophysics 2.pdffffffffffffffffffffffffff
VARICELLA VACCINATION: A POTENTIAL STRATEGY FOR PREVENTING MULTIPLE SCLEROSIS
Unveiling a 36 billion solar mass black hole at the centre of the Cosmic Hors...
DRUG THERAPY FOR SHOCK gjjjgfhhhhh.pptx.
G5Q1W8 PPT SCIENCE.pptx 2025-2026 GRADE 5
INTRODUCTION TO EVS | Concept of sustainability
GEN. BIO 1 - CELL TYPES & CELL MODIFICATIONS
Comparative Structure of Integument in Vertebrates.pptx
The KM-GBF monitoring framework – status & key messages.pptx
The World of Physical Science, • Labs: Safety Simulation, Measurement Practice
Vitamins & Minerals: Complete Guide to Functions, Food Sources, Deficiency Si...
MIRIDeepImagingSurvey(MIDIS)oftheHubbleUltraDeepField
famous lake in india and its disturibution and importance
AlphaEarth Foundations and the Satellite Embedding dataset
Chemical bonding and molecular structure

Api days 2018 - API Security by Sqreen