SlideShare a Scribd company logo
Secure by Design Microservices & Integrations
Ayoma Wijethunga
Associate Technical Lead, WSO2
OWASP Top 10 Application Security Risks SANS TOP 25 Most Dangerous Software Errors
A1:2017 - Injection
Improper Neutralization of Special Elements used in an SQL
Command ('SQL Injection')
A2:2017 - Broken Authentication
Improper Neutralization of Special Elements used in an OS
Command ('OS Command Injection')
A3:2017 - Sensitive Data Exposure
Improper Neutralization of Input During Web Page Generation
('Cross-site Scripting')
A4:2017 - XML External Entities (XXE) Unrestricted Upload of File with Dangerous Type
A5:2017 - Broken Access Control Cross-Site Request Forgery (CSRF)
A6:2017 - Security Misconfiguration URL Redirection to Untrusted Site ('Open Redirect')
A7:2017 - Cross-Site Scripting (XSS)
Buffer Copy without Checking Size of Input ('Classic Buffer
Overflow')
A8:2017 - Insecure Deserialization
Improper Limitation of a Pathname to a Restricted Directory
('Path Traversal')
A9:2017 - Using Components with Known
Vulnerabilities
Download of Code Without Integrity Check
A10:2017 - Insufficient Logging & Monitoring Inclusion of Functionality from Untrusted Control Sphere
Use of Potentially Dangerous Function
Incorrect Calculation of Buffer Size
Uncontrolled Format String
… 12 more to go
Multitude of Application Security Risks & Growing
Security @ WSO2 - 1000 Foot View
* https://wso2.com/technical-reports/wso2-secure-engineering-guidelines
Security with Code &
Design Reviews
Static Code
Analysis
Dynamic Security
Analysis
IDE & Build Level
Checks
Secure Engineering
Guidelines *
Security @ WSO2 - Pain Points
○ Multiple iterations of checks to identify security mistakes
○ Finding an issue towards the end of the process is costly
○ False positives
○ Suppression & vulnerability management
○ WSO2 uses DefectDojo (customized)
Making Ballerina security-aware
○ Make language compiler aware of security risks
○ Detect and prevent unintentional security mistakes
○ Essential security features built-in to the language
Security Vulnerability Prevention
Taint Analysis
Every Function Has Security
Information Attached
public native function select
(@sensitive string sqlQuery,
typedesc? recordType,
boolean loadToMemory = false,
Param... parameters)
returns @tainted table|error;
@sensitive [parameter]
Security Sensitive Parameters
(Passing untrusted data to the
parameter can lead to a security risk)
returns @tainted
Returns Untrusted Data
Signature is derived
if not explicitly mentioned.
public native function read
(@sensitive int numberOfChars)
returns @tainted string|error;
public function execute
(@sensitive string httpVerb,
@sensitive string path,
Request|string|xml|json|byte[]
|io:ByteChannel|mime:Entity[]|()
message)
returns Response|error;
public native function getHeaders
(@sensitive string headerName)
returns @tainted string[];
ballerina/sql
ballerina/io
ballerina/http
ballerina/mime
Derived Security Information public native function select
(@sensitive string sqlQuery,
typedesc? recordType,
boolean loadToMemory = false,
Param... parameters)
returns @tainted table|error;
baseSqlQuery and sortColumn
derived to be "security sensitive"
public function sortedSelect (string
baseSqlQuery, string sortColumn)
returns table|error {
return dbclient->select(baseSqlQuery
+ " ORDER BY " + sortColumn, ());
}
Language Compiler
Performs Taint Analysis
Ballerina Compiler
Taint Analyze
Code Analyze
Code Generation
Desugar
Type Check
Compiler Plugin
Ballerina can:
Segregating untrusted
data from trusted data
Ballerina knows:
Security sensitive areas
Ballerina can:
Accurately propagate
tainted state across the
program
Evolves with the
language
SQL Injection Prevention
Demo
sql:Parameter param_id = { sqlType:
sql:TYPE_INTEGER, value: params.id };
var selectRet = testDB->select
("SELECT * FROM student WHERE id = ?", (),
param_id);
match selectRet {
table tableReturned => {
if (td.hasNext()) {
res.setPayload("Found!");
} else {
res.setPayload("Not Found!");
}
td.close();
}
error err => throw err;
}
var params = req.getQueryParams();
var selectRet = testDB->select
("SELECT * FROM student WHERE id = "
+ params.id, ());
match selectRet {
table tableReturned => {
if (td.hasNext()) {
res.setPayload("Found!");
} else {
res.setPayload("Not Found!");
}
td.close();
}
error err => throw err;
}
Correct Approach:
error: ./sqli_fail.bal:23:40: tainted value passed to
sensitive parameter 'sqlQuery'
Cross Site Scripting (XSS)
Prevention Demo
import ballerina/http;
string regex = "[a-zA-Z]+";
service<http:Service> hello bind {port: 9090} {
sayHello(endpoint c, http:Request req) {
http:Response res = new;
var params = req.getQueryParams();
if (check params.name.matches(regex)) {
res.setPayload("Hello, "
+ untaint params.name + "!");
} else {
res.setPayload("Name contains
invalid data!");
}
_ = c->respond(res);
}
}
import ballerina/http;
service<http:Service> hello bind {port: 9090} {
sayHello(endpoint c, http:Request req) {
var params = req.getQueryParams();
_ = c->respond("Hello, " + params.name
);
}
}
error: ./http_fail.bal:9:25: tainted value passed to
sensitive parameter 'message'
Correct Approach:
Security Vulnerability Prevention
Secure Defaults
XML External Entity Injection
(XXE) Prevention Demo
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [
<!ELEMENT foo ANY >
<!ENTITY xxe SYSTEM "file:///etc/passwd">
]>
<foo>&xxe;</foo>
This XML will expose the content
of /etc/passwd file.
XML Entity Expansion
Prevention
<?xml version="1.0"?>
<!DOCTYPE lolz [
<!ENTITY lol "lol">
<!ENTITY lol2 "&lol;&lol;&lol;&lol;&lol;&lol;">
<!ENTITY lol3 "&lol2;&lol2;&lol2;&lol2;&lol2;">
<!ENTITY lol4 "&lol3;&lol3;&lol3;&lol3;&lol3;">
<!ENTITY lol5 "&lol4;&lol4;&lol4;&lol4;&lol4;">
<!ENTITY lol6 "&lol5;&lol5;&lol5;&lol5;&lol5;">
<!ENTITY lol7 "&lol6;&lol6;&lol6;&lol6;&lol6;">
<!ENTITY lol8 "&lol7;&lol7;&lol7;&lol7;&lol7;">
<!ENTITY lol9 "&lol8;&lol8;&lol8;&lol8;&lol8;">
]>
<lolz>&lol9;</lolz>
Parsing the XML will result in DoS
attack, since parser will expand all
the entities.
Securing Microservices
Built-in Security Features
Built-in Security Features
○ OCSP validation for SSL/TLS certificates
○ CRL validation for SSL/TLS certificates
○ Config API reading encrypted passwords or secrets
○ Cryptographic operations
○ Authentication and authorization for services
Securing Microservices
Authentication & Authorization
Inbound Authentication & Authorization
Authentication
Filter
Authorization
Filter
Authentication
Provider
Resource
Request
Basic Auth
OAuth
JWT
Certificate
Response
HTTP JMS
Config File
LDAP
AD
DB
User Storage
Inbound Authentication
& Authorization - Basic Auth import ballerina/http;
endpoint http:SecureListener ep {
port:9090
};
@http:ServiceConfig {
basePath: "/hello",
authConfig: { scopes: [ "hello" ] }
}
service<http:Service> helloWorld bind ep {
@http:ResourceConfig {
methods: [ "GET" ],
path: "/"
}
sayHello (endpoint c, http:Request r) {
_ = c -> respond("Hello!");
}
}
http:AuthProvider configured to
use "config" file as the user store.
Endpoint is configured to use the
http:AuthProvider
@http:ServiceConfig is configured
to authorize users with scope
"hello"
Inbound Authentication
& Authorization - JWT Auth
http:AuthProvider jwtAuthProvider = {
scheme: "jwt",
issuer: "ballerina",
audience: "ballerina.io",
clockSkew: 10,
certificateAlias: "ballerina",
trustStore: {
path: "/home/ops/truststore.p12",
password: "t4C3F5WrFbQn6h4S"
}
};
endpoint http:SecureListener ep {
port:9090,
authProviders: [ jwtAuthProvider ]
};
http:AuthProvider configured to
use enforce authentication using
"jwt" scheme.
Outbound Authentication endpoint http:Client downstreamServiceEP {
url: "https://localhost:9092",
auth: { scheme: http:JWT_AUTH },
};
endpoint http:Client downstreamServiceEP {
url: "https://localhost:9092",
auth: {
scheme: http:OAUTH2,
accessToken: "34060588",
refreshToken: "15160398",
refreshUrl: "https://ballerina.io/ref"
clientId: "rgfKVdnMQnJSSr",
clientSecret: "BRebJ0aqfclQB9"
},
}
endpoint http:Client downstreamServiceEP {
url: "https://localhost:9092",
auth: {
scheme: http:BASIC_AUTH,
username: "downstreamServiceUser",
password: "QK1eIWH5d6UaZXA3"
}
Client endpoint can be configured
with the desired authentication
scheme.
JWT Authentication
OAuth2 Authentication
Basic Authentication
Summary
○ Taint Analysis
○ Secure Defaults
○ Security Features
○ Authentication and Authorization
"How to Write Secure Ballerina Programs"
https://ballerina.io/learn/how-to-write-secure-ballerina-code

More Related Content

What's hot

Sql Injection Myths and Fallacies
Sql Injection Myths and FallaciesSql Injection Myths and Fallacies
Sql Injection Myths and Fallacies
Karwin Software Solutions LLC
 
RSA Europe 2013 OWASP Training
RSA Europe 2013 OWASP TrainingRSA Europe 2013 OWASP Training
RSA Europe 2013 OWASP Training
Jim Manico
 
Sql injection
Sql injectionSql injection
Sql injection
Nikunj Dhameliya
 
SQL Injection
SQL Injection SQL Injection
SQL Injection
Adhoura Academy
 
Sql Injection Attacks Siddhesh
Sql Injection Attacks SiddheshSql Injection Attacks Siddhesh
Sql Injection Attacks Siddhesh
Siddhesh Bhobe
 
SQL Injection Defense in Python
SQL Injection Defense in PythonSQL Injection Defense in Python
SQL Injection Defense in Python
Public Broadcasting Service
 
2013 OWASP Top 10
2013 OWASP Top 102013 OWASP Top 10
2013 OWASP Top 10
bilcorry
 
Advanced SQL Injection: Attacks
Advanced SQL Injection: Attacks Advanced SQL Injection: Attacks
Advanced SQL Injection: Attacks
Nuno Loureiro
 
Sql Injection and XSS
Sql Injection and XSSSql Injection and XSS
Sql Injection and XSS
Mike Crabb
 
Sql Injection - Vulnerability and Security
Sql Injection - Vulnerability and SecuritySql Injection - Vulnerability and Security
Sql Injection - Vulnerability and Security
Sandip Chaudhari
 
Owasp Top 10 - A1 Injection
Owasp Top 10 - A1 InjectionOwasp Top 10 - A1 Injection
Owasp Top 10 - A1 Injection
Paul Ionescu
 
C days2015
C days2015C days2015
C days2015
Nuno Loureiro
 
SQL and XPATH Injection with Fusion Lite Insight
SQL and XPATH Injection with Fusion Lite InsightSQL and XPATH Injection with Fusion Lite Insight
SQL and XPATH Injection with Fusion Lite Insight
iAppSecure Solutions
 
Prevoty NYC Java SIG 20150730
Prevoty NYC Java SIG 20150730Prevoty NYC Java SIG 20150730
Prevoty NYC Java SIG 20150730
chadtindel
 
Web application attacks using Sql injection and countermasures
Web application attacks using Sql injection and countermasuresWeb application attacks using Sql injection and countermasures
Web application attacks using Sql injection and countermasures
Cade Zvavanjanja
 
SQL Injection: complete walkthrough (not only) for PHP developers
SQL Injection: complete walkthrough (not only) for PHP developersSQL Injection: complete walkthrough (not only) for PHP developers
SQL Injection: complete walkthrough (not only) for PHP developers
Krzysztof Kotowicz
 
Owasp top 10 2013
Owasp top 10 2013Owasp top 10 2013
Owasp top 10 2013
Edouard de Lansalut
 
20160225 OWASP Atlanta Prevoty RASP
20160225 OWASP Atlanta Prevoty RASP20160225 OWASP Atlanta Prevoty RASP
20160225 OWASP Atlanta Prevoty RASP
chadtindel
 
Writing Secure Code – Threat Defense
Writing Secure Code – Threat DefenseWriting Secure Code – Threat Defense
Writing Secure Code – Threat Defense
amiable_indian
 

What's hot (20)

Sql Injection Myths and Fallacies
Sql Injection Myths and FallaciesSql Injection Myths and Fallacies
Sql Injection Myths and Fallacies
 
RSA Europe 2013 OWASP Training
RSA Europe 2013 OWASP TrainingRSA Europe 2013 OWASP Training
RSA Europe 2013 OWASP Training
 
Sql injection
Sql injectionSql injection
Sql injection
 
SQL Injection
SQL Injection SQL Injection
SQL Injection
 
Sql Injection Attacks Siddhesh
Sql Injection Attacks SiddheshSql Injection Attacks Siddhesh
Sql Injection Attacks Siddhesh
 
SQL Injection Defense in Python
SQL Injection Defense in PythonSQL Injection Defense in Python
SQL Injection Defense in Python
 
2013 OWASP Top 10
2013 OWASP Top 102013 OWASP Top 10
2013 OWASP Top 10
 
Sql injection
Sql injectionSql injection
Sql injection
 
Advanced SQL Injection: Attacks
Advanced SQL Injection: Attacks Advanced SQL Injection: Attacks
Advanced SQL Injection: Attacks
 
Sql Injection and XSS
Sql Injection and XSSSql Injection and XSS
Sql Injection and XSS
 
Sql Injection - Vulnerability and Security
Sql Injection - Vulnerability and SecuritySql Injection - Vulnerability and Security
Sql Injection - Vulnerability and Security
 
Owasp Top 10 - A1 Injection
Owasp Top 10 - A1 InjectionOwasp Top 10 - A1 Injection
Owasp Top 10 - A1 Injection
 
C days2015
C days2015C days2015
C days2015
 
SQL and XPATH Injection with Fusion Lite Insight
SQL and XPATH Injection with Fusion Lite InsightSQL and XPATH Injection with Fusion Lite Insight
SQL and XPATH Injection with Fusion Lite Insight
 
Prevoty NYC Java SIG 20150730
Prevoty NYC Java SIG 20150730Prevoty NYC Java SIG 20150730
Prevoty NYC Java SIG 20150730
 
Web application attacks using Sql injection and countermasures
Web application attacks using Sql injection and countermasuresWeb application attacks using Sql injection and countermasures
Web application attacks using Sql injection and countermasures
 
SQL Injection: complete walkthrough (not only) for PHP developers
SQL Injection: complete walkthrough (not only) for PHP developersSQL Injection: complete walkthrough (not only) for PHP developers
SQL Injection: complete walkthrough (not only) for PHP developers
 
Owasp top 10 2013
Owasp top 10 2013Owasp top 10 2013
Owasp top 10 2013
 
20160225 OWASP Atlanta Prevoty RASP
20160225 OWASP Atlanta Prevoty RASP20160225 OWASP Atlanta Prevoty RASP
20160225 OWASP Atlanta Prevoty RASP
 
Writing Secure Code – Threat Defense
Writing Secure Code – Threat DefenseWriting Secure Code – Threat Defense
Writing Secure Code – Threat Defense
 

Similar to Secure by Design Microservices & Integrations

PCI Security Requirements - secure coding
PCI Security Requirements - secure codingPCI Security Requirements - secure coding
PCI Security Requirements - secure codingHaitham Raik
 
Secure Software Development Lifecycle - Devoxx MA 2018
Secure Software Development Lifecycle - Devoxx MA 2018Secure Software Development Lifecycle - Devoxx MA 2018
Secure Software Development Lifecycle - Devoxx MA 2018
Imola Informatica
 
Secure code
Secure codeSecure code
Secure code
ddeogun
 
OWASP Top 10 And Insecure Software Root Causes
OWASP Top 10 And Insecure Software Root CausesOWASP Top 10 And Insecure Software Root Causes
OWASP Top 10 And Insecure Software Root CausesMarco Morana
 
Web API Security
Web API SecurityWeb API Security
Web API Security
Stefaan
 
Application and Website Security -- Fundamental Edition
Application and Website Security -- Fundamental EditionApplication and Website Security -- Fundamental Edition
Application and Website Security -- Fundamental Edition
Daniel Owens
 
The top 10 security issues in web applications
The top 10 security issues in web applicationsThe top 10 security issues in web applications
The top 10 security issues in web applications
Devnology
 
Securing Java EE Web Apps
Securing Java EE Web AppsSecuring Java EE Web Apps
Securing Java EE Web AppsFrank Kim
 
Mobile Application Pentest [Fast-Track]
Mobile Application Pentest [Fast-Track]Mobile Application Pentest [Fast-Track]
Mobile Application Pentest [Fast-Track]Prathan Phongthiproek
 
OWASP Portland - OWASP Top 10 For JavaScript Developers
OWASP Portland - OWASP Top 10 For JavaScript DevelopersOWASP Portland - OWASP Top 10 For JavaScript Developers
OWASP Portland - OWASP Top 10 For JavaScript Developers
Lewis Ardern
 
ASP.NET Web Security
ASP.NET Web SecurityASP.NET Web Security
ASP.NET Web Security
SharePointRadi
 
Php Security By Mugdha And Anish
Php Security By Mugdha And AnishPhp Security By Mugdha And Anish
Php Security By Mugdha And Anish
OSSCube
 
Owasp top 10_openwest_2019
Owasp top 10_openwest_2019Owasp top 10_openwest_2019
Owasp top 10_openwest_2019
Sean Jackson
 
Eight simple rules to writing secure PHP programs
Eight simple rules to writing secure PHP programsEight simple rules to writing secure PHP programs
Eight simple rules to writing secure PHP programsAleksandr Yampolskiy
 
Cm8 secure code_training_1day_security libraries
Cm8 secure code_training_1day_security librariesCm8 secure code_training_1day_security libraries
Cm8 secure code_training_1day_security libraries
dcervigni
 
Security hole #5 application security science or quality assurance
Security hole #5 application security   science or quality assuranceSecurity hole #5 application security   science or quality assurance
Security hole #5 application security science or quality assuranceTjylen Veselyj
 
Top Ten Java Defense for Web Applications v2
Top Ten Java Defense for Web Applications v2Top Ten Java Defense for Web Applications v2
Top Ten Java Defense for Web Applications v2
Jim Manico
 
Web Application Security - Folio3
Web Application Security - Folio3Web Application Security - Folio3
Web Application Security - Folio3
Folio3 Software
 
OWASP_Top_Ten_Proactive_Controls_v2.pptx
OWASP_Top_Ten_Proactive_Controls_v2.pptxOWASP_Top_Ten_Proactive_Controls_v2.pptx
OWASP_Top_Ten_Proactive_Controls_v2.pptx
azida3
 

Similar to Secure by Design Microservices & Integrations (20)

PCI Security Requirements - secure coding
PCI Security Requirements - secure codingPCI Security Requirements - secure coding
PCI Security Requirements - secure coding
 
Secure Software Development Lifecycle - Devoxx MA 2018
Secure Software Development Lifecycle - Devoxx MA 2018Secure Software Development Lifecycle - Devoxx MA 2018
Secure Software Development Lifecycle - Devoxx MA 2018
 
Secure code
Secure codeSecure code
Secure code
 
OWASP Top 10 And Insecure Software Root Causes
OWASP Top 10 And Insecure Software Root CausesOWASP Top 10 And Insecure Software Root Causes
OWASP Top 10 And Insecure Software Root Causes
 
Web API Security
Web API SecurityWeb API Security
Web API Security
 
Application and Website Security -- Fundamental Edition
Application and Website Security -- Fundamental EditionApplication and Website Security -- Fundamental Edition
Application and Website Security -- Fundamental Edition
 
The top 10 security issues in web applications
The top 10 security issues in web applicationsThe top 10 security issues in web applications
The top 10 security issues in web applications
 
Securing Java EE Web Apps
Securing Java EE Web AppsSecuring Java EE Web Apps
Securing Java EE Web Apps
 
Mobile Application Pentest [Fast-Track]
Mobile Application Pentest [Fast-Track]Mobile Application Pentest [Fast-Track]
Mobile Application Pentest [Fast-Track]
 
OWASP Portland - OWASP Top 10 For JavaScript Developers
OWASP Portland - OWASP Top 10 For JavaScript DevelopersOWASP Portland - OWASP Top 10 For JavaScript Developers
OWASP Portland - OWASP Top 10 For JavaScript Developers
 
ASP.NET Web Security
ASP.NET Web SecurityASP.NET Web Security
ASP.NET Web Security
 
Php Security By Mugdha And Anish
Php Security By Mugdha And AnishPhp Security By Mugdha And Anish
Php Security By Mugdha And Anish
 
Owasp top 10_openwest_2019
Owasp top 10_openwest_2019Owasp top 10_openwest_2019
Owasp top 10_openwest_2019
 
Eight simple rules to writing secure PHP programs
Eight simple rules to writing secure PHP programsEight simple rules to writing secure PHP programs
Eight simple rules to writing secure PHP programs
 
Starwest 2008
Starwest 2008Starwest 2008
Starwest 2008
 
Cm8 secure code_training_1day_security libraries
Cm8 secure code_training_1day_security librariesCm8 secure code_training_1day_security libraries
Cm8 secure code_training_1day_security libraries
 
Security hole #5 application security science or quality assurance
Security hole #5 application security   science or quality assuranceSecurity hole #5 application security   science or quality assurance
Security hole #5 application security science or quality assurance
 
Top Ten Java Defense for Web Applications v2
Top Ten Java Defense for Web Applications v2Top Ten Java Defense for Web Applications v2
Top Ten Java Defense for Web Applications v2
 
Web Application Security - Folio3
Web Application Security - Folio3Web Application Security - Folio3
Web Application Security - Folio3
 
OWASP_Top_Ten_Proactive_Controls_v2.pptx
OWASP_Top_Ten_Proactive_Controls_v2.pptxOWASP_Top_Ten_Proactive_Controls_v2.pptx
OWASP_Top_Ten_Proactive_Controls_v2.pptx
 

More from Ballerina

Role of Integration and Service Mesh in Cloud Native Architecture KubeCon 2108
Role of Integration and Service Mesh in Cloud Native Architecture KubeCon 2108Role of Integration and Service Mesh in Cloud Native Architecture KubeCon 2108
Role of Integration and Service Mesh in Cloud Native Architecture KubeCon 2108
Ballerina
 
Ballerina in the Real World: Motorola_KubeCon 2018
Ballerina in the Real World: Motorola_KubeCon 2018Ballerina in the Real World: Motorola_KubeCon 2018
Ballerina in the Real World: Motorola_KubeCon 2018
Ballerina
 
Ballerina integration with Azure cloud services_KubeCon 2018
Ballerina integration with Azure cloud services_KubeCon 2018Ballerina integration with Azure cloud services_KubeCon 2018
Ballerina integration with Azure cloud services_KubeCon 2018
Ballerina
 
Ballerina is not Java_KubeCon 2108
Ballerina is not Java_KubeCon 2108Ballerina is not Java_KubeCon 2108
Ballerina is not Java_KubeCon 2108
Ballerina
 
Microservice Integration from Dev to Production_KubeCon2018
Microservice Integration from Dev to Production_KubeCon2018Microservice Integration from Dev to Production_KubeCon2018
Microservice Integration from Dev to Production_KubeCon2018
Ballerina
 
Building a Microgateway in Ballerina_KubeCon 2108
Building a Microgateway in Ballerina_KubeCon 2108Building a Microgateway in Ballerina_KubeCon 2108
Building a Microgateway in Ballerina_KubeCon 2108
Ballerina
 
Ballerina ecosystem
Ballerina ecosystemBallerina ecosystem
Ballerina ecosystem
Ballerina
 
Orchestrating microservices with docker and kubernetes
Orchestrating microservices with docker and kubernetesOrchestrating microservices with docker and kubernetes
Orchestrating microservices with docker and kubernetes
Ballerina
 
Data integration
Data integrationData integration
Data integration
Ballerina
 
Service resiliency in microservices
Service resiliency in microservicesService resiliency in microservices
Service resiliency in microservices
Ballerina
 
Microservices integration
Microservices integration   Microservices integration
Microservices integration
Ballerina
 
Writing microservices
Writing microservicesWriting microservices
Writing microservices
Ballerina
 
Ballerina philosophy
Ballerina philosophy Ballerina philosophy
Ballerina philosophy
Ballerina
 
Ballerina: Cloud Native Programming Language
Ballerina: Cloud Native Programming Language Ballerina: Cloud Native Programming Language
Ballerina: Cloud Native Programming Language
Ballerina
 
Writing services in Ballerina_Ballerina Day CMB 2018
Writing services in Ballerina_Ballerina Day CMB 2018Writing services in Ballerina_Ballerina Day CMB 2018
Writing services in Ballerina_Ballerina Day CMB 2018
Ballerina
 
Resiliency & Security_Ballerina Day CMB 2018
Resiliency & Security_Ballerina Day CMB 2018  Resiliency & Security_Ballerina Day CMB 2018
Resiliency & Security_Ballerina Day CMB 2018
Ballerina
 
Stream Processing with Ballerina
Stream Processing with BallerinaStream Processing with Ballerina
Stream Processing with Ballerina
Ballerina
 
Observability with Ballerina
Observability with BallerinaObservability with Ballerina
Observability with Ballerina
Ballerina
 
Serverless Ballerina
Serverless BallerinaServerless Ballerina
Serverless Ballerina
Ballerina
 
Test Driven Development for Microservices
Test Driven Development for MicroservicesTest Driven Development for Microservices
Test Driven Development for Microservices
Ballerina
 

More from Ballerina (20)

Role of Integration and Service Mesh in Cloud Native Architecture KubeCon 2108
Role of Integration and Service Mesh in Cloud Native Architecture KubeCon 2108Role of Integration and Service Mesh in Cloud Native Architecture KubeCon 2108
Role of Integration and Service Mesh in Cloud Native Architecture KubeCon 2108
 
Ballerina in the Real World: Motorola_KubeCon 2018
Ballerina in the Real World: Motorola_KubeCon 2018Ballerina in the Real World: Motorola_KubeCon 2018
Ballerina in the Real World: Motorola_KubeCon 2018
 
Ballerina integration with Azure cloud services_KubeCon 2018
Ballerina integration with Azure cloud services_KubeCon 2018Ballerina integration with Azure cloud services_KubeCon 2018
Ballerina integration with Azure cloud services_KubeCon 2018
 
Ballerina is not Java_KubeCon 2108
Ballerina is not Java_KubeCon 2108Ballerina is not Java_KubeCon 2108
Ballerina is not Java_KubeCon 2108
 
Microservice Integration from Dev to Production_KubeCon2018
Microservice Integration from Dev to Production_KubeCon2018Microservice Integration from Dev to Production_KubeCon2018
Microservice Integration from Dev to Production_KubeCon2018
 
Building a Microgateway in Ballerina_KubeCon 2108
Building a Microgateway in Ballerina_KubeCon 2108Building a Microgateway in Ballerina_KubeCon 2108
Building a Microgateway in Ballerina_KubeCon 2108
 
Ballerina ecosystem
Ballerina ecosystemBallerina ecosystem
Ballerina ecosystem
 
Orchestrating microservices with docker and kubernetes
Orchestrating microservices with docker and kubernetesOrchestrating microservices with docker and kubernetes
Orchestrating microservices with docker and kubernetes
 
Data integration
Data integrationData integration
Data integration
 
Service resiliency in microservices
Service resiliency in microservicesService resiliency in microservices
Service resiliency in microservices
 
Microservices integration
Microservices integration   Microservices integration
Microservices integration
 
Writing microservices
Writing microservicesWriting microservices
Writing microservices
 
Ballerina philosophy
Ballerina philosophy Ballerina philosophy
Ballerina philosophy
 
Ballerina: Cloud Native Programming Language
Ballerina: Cloud Native Programming Language Ballerina: Cloud Native Programming Language
Ballerina: Cloud Native Programming Language
 
Writing services in Ballerina_Ballerina Day CMB 2018
Writing services in Ballerina_Ballerina Day CMB 2018Writing services in Ballerina_Ballerina Day CMB 2018
Writing services in Ballerina_Ballerina Day CMB 2018
 
Resiliency & Security_Ballerina Day CMB 2018
Resiliency & Security_Ballerina Day CMB 2018  Resiliency & Security_Ballerina Day CMB 2018
Resiliency & Security_Ballerina Day CMB 2018
 
Stream Processing with Ballerina
Stream Processing with BallerinaStream Processing with Ballerina
Stream Processing with Ballerina
 
Observability with Ballerina
Observability with BallerinaObservability with Ballerina
Observability with Ballerina
 
Serverless Ballerina
Serverless BallerinaServerless Ballerina
Serverless Ballerina
 
Test Driven Development for Microservices
Test Driven Development for MicroservicesTest Driven Development for Microservices
Test Driven Development for Microservices
 

Recently uploaded

Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
lorraineandreiamcidl
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
Hornet Dynamics
 
Launch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in MinutesLaunch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in Minutes
Roshan Dwivedi
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
Deuglo Infosystem Pvt Ltd
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
TheSMSPoint
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
Alina Yurenko
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 

Recently uploaded (20)

Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
 
Launch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in MinutesLaunch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in Minutes
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 

Secure by Design Microservices & Integrations

  • 1. Secure by Design Microservices & Integrations Ayoma Wijethunga Associate Technical Lead, WSO2
  • 2. OWASP Top 10 Application Security Risks SANS TOP 25 Most Dangerous Software Errors A1:2017 - Injection Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') A2:2017 - Broken Authentication Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection') A3:2017 - Sensitive Data Exposure Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') A4:2017 - XML External Entities (XXE) Unrestricted Upload of File with Dangerous Type A5:2017 - Broken Access Control Cross-Site Request Forgery (CSRF) A6:2017 - Security Misconfiguration URL Redirection to Untrusted Site ('Open Redirect') A7:2017 - Cross-Site Scripting (XSS) Buffer Copy without Checking Size of Input ('Classic Buffer Overflow') A8:2017 - Insecure Deserialization Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') A9:2017 - Using Components with Known Vulnerabilities Download of Code Without Integrity Check A10:2017 - Insufficient Logging & Monitoring Inclusion of Functionality from Untrusted Control Sphere Use of Potentially Dangerous Function Incorrect Calculation of Buffer Size Uncontrolled Format String … 12 more to go Multitude of Application Security Risks & Growing
  • 3. Security @ WSO2 - 1000 Foot View * https://wso2.com/technical-reports/wso2-secure-engineering-guidelines Security with Code & Design Reviews Static Code Analysis Dynamic Security Analysis IDE & Build Level Checks Secure Engineering Guidelines *
  • 4. Security @ WSO2 - Pain Points ○ Multiple iterations of checks to identify security mistakes ○ Finding an issue towards the end of the process is costly ○ False positives ○ Suppression & vulnerability management ○ WSO2 uses DefectDojo (customized)
  • 5. Making Ballerina security-aware ○ Make language compiler aware of security risks ○ Detect and prevent unintentional security mistakes ○ Essential security features built-in to the language
  • 7. Every Function Has Security Information Attached public native function select (@sensitive string sqlQuery, typedesc? recordType, boolean loadToMemory = false, Param... parameters) returns @tainted table|error; @sensitive [parameter] Security Sensitive Parameters (Passing untrusted data to the parameter can lead to a security risk) returns @tainted Returns Untrusted Data Signature is derived if not explicitly mentioned. public native function read (@sensitive int numberOfChars) returns @tainted string|error; public function execute (@sensitive string httpVerb, @sensitive string path, Request|string|xml|json|byte[] |io:ByteChannel|mime:Entity[]|() message) returns Response|error; public native function getHeaders (@sensitive string headerName) returns @tainted string[]; ballerina/sql ballerina/io ballerina/http ballerina/mime
  • 8. Derived Security Information public native function select (@sensitive string sqlQuery, typedesc? recordType, boolean loadToMemory = false, Param... parameters) returns @tainted table|error; baseSqlQuery and sortColumn derived to be "security sensitive" public function sortedSelect (string baseSqlQuery, string sortColumn) returns table|error { return dbclient->select(baseSqlQuery + " ORDER BY " + sortColumn, ()); }
  • 9. Language Compiler Performs Taint Analysis Ballerina Compiler Taint Analyze Code Analyze Code Generation Desugar Type Check Compiler Plugin Ballerina can: Segregating untrusted data from trusted data Ballerina knows: Security sensitive areas Ballerina can: Accurately propagate tainted state across the program Evolves with the language
  • 10. SQL Injection Prevention Demo sql:Parameter param_id = { sqlType: sql:TYPE_INTEGER, value: params.id }; var selectRet = testDB->select ("SELECT * FROM student WHERE id = ?", (), param_id); match selectRet { table tableReturned => { if (td.hasNext()) { res.setPayload("Found!"); } else { res.setPayload("Not Found!"); } td.close(); } error err => throw err; } var params = req.getQueryParams(); var selectRet = testDB->select ("SELECT * FROM student WHERE id = " + params.id, ()); match selectRet { table tableReturned => { if (td.hasNext()) { res.setPayload("Found!"); } else { res.setPayload("Not Found!"); } td.close(); } error err => throw err; } Correct Approach: error: ./sqli_fail.bal:23:40: tainted value passed to sensitive parameter 'sqlQuery'
  • 11. Cross Site Scripting (XSS) Prevention Demo import ballerina/http; string regex = "[a-zA-Z]+"; service<http:Service> hello bind {port: 9090} { sayHello(endpoint c, http:Request req) { http:Response res = new; var params = req.getQueryParams(); if (check params.name.matches(regex)) { res.setPayload("Hello, " + untaint params.name + "!"); } else { res.setPayload("Name contains invalid data!"); } _ = c->respond(res); } } import ballerina/http; service<http:Service> hello bind {port: 9090} { sayHello(endpoint c, http:Request req) { var params = req.getQueryParams(); _ = c->respond("Hello, " + params.name ); } } error: ./http_fail.bal:9:25: tainted value passed to sensitive parameter 'message' Correct Approach:
  • 13. XML External Entity Injection (XXE) Prevention Demo <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE foo [ <!ELEMENT foo ANY > <!ENTITY xxe SYSTEM "file:///etc/passwd"> ]> <foo>&xxe;</foo> This XML will expose the content of /etc/passwd file.
  • 14. XML Entity Expansion Prevention <?xml version="1.0"?> <!DOCTYPE lolz [ <!ENTITY lol "lol"> <!ENTITY lol2 "&lol;&lol;&lol;&lol;&lol;&lol;"> <!ENTITY lol3 "&lol2;&lol2;&lol2;&lol2;&lol2;"> <!ENTITY lol4 "&lol3;&lol3;&lol3;&lol3;&lol3;"> <!ENTITY lol5 "&lol4;&lol4;&lol4;&lol4;&lol4;"> <!ENTITY lol6 "&lol5;&lol5;&lol5;&lol5;&lol5;"> <!ENTITY lol7 "&lol6;&lol6;&lol6;&lol6;&lol6;"> <!ENTITY lol8 "&lol7;&lol7;&lol7;&lol7;&lol7;"> <!ENTITY lol9 "&lol8;&lol8;&lol8;&lol8;&lol8;"> ]> <lolz>&lol9;</lolz> Parsing the XML will result in DoS attack, since parser will expand all the entities.
  • 16. Built-in Security Features ○ OCSP validation for SSL/TLS certificates ○ CRL validation for SSL/TLS certificates ○ Config API reading encrypted passwords or secrets ○ Cryptographic operations ○ Authentication and authorization for services
  • 18. Inbound Authentication & Authorization Authentication Filter Authorization Filter Authentication Provider Resource Request Basic Auth OAuth JWT Certificate Response HTTP JMS Config File LDAP AD DB User Storage
  • 19. Inbound Authentication & Authorization - Basic Auth import ballerina/http; endpoint http:SecureListener ep { port:9090 }; @http:ServiceConfig { basePath: "/hello", authConfig: { scopes: [ "hello" ] } } service<http:Service> helloWorld bind ep { @http:ResourceConfig { methods: [ "GET" ], path: "/" } sayHello (endpoint c, http:Request r) { _ = c -> respond("Hello!"); } } http:AuthProvider configured to use "config" file as the user store. Endpoint is configured to use the http:AuthProvider @http:ServiceConfig is configured to authorize users with scope "hello"
  • 20. Inbound Authentication & Authorization - JWT Auth http:AuthProvider jwtAuthProvider = { scheme: "jwt", issuer: "ballerina", audience: "ballerina.io", clockSkew: 10, certificateAlias: "ballerina", trustStore: { path: "/home/ops/truststore.p12", password: "t4C3F5WrFbQn6h4S" } }; endpoint http:SecureListener ep { port:9090, authProviders: [ jwtAuthProvider ] }; http:AuthProvider configured to use enforce authentication using "jwt" scheme.
  • 21. Outbound Authentication endpoint http:Client downstreamServiceEP { url: "https://localhost:9092", auth: { scheme: http:JWT_AUTH }, }; endpoint http:Client downstreamServiceEP { url: "https://localhost:9092", auth: { scheme: http:OAUTH2, accessToken: "34060588", refreshToken: "15160398", refreshUrl: "https://ballerina.io/ref" clientId: "rgfKVdnMQnJSSr", clientSecret: "BRebJ0aqfclQB9" }, } endpoint http:Client downstreamServiceEP { url: "https://localhost:9092", auth: { scheme: http:BASIC_AUTH, username: "downstreamServiceUser", password: "QK1eIWH5d6UaZXA3" } Client endpoint can be configured with the desired authentication scheme. JWT Authentication OAuth2 Authentication Basic Authentication
  • 22. Summary ○ Taint Analysis ○ Secure Defaults ○ Security Features ○ Authentication and Authorization "How to Write Secure Ballerina Programs" https://ballerina.io/learn/how-to-write-secure-ballerina-code