OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs....

61
Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the OWASP License. The OWASP Foundation OWASP http://www.owasp.org OPA: Language Support for a Sane, Safe and Secure Web David Rajchenbach-Teller Head of R&D MLstate [email protected] twitter.com/mlstate +33 1 55 43 76 55 June 24th, 2010

Transcript of OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs....

Page 1: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

Copyright © The OWASP FoundationPermission is granted to copy, distribute and/or modify this document under the terms of the OWASP License.

The OWASP Foundation

OWASP

http://www.owasp.org

OPA: Language Support for a Sane, Safe and Secure Web

David Rajchenbach-TellerHead of R&[email protected]/mlstate+33 1 55 43 76 55

June 24th, 2010

Page 2: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

What it’s all about

OWASP

What Automated Solutions Miss

!!Theoretical

"!Logic flaws (business and application)

"!Design flaws

"!The Stupid

!!Practical

"!Difficulty interacting with Rich Internet Applications (RIA)

"!Complex variants of common attacks (SQL Injection, XSS, etc)

"!Cross-Site Request Forgery (CSRF)

"!Uncommon or custom infrastructure

"!Authorization enforcement

"!Abstract information leakage 6 2

Page 3: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

What it’s all about

“Automated vs. Manual: You can’t filter The Stupid”Charles Henderson, David Byrne

AppSec DC 2009 + 2010

OWASP

What Automated Solutions Miss

!!Theoretical

"!Logic flaws (business and application)

"!Design flaws

"!The Stupid

!!Practical

"!Difficulty interacting with Rich Internet Applications (RIA)

"!Complex variants of common attacks (SQL Injection, XSS, etc)

"!Cross-Site Request Forgery (CSRF)

"!Uncommon or custom infrastructure

"!Authorization enforcement

"!Abstract information leakage 6

2

Page 4: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

What it’s all about

“Automated vs. Manual: You can’t filter The Stupid”Charles Henderson, David Byrne

AppSec DC 2009 + 2010

“Oh, yeah?”The MLstate teamAppSec Research 2010

OWASP

What Automated Solutions Miss

!!Theoretical

"!Logic flaws (business and application)

"!Design flaws

"!The Stupid

!!Practical

"!Difficulty interacting with Rich Internet Applications (RIA)

"!Complex variants of common attacks (SQL Injection, XSS, etc)

"!Cross-Site Request Forgery (CSRF)

"!Uncommon or custom infrastructure

"!Authorization enforcement

"!Abstract information leakage 6

2

Page 5: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

General approachKeeping in the Smart UsefulFiltering out the Stupid FragileLessons and Future

OWASP

OPA: Language Support for a Sane, Safe and Secure Web

3

Page 6: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

General approachKeeping in the Smart UsefulFiltering out the Stupid FragileLessons and Future

OWASP

OPA: Language Support for a Sane, Safe and Secure Web

3

Page 7: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP 4

Web Applications(high-level design)

App App

User User

Storage Delivery

Logics

UI

Page 8: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

WebServer

Web Browser

Database

Language

JavaScript

PHP?

Web Applications(what we see)

5

Page 9: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

WebServer

Web Browser

Database

Language

JavaScript

PHP?

DatabaseDatabase

LanguageFramework

+scriptsWho

knows?

WebServer

WebServer

Web Browser

WebServer

Language

Java?

Web Applications(what we see)

5

Page 10: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

WebServer

Web Browser

Database

Language

JavaScript

PHP?

DatabaseDatabase

LanguageFramework

+scriptsWho

knows?

WebServer

WebServer

Web Browser

WebServer

Language

Java?

Web Applications(what we see)

Config error?

Config error?

Config error?

Config error?

5

Page 11: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

WebServer

Web Browser

Database

Language

JavaScript

PHP?

DatabaseDatabase

LanguageFramework

+scriptsWho

knows?

WebServer

WebServer

Web Browser

