SlideShare una empresa de Scribd logo
1 de 32
Descargar para leer sin conexión
NodeJS Security:
The Good, Bad & Ugly
A look at Server Side JS History.
   How old do you think it is?
1996 (LiveWire). Rhino (1997).
    50+ more since then
something went wrong…
JS not interesting   Slow JS Engines
    to many




           JS is               Lack of a
       misunderstood.         compelling
        Under-rated          browser war
Lead to blazing fast engines
                  Google V8 (NodeJS uses this),
The Browser War
                   FF SpiderMonkey, MS Chakra



        So why now?
Why is it so HOT?
Speed. Performance. JS to do it all.
Adoption: 11/11
Adoption: 02/12
(5 min Tech Primer)
Event-driven. Asynchronous.
      Single-threaded
Traditional Platforms
• A sample code
 data = readFromDatabase();
 printData(data);
 doSomethingUnrelated();



• Pitfalls
   – The program blocked when reading from db
   – Lots of processor cycles wasted
In Node
• A typical code

    readFromDatabase(function(data)
    {
    printData(data);
    });
    doSomethingUnrelated();


• Gains
    –   not have to wait for slow file I/O or db ops. Aka non-blocking server
    –   everything runs in parallel. doSomethingUnrelated() doesn’t wait.
    –   printData(data) called when finished reading
    –   insanely fast
    –   serve millions concurrent connections at once
A production
     Web Framework / MVC Arch.
Enter – Express, Mustache, Jade

     (What is MISSING?)
             A DB server.
  Enter – NoSQL (MongoDB, CouchDB)


       A full stack dev libraries.
              Enter – NPM
(In)Security
“JavaScript has so much expressive power that they are able to do useful things in it,
                                       anyway.”
                   http://javascript.crockford.com/javascript.html


      "JavaScript is the world's most misunderstood programming language.”
                  http://www.crockford.com/javascript/private.html




                                  (Mostly B’coz)

                                                With Power comes
                                              Responsibility
Property: Implied Globals
              Abuse: Namespace Pollution
          Impact: what’s the worst you can think?


               (The Ugly Parts)
Property: eval (new Function,setTimeout,setInterval)
             Abuse: JSON Parse, shortcuts
              Impact: Host Compromise


               Property: process privilege
            Abuse: run as root (even Express)
      Impact: Why does Apache run as nobody/nobody?
Global Namespace Pollution




   JS is a global lang. By default – all variables, functions, objects are
                           implied to global scope
