Javascript Static Code Analyzer

Slides:



Advertisements
Similar presentations
SYDJS July What is HaXe? Multi-platform language Open source ( Community driven Version 2.07 (around since 2005) Single syntax for.
Advertisements

Copyright © IBM Corp., Introducing the new Web Tools JavaScript™ Features Phil Berkland IBM Software Group 9/26/2007.
GATEKEEPER MOSTLY STATIC ENFORCEMENT OF SECURITY AND RELIABILITY PROPERTIES FOR JAVASCRIPT CODE Salvatore Guarnieri & Benjamin Livshits Presented by Michael.
SableCC SableCC is developed by professors and graduate students at McGill University and is open source (licensed under the Apache License, Version 2.0)‏
SOFTWARE SECURITY JORINA VAN MALSEN 1 FLAX: Systematic Discovery of Client-Side Validation Vulnerabilities in Rich Web Applications.
North Shore.NET User Group Our Sponsors. North Shore.NET User Group Check out our new web site Next Meeting
Static Analysis for Dynamic Assessments Greg Patton | September 2014.
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
UNIT4 BUSINESS ANALYTICS. page WHAT IS THE PRODUCT? 2 A business intelligence tool kit, specializing in Coporate Performance Management An application.
© 2008 Zend Technologies; made available under the EPL v March 2008 PDT – The PHP Development Toolkit Assaf Almaz, PDT co-Project Leader Zend Technologies.
JavaScript Demo Presented by … Jaisingh Sumit jain Sudhindra Taran Deep arora.
ANTLR.
ANTLR Andrew Pangborn & Zach Busser. ANTLR in a Nutshell ANother Tool for Language Recognition generates lexers generates parsers (and parse trees)‏ Java-based,
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 13 Slide 1 Application architectures.
INTRODUCTION TO WEB DATABASE PROGRAMMING
Testing Tools. Categories of testing tools Black box testing, or functional testing Testing performed via GUI. The tool helps in emulating end-user actions.
Title slide to be used at the start of a module. Developing Mobile Apps Roland Guijt
Invitation to Computer Science 5th Edition
Brakeman and Jenkins: The Duo Detects Defects in Ruby on Rails Code Justin Collins Tin Zaw AppSec USA September 23, 2011.
Approaches to Application Security – DSM
A Security Review Process for Existing Software Applications
COP4020 Programming Languages
CSCE 548 Code Review. CSCE Farkas2 Reading This lecture: – McGraw: Chapter 4 – Recommended: Best Practices for Peer Code Review,
Create your own language DESIGN -> PARSE -> INTERPRET.
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
Parser-Driven Games Tool programming © Allan C. Milne Abertay University v
© 2006 IBM Corporation IBM WebSphere Portlet Factory Architecture.
Microsoft Application Virtualization 5.0: Introduction Mohnish Chaturvedi & Ian Bartlett Premier Field Engineer WCL312.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
CSC 338: Compiler design and implementation
Compiler course 1. Introduction. Outline Scope of the course Disciplines involved in it Abstract view for a compiler Front-end and back-end tasks Modules.
© 2012 Pearson Education, Inc. All rights reserved. 1-1 Why Java? Needed program portability – Program written in a language that would run on various.
© 2006 IBM Corporation JDojo & ScriptEngine Agile Planning’s Scripting Tools.
Chapter 6 Programming Languages (2) Introduction to CS 1 st Semester, 2015 Sanghyun Park.
Eagle: Maturation and Evolution 17th Annual Tcl Conference Joe Mistachkin.
BUILD ON THE POLYGLOT COMPILER FRAMEWORK MIHAL BRUMBULLI 7th Workshop “SEERE” Montenegro-Risan 9-14 September 2007 SimJ Programming Language.
Static Analysis James Walden Northern Kentucky University.
Finding Security Vulnerabilities in Java Applications with Static Analysis Reviewed by Roy Ford.
DEV333 Instrumenting Applications for Manageability with the Enterprise Instrumentation Framework David Keogh Program Manager Visual Studio Enterprise.
Towards the better software metrics tool motivation and the first experiences Gordana Rakić Zoran Budimac.
COP 4620 / 5625 Programming Language Translation / Compiler Writing Fall 2003 Lecture 1, 08/28/03 Prof. Roy Levow.
Compiler design Lecture 1: Compiler Overview Sulaimany University 2 Oct
CS 460/660 Compiler Construction. Class 01 2 Why Study Compilers? Compilers are important – –Responsible for many aspects of system performance Compilers.
Introduction to Compilers. Related Area Programming languages Machine architecture Language theory Algorithms Data structures Operating systems Software.
Cross Language Clone Analysis Team 2 October 13, 2010.
Test Specifications A Specification System for Multi-Platform Test Suite Configuration, Build, and Execution Greg Cooksey.
. n COMPILERS n n AND n n INTERPRETERS. -Compilers nA compiler is a program thatt reads a program written in one language - the source language- and translates.
© 2008 by Shawn Spiars; made available under the EPL v1.0 | March 17, 2008 Case Study – Phurnace Software and RCP Shawn Spiars Lead UI Developer Phurnace.
Cross Language Clone Analysis Team 2 February 3, 2011.
Plug-in Architectures Presented by Truc Nguyen. What’s a plug-in? “a type of program that tightly integrates with a larger application to add a special.
Cross Language Clone Analysis Team 2 November 10, 2010.
 Fall Chart 2  Translators and Compilers  Textbook o Programming Language Processors in Java, Authors: David A. Watts & Deryck F. Brown, 2000,
Cross Language Clone Analysis Team 2 February 3, 2011.
Dr. Mohamed Ramadan Saady 314ALL CH1.1 Chapter 1: Introduction to Compiling.
FUNCTIONAL PROGRAMING AT WORK - HASKELL AND DOMAIN SPECIFIC LANGUAGES Dr. John Peterson Western State Colorado University.
1 Asstt. Prof Navjot Kaur Computer Dept PRESENTED BY.
MiniJava Compiler A multi-back-end JIT compiler of Java.
COP4020 Programming Languages Introduction Prof. Robert van Engelen (modified by Prof. Em. Chris Lacher)
DevCOP: A Software Certificate Management System for Eclipse Mark Sherriff and Laurie Williams North Carolina State University ISSRE ’06 November 10, 2006.
 Can access all API’s made available by OS vendor.  SDK’s are platform-specific.  Each mobile OS comes with its own unique tools and GUI toolkit.
NativeScript – Open source platform to build Native iOS/Android Apps.
Programming Languages Concepts Chapter 1: Programming Languages Concepts Lecture # 4.
Node.js Modules Header Mastering Node.js, Part 2 Eric W. Greene
Introduction to Compiler Construction
Static Detection of Cross-Site Scripting Vulnerabilities
JavaScript an introduction.
SoarUnit Bob Marinier 11/29/2018.
AJAX Toolkit Framework
Advanced Compiler Design
Introduce to Angular 6 Present by: Võ Văn Hào
Presentation transcript:

Javascript Static Code Analyzer Héctor Quartino hector@quartino.info hquartino@netsuite.com

About me 10+ years of developer experience. Multiple languages / technologies (Java, C#, JS). Curious about Security for a while. AppSec Engineer @ NetSuite.

About this talk Motivation. A bit of theory on the concepts behind static code analyzers. Related Javascript tools. Why would one want to use a Javascript Static Code Analyzer in Javascript? How does a Static Code Analyzer work? Can one leverage existing tools from the Javascript community to achieve this goal?

Static Code Analysis – What & Why? Runs on source code (white-box testing). Can use project specific rules. Can be automated. Highly effective with specific patterns. Early detection of potential issues. Static Code Analyzers are thorough and consistent (unlike a human ). Early detection is paramount because it makes it faster & cheaper to fix defects.

Why analyze Javascript code? Scripting language of the Web. Web Applications vs. Native Apps on mobile. JavaScript Server Applications Rhino NodeJS IoT Embedded Devices Home Automation Robotics DIY Trend of WebApps: websites are nowadays full fledged apps. War of native applications: should one do a native app or do a shell that contains a WebApp? Server Applications: Javascript is here to stay, with Node being available on as many platforms as Java (and there are even projects that run Node applications in JEE containers). IoT: Bring the RPi!

Why a Javascript Static Code Analyzer? Scenario of 100% Javascript Applications is more common. Testing infrastructure in Javascript too! Goal: One language can give more flexibility to teams. Goal: Run static code analysis on CI / nightly builds. Goal: Leverage existing tools available in the Javascript community. One language means that developers and quality engineers from different layers do not have a language barrier.

Static Code Analysis Limitations False positives Need a way to filter successive scan results. False negatives Some vulnerabilities need to be discovered via dynamic code analysis. Unaware of custom APIs, cross layer vulnerabilities, or configuration files. Add custom rules to mitigate.

A few compiler concepts Compiler: transforms code from one language to another. Input Lexer Tokens Parser AST Optimizer IR Generator Output

A few compiler concepts Compiler: transforms code from one language to another. Input Lexer Tokens Parser AST Optimizer IR Generator Output For many languages, the compiler already catches some types of bugs, i.e. type checking errors. Used by Static Analysis

A few compiler concepts (cont.) Lexer: transforms code into tokens. Lexical Grammar Type Value Keyword var Identifier foo Punctuator = bar ; Input Lexer Tokens var foo = bar;

A few compiler concepts (cont.) Parser: transforms tokens into AST. Abstract Syntax Tree: represents program structure. Syntactic Grammar Type Value Keyword var Identifier foo Punctuator = bar ; VariableDeclaration Tokens Parser AST foo bar

A few Static Code Analyzer techniques Data Flow Analysis Collect dynamic information about data by analyzing static information. Determine the Control Flows for a given program. pathA if (a > 1) { pathA(a); } else { pathB(1); } if end-if pathB

A few Static Code Analyzer techniques Taint Analysis: Trace variables from user inputs (taints) to potentially vulnerable functions (sinks). var searchTerms = $('q').val(); var trimmedSearchTerms = searchTerms.trim(); // … code displaySearchResults(trimmedSearchTerms, results);   function displaySearchResults(terms, results) { $(selector).append(terms); // XSS } Taints that are used by sinks without proper sanitization can lead to security vulnerabilities. Taint Analysis is a hard problem to resolve in Javascript due to its dynamic features (eval, variadic arguments, dynamic typing). This is an open avenue for additional Javascript tools.

Javascript Tools Parser: Esprima, Acorn. AST: ESTree. Code Analyzer: ScanJS. Code Analyzer, take 2: ESLint.

Esprima Standard ECMAScript parser written in ECMAScript. Supports ES6. Standard AST based on ESTree project. Heavily used, some examples: Code Minifier: esmangle Code Instrumentation: Instanbul ES6 to ES5 transpiler: esnext (uses Espree)

ESTree DEMO De facto standard AST specification. Originated as part of SpiderMonkey’s Parser API. Lots of manipulation tools available. DEMO Short Demo of AST explorer http://astexplorer.net/ Focus on the JSON format, describe the general aspects of the format A nice summary of ECMAScript AST Tools: https://github.com/estools

ScanJS DEMO Focused on client-side web applications. Web UI, no command line tools makes it hard to integrate with build tools. Developed by Mozilla, unfortunately deprecated, but lives on as plugin for ESLint: eslint-config-scanjs. Short demo of the ScanJS UI and scan results. DEMO

ESLint Uses Espree (fork of Esprima) for parsing. Pluggable architecture: All rules are plugins, more can be added at runtime. Different parsers can be used (Esprima, Espree or Babel are currently compatible). Language extensions specified at configuration. Global variables predefined through Environments. Integrates with editors, build systems, command line tools, and more! Talk about some of the integrations: http://eslint.org/docs/user-guide/integrations

DEMO Demo of ESLint in a sample project using custom rules.

Q&A

Reference material Esprima: http://esprima.org/ ESTree spec: https://github.com/estree/estree/blob/master/spec.md ESTools projects: https://github.com/estools ESLint: http://eslint.org/ ESLint integrations: http://eslint.org/docs/user-guide/integrations ScanJS ESLint Plugin: https://github.com/mozfreddyb/eslint-config-scanjs ScanJS ESLint Rules: https://github.com/mozfreddyb/eslint-plugin-scanjs-rules