WebServer

Language

Java?

Web Applications(what we see)

Config error?

Config error?

Config error?

Config error?

Protocol?

Protocol?

Protocol?

Protocol?

5

Page 12: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

WebServer

Web Browser

Database

Language

JavaScript

PHP?

DatabaseDatabase

LanguageFramework

+scriptsWho

knows?

WebServer

WebServer

Web Browser

WebServer

Language

Java?

Web Applications(what we see)

CSRF

XSSinjection SQL

injection

Info leak

Data injection

Memory injection

Protocol exploit

Memory injection

Sniffing

Config error?

Config error?

Config error?

Config error?

Protocol?

Protocol?

Protocol?

Protocol? Contami

nation

5

Page 13: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

WebServer

Web Browser

Database

Language

JavaScript

PHP?

DatabaseDatabase

LanguageFramework

+scriptsWho

knows?

WebServer

WebServer

Web Browser

WebServer

Language

Java?

Web Applications(what we see)

CSRF

XSSinjection SQL

injection

Info leak

Data injection

Memory injection

Protocol exploit

Memory injection

Sniffing

Config error?

Config error?

Config error?

Config error?

Protocol?

Protocol?

Protocol?

Protocol?

+Phishing+(D)DoS, economic (D)DoS+Flash, Silverlight, Gears, XPCOM, Java

(FX), NativeClient, Acrobat, QT...+Keyloggers+...

Protocol exploit

Contamination

Contamination

Protocol exploit

Protocol exploit

Known exploit

5

Page 14: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

The general idea

6

Page 15: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

The general idea

6

“If you can’t solve the problem, change the problem.” Ferengi Rule of Acquisition #408

Page 16: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

The general idea

6

“If you can’t solve the problem, change the problem.” Ferengi Rule of Acquisition #408

“What if the problem is that Joe User is stupid?”(Joe Developer)

Page 17: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

The general idea

6

“If you can’t solve the problem, change the problem.” Ferengi Rule of Acquisition #408

“What if the problem is that Joe User is stupid?”(Joe Developer)

“It’s not him, it’s you. You should design your tool so that Joe can’t do anything stupid.”

Ferengi Rule of Acquisition #408, contd.

Page 18: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

The general idea

6

“If you can’t solve the problem, change the problem.” Ferengi Rule of Acquisition #408

“What if the problem is that Joe User is stupid?”(Joe Developer)

“It’s not him, it’s you. You should design your tool so that Joe can’t do anything stupid.”

Ferengi Rule of Acquisition #408, contd.

“What if the problem is that Joe Developer is stupid?”(Joe Meta-Developer)

Page 19: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

The general idea

6

“If you can’t solve the problem, change the problem.” Ferengi Rule of Acquisition #408

“...oh, and don’t forget to make sure that Joe can still use the tools!”

Ferengi Rule of Acquisition #408, contd.

“What if the problem is that Joe User is stupid?”(Joe Developer)

“It’s not him, it’s you. You should design your tool so that Joe can’t do anything stupid.”

Ferengi Rule of Acquisition #408, contd.

“What if the problem is that Joe Developer is stupid?”(Joe Meta-Developer)

“Haven’t I answered that question already?”Ferengi Rule of Acquisition #408, contd.

Page 20: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP 7

Web applications(with OPA)

App App

User User

Storage DeliveryUI

OPA

Logics

Page 21: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP 7

Web applications(with OPA)

App App

User User

Storage DeliveryUI

OPA

Logics

Page 22: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP 7

Web applications(with OPA)

App App

User User

Storage DeliveryUI

OPA

Untrusted

Logics

Page 23: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

General OPA design

8

Page 24: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

General OPA designClean-slate design

Based on formal methodsSafe languages from the bottom up

8

Page 25: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

General OPA designClean-slate design

Based on formal methodsSafe languages from the bottom up

One language for the whole applicationGlue & checks generated automaticallyNo impedance mismatch