(In contrast, with PHP (or others), each request lives in it’s unique scope.)
Global Namespace Pollution
 WEB USER 1                                                       WEB USER 2




               # Any request will share the same global scope.
      # As seen , for two different users, each request increased gbl by 1
         (Try yourself: http://46.137.9.100:1314/)


      An equivalent code in PHP will always print 1 for every request.
Exploits: Namespace Pollution
• Overriding / Hijacking Sensitive Globals. Host Compromise
• How? imagine XSS and SOP. think your browser is now server
• Another innocent sample
    – Bob sets is_valid to true for operation X but forgets to call it as “var”.
        Y.mojito.controller = {
                 index: function(ac) {
                           var is_valid = true;


    – Alice coding on the same project also forgets “var” and initialized is_valid to false.
        Y.mojito.controller = {
                 index: function(ac) {
                           if (is_valid){
                           // get access to user data or some functions

• Attack Surface?
    – NPM: malicious library. Insecure library
    – Malicious coder
    – Innocent coder
eval is EVIL




            USE CASE # treats data as code. Very powerful. Very very popular.
EXPLOIT # CODE EXECUTION. COMMAND EXECUTION. SHELL EXECUTION. NEVER USE IT!
           SIDE NOTE: exists in NPM. Audit. Audit. Audit.



eval has cousins – setTimeout, setInterval, new Function.
                         DON‘T USE THEM
eval is EVIL




        Try yourself: http://46.137.9.100:1313
Exploit code: response.end(“my first ssi”)
Runtime Privilege Context




  # By default, NodeJS runs as privileged user
  # By default, Express runs as privileged user
        Why? Remote Shell Exploits.
     Why Apache runs as nobody/nobody?
Property: with                Property: switch
  Abuse: shorthand typos         Abuse: faulty fallthru
Impact: Context dependent      Impact: Context dependent


                (The Bad Parts)
           Property: single threaded / interpreted
           Abuse: incomplete exception handling
                       Impact: DoS


     Property: templating engines [mu, jade, ejs, haml]
        Abuse: context sensitive output escaping
                       Impact: XSS
with is EVIL (exploitable on Cocktails)




              Use Case# welcome message
              What went wrong # typo,…
with is EVIL (exploitable on Cocktails)




                      Exploit # Depends
        (Try yourself: http://46.137.9.100:1315/)
DoS (*doesn’t affect Express)

                                                          Generate a simple
                                                             exception




JS is interpreted, NOT compiled. Code itself shouldn’t be faulty. Else it’s a
                   self-DoS. Very difficult to ENSURE this.
switch is EVIL (an old foe)




     Use Case# Valued Customer be given 10% discount only
      Exploit # missing break leading to privilege escalation
switch is EVIL (an old foe)




     Exploit # Valued Customer getting more discount
 (Try Yourself: http://46.137.9.100:1317/)
No CSAS Output Escaper
• What is the #1 web security issue?
    XSS (going to spiral further)

• All templating engines for NodeJS only provide HTML
Context Escaping
     Good, but shouldn’t an excellent new technology
    attempt to fix the remaining BAD things?
        <a href=“$url”> my url </a>
           $url = javascript:alert(1)
        <body onload=“bingbang(‘$id’)”>
           $id = ‘);alert(1);
        <script> var a = $b </script>
           $b = ; alert(0);
        <div name=$c>
           $c =    onload=alert(1);
        many more….

• We ported Google AutoEscape to NodeJS, nicknamed Joe
     Will be open sourced soon…
<!-- Research In Progress -->
• Can you do cross-domain (SetSecurityToken,
  RunInContext)?
  – Exploiting hosted environments
• NPM packages
  – Think external JS. Malicious? Insecure?
  – Now even C libraries
• Are other JSLint bad practices exploitable?
  – Is Automatic Semicolon Insertion exploitable?
  – Many more…. Read “The Good Parts” once again
Training                JSLint



            (SOLUTION)
Secure Dev Frameworks


                         Coding Guideline


        EcmaScript5
Bare bone web server.
                Remember NetBSD?
Isn’t configured / capable more than what you want.
            Unlike Apache, Tomcat, IIS?


                (The Good Parts)
                          But why is it good?
                  More features, bigger attack surface.
       Bigger attack surface, more chances of things going wrong.
            And something that can go wrong will go wrong.
             E.g. 1.3 zillion BO exploits world has seen
// end of a beginning
       twitter: b1shan / yukinying
blog: http://bishankochher.blogspot.com/

Más contenido relacionado

La actualidad más candente

Odoo's Test Framework - Learn Best Practices
Odoo's Test Framework - Learn Best PracticesOdoo's Test Framework - Learn Best Practices
Odoo's Test Framework - Learn Best PracticesOdoo
 
Discover GraphQL with Python, Graphene and Odoo
Discover GraphQL with Python, Graphene and OdooDiscover GraphQL with Python, Graphene and Odoo
Discover GraphQL with Python, Graphene and OdooOdoo
 
[122]책에서는 맛볼 수 없는 HTML5 Canvas 이야기
[122]책에서는 맛볼 수 없는 HTML5 Canvas 이야기 [122]책에서는 맛볼 수 없는 HTML5 Canvas 이야기
[122]책에서는 맛볼 수 없는 HTML5 Canvas 이야기 NAVER D2
 
Front end-security
Front end-securityFront end-security
Front end-securityMiao Siyu
 
Go言語によるwebアプリの作り方
Go言語によるwebアプリの作り方Go言語によるwebアプリの作り方
Go言語によるwebアプリの作り方Yasutaka Kawamoto
 
[111015/아꿈사] HTML5를 여행하는 비(非) 웹 개발자를 위한 안내서 - 1부 웹소켓.
[111015/아꿈사] HTML5를 여행하는 비(非) 웹 개발자를 위한 안내서 - 1부 웹소켓.[111015/아꿈사] HTML5를 여행하는 비(非) 웹 개발자를 위한 안내서 - 1부 웹소켓.
[111015/아꿈사] HTML5를 여행하는 비(非) 웹 개발자를 위한 안내서 - 1부 웹소켓.sung ki choi
 
HBaseCon 2012 | Base Metrics: What They Mean to You - Cloudera
HBaseCon 2012 | Base Metrics: What They Mean to You - ClouderaHBaseCon 2012 | Base Metrics: What They Mean to You - Cloudera
HBaseCon 2012 | Base Metrics: What They Mean to You - ClouderaCloudera, Inc.
 
DOTS - Unity meets Data Oriented Design
DOTS - Unity meets Data Oriented DesignDOTS - Unity meets Data Oriented Design
DOTS - Unity meets Data Oriented DesignDevGAMM Conference
 
VMworld 2013: Extreme Performance Series: Monster Virtual Machines
VMworld 2013: Extreme Performance Series: Monster Virtual Machines VMworld 2013: Extreme Performance Series: Monster Virtual Machines
VMworld 2013: Extreme Performance Series: Monster Virtual Machines VMworld
 
Impact of the New ORM on Your Modules
Impact of the New ORM on Your ModulesImpact of the New ORM on Your Modules
Impact of the New ORM on Your ModulesOdoo
 
CSS Grid Layout for Topconf, Linz
CSS Grid Layout for Topconf, LinzCSS Grid Layout for Topconf, Linz
CSS Grid Layout for Topconf, LinzRachel Andrew
 
Tools for Solving Performance Issues
Tools for Solving Performance IssuesTools for Solving Performance Issues
Tools for Solving Performance IssuesOdoo
 
JavaScript Event Loop
JavaScript Event LoopJavaScript Event Loop
JavaScript Event LoopDesignveloper
 
Basic Concept of Node.js & NPM
Basic Concept of Node.js & NPMBasic Concept of Node.js & NPM
Basic Concept of Node.js & NPMBhargav Anadkat
 
.NET最先端技術によるハイパフォーマンスウェブアプリケーション
.NET最先端技術によるハイパフォーマンスウェブアプリケーション.NET最先端技術によるハイパフォーマンスウェブアプリケーション
.NET最先端技術によるハイパフォーマンスウェブアプリケーションYoshifumi Kawai
 

La actualidad más candente (20)

Ajax and PHP
Ajax and PHPAjax and PHP
Ajax and PHP
 
Odoo's Test Framework - Learn Best Practices
Odoo's Test Framework - Learn Best PracticesOdoo's Test Framework - Learn Best Practices
Odoo's Test Framework - Learn Best Practices
 
Discover GraphQL with Python, Graphene and Odoo
Discover GraphQL with Python, Graphene and OdooDiscover GraphQL with Python, Graphene and Odoo
Discover GraphQL with Python, Graphene and Odoo
 
[122]책에서는 맛볼 수 없는 HTML5 Canvas 이야기
[122]책에서는 맛볼 수 없는 HTML5 Canvas 이야기 [122]책에서는 맛볼 수 없는 HTML5 Canvas 이야기
[122]책에서는 맛볼 수 없는 HTML5 Canvas 이야기
 
Rust
RustRust
Rust
 
Front end-security
Front end-securityFront end-security
Front end-security
 
Go言語によるwebアプリの作り方
Go言語によるwebアプリの作り方Go言語によるwebアプリの作り方
Go言語によるwebアプリの作り方
 
[111015/아꿈사] HTML5를 여행하는 비(非) 웹 개발자를 위한 안내서 - 1부 웹소켓.
[111015/아꿈사] HTML5를 여행하는 비(非) 웹 개발자를 위한 안내서 - 1부 웹소켓.[111015/아꿈사] HTML5를 여행하는 비(非) 웹 개발자를 위한 안내서 - 1부 웹소켓.
[111015/아꿈사] HTML5를 여행하는 비(非) 웹 개발자를 위한 안내서 - 1부 웹소켓.
 
HBaseCon 2012 | Base Metrics: What They Mean to You - Cloudera
HBaseCon 2012 | Base Metrics: What They Mean to You - ClouderaHBaseCon 2012 | Base Metrics: What They Mean to You - Cloudera
HBaseCon 2012 | Base Metrics: What They Mean to You - Cloudera
 
DOTS - Unity meets Data Oriented Design
DOTS - Unity meets Data Oriented DesignDOTS - Unity meets Data Oriented Design
DOTS - Unity meets Data Oriented Design
 
VMworld 2013: Extreme Performance Series: Monster Virtual Machines
VMworld 2013: Extreme Performance Series: Monster Virtual Machines VMworld 2013: Extreme Performance Series: Monster Virtual Machines
VMworld 2013: Extreme Performance Series: Monster Virtual Machines
 
Impact of the New ORM on Your Modules
Impact of the New ORM on Your ModulesImpact of the New ORM on Your Modules
Impact of the New ORM on Your Modules
 
CSS Grid Layout for Topconf, Linz
CSS Grid Layout for Topconf, LinzCSS Grid Layout for Topconf, Linz
CSS Grid Layout for Topconf, Linz
 
GNS3
GNS3GNS3
GNS3
 
Spring Security 3
Spring Security 3Spring Security 3
Spring Security 3
 
Tools for Solving Performance Issues
Tools for Solving Performance IssuesTools for Solving Performance Issues
Tools for Solving Performance Issues
 
An Overview on Nuxt.js
An Overview on Nuxt.jsAn Overview on Nuxt.js
An Overview on Nuxt.js
 
JavaScript Event Loop
JavaScript Event LoopJavaScript Event Loop
JavaScript Event Loop
 
Basic Concept of Node.js & NPM
Basic Concept of Node.js & NPMBasic Concept of Node.js & NPM
Basic Concept of Node.js & NPM
 
.NET最先端技術によるハイパフォーマンスウェブアプリケーション
.NET最先端技術によるハイパフォーマンスウェブアプリケーション.NET最先端技術によるハイパフォーマンスウェブアプリケーション
.NET最先端技術によるハイパフォーマンスウェブアプリケーション
 

Destacado

NodeJS ecosystem
NodeJS ecosystemNodeJS ecosystem
NodeJS ecosystemYukti Kaura
 
Node.js Enterprise Middleware
Node.js Enterprise MiddlewareNode.js Enterprise Middleware
Node.js Enterprise MiddlewareBehrad Zari
 
Apache spark linkedin
Apache spark linkedinApache spark linkedin
Apache spark linkedinYukti Kaura
 
Anatomy of a Modern Node.js Application Architecture
Anatomy of a Modern Node.js Application Architecture Anatomy of a Modern Node.js Application Architecture
Anatomy of a Modern Node.js Application Architecture AppDynamics
 
Microservices Workshop All Topics Deck 2016
Microservices Workshop All Topics Deck 2016Microservices Workshop All Topics Deck 2016
Microservices Workshop All Topics Deck 2016Adrian Cockcroft
 
MicroServices at Netflix - challenges of scale
MicroServices at Netflix - challenges of scaleMicroServices at Netflix - challenges of scale
MicroServices at Netflix - challenges of scaleSudhir Tonse
 
10 Tips for failing at microservices
10 Tips for failing at microservices10 Tips for failing at microservices
10 Tips for failing at microservicesDavid Schmitz
 
The Enterprise Case for Node.js
The Enterprise Case for Node.jsThe Enterprise Case for Node.js
The Enterprise Case for Node.jsNodejsFoundation
 
Principles of microservices velocity
Principles of microservices   velocityPrinciples of microservices   velocity
Principles of microservices velocitySam Newman
 

Destacado (10)

NodeJS ecosystem
NodeJS ecosystemNodeJS ecosystem
NodeJS ecosystem
 
Node.js Enterprise Middleware
Node.js Enterprise MiddlewareNode.js Enterprise Middleware
Node.js Enterprise Middleware
 
Apache spark linkedin
Apache spark linkedinApache spark linkedin
Apache spark linkedin
 
NodeJS for Beginner
NodeJS for BeginnerNodeJS for Beginner
NodeJS for Beginner
 
Anatomy of a Modern Node.js Application Architecture
Anatomy of a Modern Node.js Application Architecture Anatomy of a Modern Node.js Application Architecture
Anatomy of a Modern Node.js Application Architecture
 
Microservices Workshop All Topics Deck 2016
Microservices Workshop All Topics Deck 2016Microservices Workshop All Topics Deck 2016
Microservices Workshop All Topics Deck 2016
 
MicroServices at Netflix - challenges of scale
MicroServices at Netflix - challenges of scaleMicroServices at Netflix - challenges of scale
MicroServices at Netflix - challenges of scale
 
10 Tips for failing at microservices
10 Tips for failing at microservices10 Tips for failing at microservices
10 Tips for failing at microservices
 
The Enterprise Case for Node.js
The Enterprise Case for Node.jsThe Enterprise Case for Node.js
The Enterprise Case for Node.js
 
Principles of microservices velocity
Principles of microservices   velocityPrinciples of microservices   velocity
Principles of microservices velocity
 

Similar a Node Security: The Good, Bad & Ugly

Joxean Koret - Database Security Paradise [Rooted CON 2011]
Joxean Koret - Database Security Paradise [Rooted CON 2011]Joxean Koret - Database Security Paradise [Rooted CON 2011]
Joxean Koret - Database Security Paradise [Rooted CON 2011]RootedCON
 
Cloud Best Practices
Cloud Best PracticesCloud Best Practices
Cloud Best PracticesEric Bottard
 
Fast, concurrent ruby web applications with EventMachine and EM::Synchrony
Fast, concurrent ruby web applications with EventMachine and EM::SynchronyFast, concurrent ruby web applications with EventMachine and EM::Synchrony
Fast, concurrent ruby web applications with EventMachine and EM::SynchronyKyle Drake
 
Frontend automation and stability
Frontend automation and stabilityFrontend automation and stability
Frontend automation and stabilityMáté Nádasdi
 
Node.js: A Guided Tour
Node.js: A Guided TourNode.js: A Guided Tour
Node.js: A Guided Tourcacois
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backendDavid Padbury
 
Why Nodejs Guilin Shanghai
Why Nodejs Guilin ShanghaiWhy Nodejs Guilin Shanghai
Why Nodejs Guilin ShanghaiJackson Tian
 
Why Node.js
Why Node.jsWhy Node.js
Why Node.jsguileen
 
Original slides from Ryan Dahl's NodeJs intro talk
Original slides from Ryan Dahl's NodeJs intro talkOriginal slides from Ryan Dahl's NodeJs intro talk
Original slides from Ryan Dahl's NodeJs intro talkAarti Parikh
 
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)Tech in Asia ID
 
Java Tools and Techniques for Solving Tricky Problem
Java Tools and Techniques for Solving Tricky ProblemJava Tools and Techniques for Solving Tricky Problem
Java Tools and Techniques for Solving Tricky ProblemWill Iverson
 
SXSW 2012 JavaScript MythBusters
SXSW 2012 JavaScript MythBustersSXSW 2012 JavaScript MythBusters
SXSW 2012 JavaScript MythBustersElena-Oana Tabaranu
 
GWT is Smarter Than You
GWT is Smarter Than YouGWT is Smarter Than You
GWT is Smarter Than YouRobert Cooper
 
Intro To Node.js
Intro To Node.jsIntro To Node.js
Intro To Node.jsChris Cowan
 
The Transparent Web: Bridging the Chasm in Web Development
The Transparent Web: Bridging the Chasm in Web DevelopmentThe Transparent Web: Bridging the Chasm in Web Development
The Transparent Web: Bridging the Chasm in Web Developmenttwopoint718
 
TorqueBox at DC:JBUG - November 2011
TorqueBox at DC:JBUG - November 2011TorqueBox at DC:JBUG - November 2011
TorqueBox at DC:JBUG - November 2011bobmcwhirter
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.jsorkaplan
 
Nodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredevNodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredevFelix Geisendörfer
 

Similar a Node Security: The Good, Bad & Ugly (20)

Joxean Koret - Database Security Paradise [Rooted CON 2011]
Joxean Koret - Database Security Paradise [Rooted CON 2011]Joxean Koret - Database Security Paradise [Rooted CON 2011]
Joxean Koret - Database Security Paradise [Rooted CON 2011]
 
Foolangjs
FoolangjsFoolangjs
Foolangjs
 
Cloud Best Practices
Cloud Best PracticesCloud Best Practices
Cloud Best Practices
 
Fast, concurrent ruby web applications with EventMachine and EM::Synchrony
Fast, concurrent ruby web applications with EventMachine and EM::SynchronyFast, concurrent ruby web applications with EventMachine and EM::Synchrony
Fast, concurrent ruby web applications with EventMachine and EM::Synchrony
 
Frontend automation and stability
Frontend automation and stabilityFrontend automation and stability
Frontend automation and stability
 
Node.js: A Guided Tour
Node.js: A Guided TourNode.js: A Guided Tour
Node.js: A Guided Tour
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backend
 
Why Nodejs Guilin Shanghai
Why Nodejs Guilin ShanghaiWhy Nodejs Guilin Shanghai
Why Nodejs Guilin Shanghai
 
Why Node.js
Why Node.jsWhy Node.js
Why Node.js
 
Original slides from Ryan Dahl's NodeJs intro talk
Original slides from Ryan Dahl's NodeJs intro talkOriginal slides from Ryan Dahl's NodeJs intro talk
Original slides from Ryan Dahl's NodeJs intro talk
 
DSLs in JavaScript
DSLs in JavaScriptDSLs in JavaScript
DSLs in JavaScript
 
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
 
Java Tools and Techniques for Solving Tricky Problem
Java Tools and Techniques for Solving Tricky ProblemJava Tools and Techniques for Solving Tricky Problem
Java Tools and Techniques for Solving Tricky Problem
 
SXSW 2012 JavaScript MythBusters
SXSW 2012 JavaScript MythBustersSXSW 2012 JavaScript MythBusters
SXSW 2012 JavaScript MythBusters
 
GWT is Smarter Than You
GWT is Smarter Than YouGWT is Smarter Than You
GWT is Smarter Than You
 
Intro To Node.js
Intro To Node.jsIntro To Node.js
Intro To Node.js
 
The Transparent Web: Bridging the Chasm in Web Development
The Transparent Web: Bridging the Chasm in Web DevelopmentThe Transparent Web: Bridging the Chasm in Web Development
The Transparent Web: Bridging the Chasm in Web Development
 
TorqueBox at DC:JBUG - November 2011
TorqueBox at DC:JBUG - November 2011TorqueBox at DC:JBUG - November 2011
TorqueBox at DC:JBUG - November 2011
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
Nodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredevNodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredev
 

Último

Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 

Último (20)

Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 

Node Security: The Good, Bad & Ugly

  • 2. A look at Server Side JS History. How old do you think it is?
  • 3. 1996 (LiveWire). Rhino (1997). 50+ more since then
  • 4. something went wrong… JS not interesting Slow JS Engines to many JS is Lack of a misunderstood. compelling Under-rated browser war
  • 5. Lead to blazing fast engines Google V8 (NodeJS uses this), The Browser War FF SpiderMonkey, MS Chakra So why now?
  • 6. Why is it so HOT? Speed. Performance. JS to do it all.
  • 9. (5 min Tech Primer) Event-driven. Asynchronous. Single-threaded
  • 10. Traditional Platforms • A sample code data = readFromDatabase(); printData(data); doSomethingUnrelated(); • Pitfalls – The program blocked when reading from db – Lots of processor cycles wasted
  • 11. In Node • A typical code readFromDatabase(function(data) { printData(data); }); doSomethingUnrelated(); • Gains – not have to wait for slow file I/O or db ops. Aka non-blocking server – everything runs in parallel. doSomethingUnrelated() doesn’t wait. – printData(data) called when finished reading – insanely fast – serve millions concurrent connections at once
  • 12. A production Web Framework / MVC Arch. Enter – Express, Mustache, Jade (What is MISSING?) A DB server. Enter – NoSQL (MongoDB, CouchDB) A full stack dev libraries. Enter – NPM
  • 14. “JavaScript has so much expressive power that they are able to do useful things in it, anyway.” http://javascript.crockford.com/javascript.html "JavaScript is the world's most misunderstood programming language.” http://www.crockford.com/javascript/private.html (Mostly B’coz) With Power comes Responsibility
  • 15. Property: Implied Globals Abuse: Namespace Pollution Impact: what’s the worst you can think? (The Ugly Parts) Property: eval (new Function,setTimeout,setInterval) Abuse: JSON Parse, shortcuts Impact: Host Compromise Property: process privilege Abuse: run as root (even Express) Impact: Why does Apache run as nobody/nobody?
  • 16. Global Namespace Pollution JS is a global lang. By default – all variables, functions, objects are implied to global scope (In contrast, with PHP (or others), each request lives in it’s unique scope.)
  • 17. Global Namespace Pollution WEB USER 1 WEB USER 2 # Any request will share the same global scope. # As seen , for two different users, each request increased gbl by 1 (Try yourself: http://46.137.9.100:1314/) An equivalent code in PHP will always print 1 for every request.
  • 18. Exploits: Namespace Pollution • Overriding / Hijacking Sensitive Globals. Host Compromise • How? imagine XSS and SOP. think your browser is now server • Another innocent sample – Bob sets is_valid to true for operation X but forgets to call it as “var”. Y.mojito.controller = { index: function(ac) { var is_valid = true; – Alice coding on the same project also forgets “var” and initialized is_valid to false. Y.mojito.controller = { index: function(ac) { if (is_valid){ // get access to user data or some functions • Attack Surface? – NPM: malicious library. Insecure library – Malicious coder – Innocent coder
  • 19. eval is EVIL USE CASE # treats data as code. Very powerful. Very very popular. EXPLOIT # CODE EXECUTION. COMMAND EXECUTION. SHELL EXECUTION. NEVER USE IT! SIDE NOTE: exists in NPM. Audit. Audit. Audit. eval has cousins – setTimeout, setInterval, new Function. DON‘T USE THEM
  • 20. eval is EVIL Try yourself: http://46.137.9.100:1313 Exploit code: response.end(“my first ssi”)
  • 21. Runtime Privilege Context # By default, NodeJS runs as privileged user # By default, Express runs as privileged user Why? Remote Shell Exploits. Why Apache runs as nobody/nobody?
  • 22. Property: with Property: switch Abuse: shorthand typos Abuse: faulty fallthru Impact: Context dependent Impact: Context dependent (The Bad Parts) Property: single threaded / interpreted Abuse: incomplete exception handling Impact: DoS Property: templating engines [mu, jade, ejs, haml] Abuse: context sensitive output escaping Impact: XSS
  • 23. with is EVIL (exploitable on Cocktails) Use Case# welcome message What went wrong # typo,…
  • 24. with is EVIL (exploitable on Cocktails) Exploit # Depends (Try yourself: http://46.137.9.100:1315/)
  • 25. DoS (*doesn’t affect Express) Generate a simple exception JS is interpreted, NOT compiled. Code itself shouldn’t be faulty. Else it’s a self-DoS. Very difficult to ENSURE this.
  • 26. switch is EVIL (an old foe) Use Case# Valued Customer be given 10% discount only Exploit # missing break leading to privilege escalation
  • 27. switch is EVIL (an old foe) Exploit # Valued Customer getting more discount (Try Yourself: http://46.137.9.100:1317/)
  • 28. No CSAS Output Escaper • What is the #1 web security issue? XSS (going to spiral further) • All templating engines for NodeJS only provide HTML Context Escaping  Good, but shouldn’t an excellent new technology attempt to fix the remaining BAD things?  <a href=“$url”> my url </a> $url = javascript:alert(1)  <body onload=“bingbang(‘$id’)”> $id = ‘);alert(1);  <script> var a = $b </script> $b = ; alert(0);  <div name=$c> $c = onload=alert(1);  many more…. • We ported Google AutoEscape to NodeJS, nicknamed Joe  Will be open sourced soon…
  • 29. <!-- Research In Progress --> • Can you do cross-domain (SetSecurityToken, RunInContext)? – Exploiting hosted environments • NPM packages – Think external JS. Malicious? Insecure? – Now even C libraries • Are other JSLint bad practices exploitable? – Is Automatic Semicolon Insertion exploitable? – Many more…. Read “The Good Parts” once again
  • 30. Training JSLint (SOLUTION) Secure Dev Frameworks Coding Guideline EcmaScript5
  • 31. Bare bone web server. Remember NetBSD? Isn’t configured / capable more than what you want. Unlike Apache, Tomcat, IIS? (The Good Parts) But why is it good? More features, bigger attack surface. Bigger attack surface, more chances of things going wrong. And something that can go wrong will go wrong. E.g. 1.3 zillion BO exploits world has seen
  • 32. // end of a beginning twitter: b1shan / yukinying blog: http://bishankochher.blogspot.com/