8

Page 26: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

General OPA designClean-slate design

Based on formal methodsSafe languages from the bottom up

One language for the whole applicationGlue & checks generated automaticallyNo impedance mismatch

“Just” a distributed systemIn which not all principals are trustedAnd communications use web standardsSecurity is (mostly) automatic

8

Page 27: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

General OPA designClean-slate design

Based on formal methodsSafe languages from the bottom up

One language for the whole applicationGlue & checks generated automaticallyNo impedance mismatch

“Just” a distributed systemIn which not all principals are trustedAnd communications use web standardsSecurity is (mostly) automatic

8

Joe doesn’t need to know

Simpler than LAMP

Joe doesn’t need to know

Page 28: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

General approachKeeping in the Smart UsefulFiltering out the Stupid FragileLessons and Future

OWASP

OPA: Language Support for a Sane, Safe and Secure Web

9

Page 29: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

General approachKeeping in the Smart UsefulFiltering out the Stupid FragileLessons and Future

OPA: Language Support for a Sane, Safe and Secure Web

9

Page 30: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

Hello, web

10

Page 31: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

Hello, web

10

server = one_page_server("Hello, web", -> <>Hello, web</>)

Complete web application.

1) Compileopa hello.opa

2) Run./hello.exe

3) Testbrowse http://localhost:8080

Page 32: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

URL shortener (22 loc)

11

db /abbrevs: intmap(string)db /abbrevs[_] = "/"

make_shorter(url:string):string =  key = Db.fresh_key(/abbrevs)  do /abbrevs[key] <- url  "{key}"_ = @server(make_shorter)

do_shorten(_) =exec([#shortened <- make_shorter(Page.getVal(#origin))])

urls = parser| "/" dest=Rule.integer ->     Resource.redirection_page("Please wait a second", <div class="loading">(loading...)</>,{address_moved},0,/abbrevs[dest])| .* ->     Resource.html("MLstate redirector",     <>Please enter a URL you wish to shorten<br/>    <input id="origin"/><button onclick={do_shorten}>Shorten</button>    <div id="shortened"></div>    </>)

server = simple_server(urls)

Page 33: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

URL shortener (22 loc)

11

db /abbrevs: intmap(string)db /abbrevs[_] = "/"

make_shorter(url:string):string =  key = Db.fresh_key(/abbrevs)  do /abbrevs[key] <- url  "{key}"_ = @server(make_shorter)

do_shorten(_) =exec([#shortened <- make_shorter(Page.getVal(#origin))])

urls = parser| "/" dest=Rule.integer ->     Resource.redirection_page("Please wait a second", <div class="loading">(loading...)</>,{address_moved},0,/abbrevs[dest])| .* ->     Resource.html("MLstate redirector",     <>Please enter a URL you wish to shorten<br/>    <input id="origin"/><button onclick={do_shorten}>Shorten</button>    <div id="shortened"></div>    </>)

server = simple_server(urls)

Database

UI

Control

Page 34: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

Nice web chat

12

type mess = {id: string; message: string}room = Network.empty():Network.network(mess)connect(callback) = Network.add(Session.make_callback(callback), room)make_broadcaster(id) = _ -> Network.broadcast({~id message=Page.get_value(#entry)}, room)

styled_page(title, body) = (  Resource.full_page(title, body, <link rel="stylesheet" type="text/css" href="resources/css.css" />, {success}, []))

user_update(x:mess) = (  line = <div class="opa-line">    <div class="opa-wrap"><div class="opa-user">{x.id}:</div>    <div class="opa-message">{x.message}</div></div>  </div>  do exec([#show +<- line ])  Page.set_scroll_top(#show, Page.get_height(#show)+Page.get_scroll_top(#show)))

start(connexion) = (   id = String.sub(0, 8, Server.get_user(connexion) ? "Unknown")   broadcast = make_broadcaster(id)   styled_page("Chat",  //Display     <script onload={_ -> connect()}/>     <div id="header"><div id="logo"></div></div>     <div id="show"></div>     <input id="entry"/>     <div class="opa-button" onclick={broadcast}>Send!</div>   )

)

urls      = parser .* -> startresources = @static_include_directory("resources")server    = Server.make(Resource.add_auto_server(resources, urls))

Page 35: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

Nice web chat

12

type mess = {id: string; message: string}room = Network.empty():Network.network(mess)connect(callback) = Network.add(Session.make_callback(callback), room)make_broadcaster(id) = _ -> Network.broadcast({~id message=Page.get_value(#entry)}, room)

styled_page(title, body) = (  Resource.full_page(title, body, <link rel="stylesheet" type="text/css" href="resources/css.css" />, {success}, []))

user_update(x:mess) = (  line = <div class="opa-line">    <div class="opa-wrap"><div class="opa-user">{x.id}:</div>    <div class="opa-message">{x.message}</div></div>  </div>  do exec([#show +<- line ])  Page.set_scroll_top(#show, Page.get_height(#show)+Page.get_scroll_top(#show)))

start(connexion) = (   id = String.sub(0, 8, Server.get_user(connexion) ? "Unknown")   broadcast = make_broadcaster(id)   styled_page("Chat",  //Display     <script onload={_ -> connect()}/>     <div id="header"><div id="logo"></div></div>     <div id="show"></div>     <input id="entry"/>     <div class="opa-button" onclick={broadcast}>Send!</div>   )

)

urls      = parser .* -> startresources = @static_include_directory("resources")server    = Server.make(Resource.add_auto_server(resources, urls))

UI

Page 36: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

Nice web chat

12

type mess = {id: string; message: string}room = Network.empty():Network.network(mess)connect(callback) = Network.add(Session.make_callback(callback), room)make_broadcaster(id) = _ -> Network.broadcast({~id message=Page.get_value(#entry)}, room)

styled_page(title, body) = (  Resource.full_page(title, body, <link rel="stylesheet" type="text/css" href="resources/css.css" />, {success}, []))

user_update(x:mess) = (  line = <div class="opa-line">    <div class="opa-wrap"><div class="opa-user">{x.id}:</div>    <div class="opa-message">{x.message}</div></div>  </div>  do exec([#show +<- line ])  Page.set_scroll_top(#show, Page.get_height(#show)+Page.get_scroll_top(#show)))

start(connexion) = (   id = String.sub(0, 8, Server.get_user(connexion) ? "Unknown")   broadcast = make_broadcaster(id)   styled_page("Chat",  //Display     <script onload={_ -> connect()}/>     <div id="header"><div id="logo"></div></div>     <div id="show"></div>     <input id="entry"/>     <div class="opa-button" onclick={broadcast}>Send!</div>   )

)

urls      = parser .* -> startresources = @static_include_directory("resources")server    = Server.make(Resource.add_auto_server(resources, urls))

UI

Real-time web

Page 37: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

Nice web chat

12

type mess = {id: string; message: string}room = Network.empty():Network.network(mess)connect(callback) = Network.add(Session.make_callback(callback), room)make_broadcaster(id) = _ -> Network.broadcast({~id message=Page.get_value(#entry)}, room)

styled_page(title, body) = (  Resource.full_page(title, body, <link rel="stylesheet" type="text/css" href="resources/css.css" />, {success}, []))

user_update(x:mess) = (  line = <div class="opa-line">    <div class="opa-wrap"><div class="opa-user">{x.id}:</div>    <div class="opa-message">{x.message}</div></div>  </div>  do exec([#show +<- line ])  Page.set_scroll_top(#show, Page.get_height(#show)+Page.get_scroll_top(#show)))

start(connexion) = (   id = String.sub(0, 8, Server.get_user(connexion) ? "Unknown")   broadcast = make_broadcaster(id)   styled_page("Chat",  //Display     <script onload={_ -> connect()}/>     <div id="header"><div id="logo"></div></div>     <div id="show"></div>     <input id="entry"/>     <div class="opa-button" onclick={broadcast}>Send!</div>   )

)

urls      = parser .* -> startresources = @static_include_directory("resources")server    = Server.make(Resource.add_auto_server(resources, urls))

UI

Real-time web

URLs

Page 38: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

There’s more

Games

Productivity tools

Development tools

Security applications

e-Commerce applications

...

13

Page 39: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

Things we can do (and check!)

14

Page 40: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

Things we can do (and check!)

14

Ajax

Comet

SOAP

WSDL

Distribution

Data history

Multitasking

XML processing

Higher-order programming

Higher-order database

Complex database

Concurrent transactions

Capabilities

User interface

Time-unlimited rollbackFine-grained sessions

Programmable security policies

...

Page 41: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

General approachKeeping in the Smart UsefulFiltering out the Stupid FragileLessons and Future

OWASP

OPA: Language Support for a Sane, Safe and Secure Web

15

Page 42: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

General approachKeeping in the Smart UsefulFiltering out the Stupid FragileLessons and Future

OPA: Language Support for a Sane, Safe and Secure Web

15

Page 43: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

Transparent protections

16

type mess = {id: string; message: string}room = Network.empty():Network.network(mess)connect(callback) = Network.add(Session.make_callback(callback), room)make_broadcaster(id) = _ -> Network.broadcast({~id message=Page.get_value(#entry)}, room)

styled_page(title, body) = (  Resource.full_page(title, body, <link rel="stylesheet" type="text/css" href="resources/css.css" />, {success}, []))

user_update(x:mess) = (  line = <div class="opa-line">    <div class="opa-wrap"><div class="opa-user">{x.id}:</div>    <div class="opa-message">{x.message}</div></div>  </div>  do exec([#show +<- line ])  Page.set_scroll_top(Page.get_height(#show)+Page.get_scroll_top(#show), #show))

start(connexion) = (   id = String.sub(0, 8, Server.get_user(connexion) ? "Unknown")   broadcast = make_broadcaster(id)   styled_page("Chat",  //Display     <script onload={_ -> connect()}/>     <div id="header"><div id="logo"></div></div>     <div id="show"></div>     <input id="entry"/>     <div class="opa-button" onclick={broadcast}>Send!</div>   ))

urls      = parser .* -> startresources = @static_include_directory("resources")server    = Server.make(Resource.add_auto_server(resources, urls))

Page 44: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

Transparent protections

16

type mess = {id: string; message: string}room = Network.empty():Network.network(mess)connect(callback) = Network.add(Session.make_callback(callback), room)make_broadcaster(id) = _ -> Network.broadcast({~id message=Page.get_value(#entry)}, room)

styled_page(title, body) = (  Resource.full_page(title, body, <link rel="stylesheet" type="text/css" href="resources/css.css" />, {success}, []))

user_update(x:mess) = (  line = <div class="opa-line">    <div class="opa-wrap"><div class="opa-user">{x.id}:</div>    <div class="opa-message">{x.message}</div></div>  </div>  do exec([#show +<- line ])  Page.set_scroll_top(Page.get_height(#show)+Page.get_scroll_top(#show), #show))

start(connexion) = (   id = String.sub(0, 8, Server.get_user(connexion) ? "Unknown")   broadcast = make_broadcaster(id)   styled_page("Chat",  //Display     <script onload={_ -> connect()}/>     <div id="header"><div id="logo"></div></div>     <div id="show"></div>     <input id="entry"/>     <div class="opa-button" onclick={broadcast}>Send!</div>   ))

urls      = parser .* -> startresources = @static_include_directory("resources")server    = Server.make(Resource.add_auto_server(resources, urls))

user_update(x:mess) = (  line = <div class="opa-line">    <div class="opa-wrap"><div class="opa-user">{x.id}:</div>    <div class="opa-message">{x.message}</div></div>  </div>  do exec([#show +<- line ])  Page.set_scroll_top(#show, Page.get_height(#show)+Page.get_scroll_top(#show)))

All insertions are checked

Page 45: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

Transparent protections

16

type mess = {id: string; message: string}room = Network.empty():Network.network(mess)connect(callback) = Network.add(Session.make_callback(callback), room)make_broadcaster(id) = _ -> Network.broadcast({~id message=Page.get_value(#entry)}, room)

styled_page(title, body) = (  Resource.full_page(title, body, <link rel="stylesheet" type="text/css" href="resources/css.css" />, {success}, []))

user_update(x:mess) = (  line = <div class="opa-line">    <div class="opa-wrap"><div class="opa-user">{x.id}:</div>    <div class="opa-message">{x.message}</div></div>  </div>  do exec([#show +<- line ])  Page.set_scroll_top(Page.get_height(#show)+Page.get_scroll_top(#show), #show))

start(connexion) = (   id = String.sub(0, 8, Server.get_user(connexion) ? "Unknown")   broadcast = make_broadcaster(id)   styled_page("Chat",  //Display     <script onload={_ -> connect()}/>     <div id="header"><div id="logo"></div></div>     <div id="show"></div>     <input id="entry"/>     <div class="opa-button" onclick={broadcast}>Send!</div>   ))

urls      = parser .* -> startresources = @static_include_directory("resources")server    = Server.make(Resource.add_auto_server(resources, urls))

Page 46: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

Transparent protections

16

type mess = {id: string; message: string}room = Network.empty():Network.network(mess)connect(callback) = Network.add(Session.make_callback(callback), room)make_broadcaster(id) = _ -> Network.broadcast({~id message=Page.get_value(#entry)}, room)

styled_page(title, body) = (  Resource.full_page(title, body, <link rel="stylesheet" type="text/css" href="resources/css.css" />, {success}, []))

user_update(x:mess) = (  line = <div class="opa-line">    <div class="opa-wrap"><div class="opa-user">{x.id}:</div>    <div class="opa-message">{x.message}</div></div>  </div>  do exec([#show +<- line ])  Page.set_scroll_top(Page.get_height(#show)+Page.get_scroll_top(#show), #show))

start(connexion) = (   id = String.sub(0, 8, Server.get_user(connexion) ? "Unknown")   broadcast = make_broadcaster(id)   styled_page("Chat",  //Display     <script onload={_ -> connect()}/>     <div id="header"><div id="logo"></div></div>     <div id="show"></div>     <input id="entry"/>     <div class="opa-button" onclick={broadcast}>Send!</div>   ))

urls      = parser .* -> startresources = @static_include_directory("resources")server    = Server.make(Resource.add_auto_server(resources, urls))

make_broadcaster(id) = _ -> Network.broadcast({~id message=Page.get_value(#entry)}, room)

All communications are checked

Page 47: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

Transparent protections

16

type mess = {id: string; message: string}room = Network.empty():Network.network(mess)connect(callback) = Network.add(Session.make_callback(callback), room)make_broadcaster(id) = _ -> Network.broadcast({~id message=Page.get_value(#entry)}, room)

styled_page(title, body) = (  Resource.full_page(title, body, <link rel="stylesheet" type="text/css" href="resources/css.css" />, {success}, []))

user_update(x:mess) = (  line = <div class="opa-line">    <div class="opa-wrap"><div class="opa-user">{x.id}:</div>    <div class="opa-message">{x.message}</div></div>  </div>  do exec([#show +<- line ])  Page.set_scroll_top(Page.get_height(#show)+Page.get_scroll_top(#show), #show))

start(connexion) = (   id = String.sub(0, 8, Server.get_user(connexion) ? "Unknown")   broadcast = make_broadcaster(id)   styled_page("Chat",  //Display     <script onload={_ -> connect()}/>     <div id="header"><div id="logo"></div></div>     <div id="show"></div>     <input id="entry"/>     <div class="opa-button" onclick={broadcast}>Send!</div>   ))

urls      = parser .* -> startresources = @static_include_directory("resources")server    = Server.make(Resource.add_auto_server(resources, urls))

Page 48: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

Transparent protections

16

type mess = {id: string; message: string}room = Network.empty():Network.network(mess)connect(callback) = Network.add(Session.make_callback(callback), room)make_broadcaster(id) = _ -> Network.broadcast({~id message=Page.get_value(#entry)}, room)

styled_page(title, body) = (  Resource.full_page(title, body, <link rel="stylesheet" type="text/css" href="resources/css.css" />, {success}, []))

user_update(x:mess) = (  line = <div class="opa-line">    <div class="opa-wrap"><div class="opa-user">{x.id}:</div>    <div class="opa-message">{x.message}</div></div>  </div>  do exec([#show +<- line ])  Page.set_scroll_top(Page.get_height(#show)+Page.get_scroll_top(#show), #show))

start(connexion) = (   id = String.sub(0, 8, Server.get_user(connexion) ? "Unknown")   broadcast = make_broadcaster(id)   styled_page("Chat",  //Display     <script onload={_ -> connect()}/>     <div id="header"><div id="logo"></div></div>     <div id="show"></div>     <input id="entry"/>     <div class="opa-button" onclick={broadcast}>Send!</div>   ))

urls      = parser .* -> startresources = @static_include_directory("resources")server    = Server.make(Resource.add_auto_server(resources, urls))

   styled_page("Chat",  //Display     <script onload={_ -> connect()}/>     <div id="header"><div id="logo"></div></div>     <div id="show"></div>     <input id="entry"/>     <div class="opa-button" onclick={broadcast}>Send!</div>   )

Per-user capability?*

Page 49: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

Transparent protections

16

type mess = {id: string; message: string}room = Network.empty():Network.network(mess)connect(callback) = Network.add(Session.make_callback(callback), room)make_broadcaster(id) = _ -> Network.broadcast({~id message=Page.get_value(#entry)}, room)

styled_page(title, body) = (  Resource.full_page(title, body, <link rel="stylesheet" type="text/css" href="resources/css.css" />, {success}, []))

user_update(x:mess) = (  line = <div class="opa-line">    <div class="opa-wrap"><div class="opa-user">{x.id}:</div>    <div class="opa-message">{x.message}</div></div>  </div>  do exec([#show +<- line ])  Page.set_scroll_top(Page.get_height(#show)+Page.get_scroll_top(#show), #show))

start(connexion) = (   id = String.sub(0, 8, Server.get_user(connexion) ? "Unknown")   broadcast = make_broadcaster(id)   styled_page("Chat",  //Display     <script onload={_ -> connect()}/>     <div id="header"><div id="logo"></div></div>     <div id="show"></div>     <input id="entry"/>     <div class="opa-button" onclick={broadcast}>Send!</div>   ))

urls      = parser .* -> startresources = @static_include_directory("resources")server    = Server.make(Resource.add_auto_server(resources, urls))

Page 50: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

A1-Injection A6-Security Misconfiguration

A2-Cross Site Scripting (XSS) A7-Insecure Cryptographic Storage

A3-Broken Authentication and Session Management

A8-Failure to Restrict URL Access

A4-Insecure Direct Object References

A9-Insufficient Transport Layer Protection

A5-Cross Site Request Forgery (CSRF)

A10-Unvalidated Redirects and Forwards

OWASP

More

17

Page 51: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

A1-Injection A6-Security Misconfiguration

A2-Cross Site Scripting (XSS) A7-Insecure Cryptographic Storage

A3-Broken Authentication and Session Management

A8-Failure to Restrict URL Access

A4-Insecure Direct Object References

A9-Insufficient Transport Layer Protection

A5-Cross Site Request Forgery (CSRF)

A10-Unvalidated Redirects and Forwards

OWASP

More

17

A1-Injection A6-Security Misconfiguration

A2-Cross Site Scripting (XSS) A7-Insecure Cryptographic Storage

A3-Broken Authentication and Session Management

A8-Failure to Restrict URL Access

A4-Insecure Direct Object References

A9-Insufficient Transport Layer Protection

A5-Cross Site Request Forgery (CSRF)

A10-Unvalidated Redirects and Forwards

Page 52: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

A1-Injection A6-Security Misconfiguration

A2-Cross Site Scripting (XSS) A7-Insecure Cryptographic Storage

A3-Broken Authentication and Session Management

A8-Failure to Restrict URL Access

A4-Insecure Direct Object References

A9-Insufficient Transport Layer Protection

A5-Cross Site Request Forgery (CSRF)

A10-Unvalidated Redirects and Forwards

OWASP

More

17

A1-Injection A6-Security Misconfiguration

A2-Cross Site Scripting (XSS) A7-Insecure Cryptographic Storage

A3-Broken Authentication and Session Management

A8-Failure to Restrict URL Access

A4-Insecure Direct Object References

A9-Insufficient Transport Layer Protection

A5-Cross Site Request Forgery (CSRF)

A10-Unvalidated Redirects and Forwards

Page 53: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP 18OWASP

What Automated Solutions Miss

!!Theoretical

"!Logic flaws (business and application)

"!Design flaws

"!The Stupid

!!Practical

"!Difficulty interacting with Rich Internet Applications (RIA)

"!Complex variants of common attacks (SQL Injection, XSS, etc)

"!Cross-Site Request Forgery (CSRF)

"!Uncommon or custom infrastructure

"!Authorization enforcement

"!Abstract information leakage 6

(in progress)

16

Page 54: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP 18OWASP

What Automated Solutions Miss

!!Theoretical

"!Logic flaws (business and application)

"!Design flaws

"!The Stupid

!!Practical

"!Difficulty interacting with Rich Internet Applications (RIA)

"!Complex variants of common attacks (SQL Injection, XSS, etc)

"!Cross-Site Request Forgery (CSRF)

"!Uncommon or custom infrastructure

"!Authorization enforcement

"!Abstract information leakage 6

^other

(in progress)

(been there, done that)

(abstract&specify them away!)

(been there, done that)

(in progress)

(in progress)

(been there, done that)

(been there, done that)

(what we do best)

16

Page 55: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

General approachKeeping in the Smart UsefulFiltering out the Stupid FragileLessons and Future

OWASP

OPA: Language Support for a Sane, Safe and Secure Web

19

Page 56: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

General approachKeeping in the Smart UsefulFiltering out the Stupid FragileLessons and Future

OWASP

OPA: Language Support for a Sane, Safe and Secure Web

19

Page 57: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

Theoretical foundations

Building on 30+ years of research in formal methods & language theory.

Key for precise analysis.

Key for precise optimizations.

20

Page 58: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

False positives

False positives are annoying but not that bad -- as long as they are predictable and there’s a workaround.

Experienced developers make safety/security mistakes quite often.

False positives often later reveal themselves as true positives.

21

Page 59: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP

Future

Eliminate CSRF.

Extend per-application security policy.

Extend per-library/per-data safety policy.

Plenty of additional features!

Hiring you?

22

Page 60: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP 23

That’s all, folks!

http://www.mlstate.com

Page 61: OPA: Language Support for a Sane, Safe and Secure Web...OWASP What it’s all about “Automated vs. Manual: You can’t filter The Stupid” Charles Henderson, David Byrne AppSec

OWASP 23

That’s all, folks!

Thanks and apologies to David Byrne & Charles Anderson for hijacking their slides

http://www.mlstate.com