JSON, ADsafe, and Misty Douglas Crockford Yahoo!.

Slides:



Advertisements
Similar presentations
Ajax Security Douglas Crockford Yahoo! javascript.crockford.com/security.ppt.
Advertisements

The JavaScript Programming Language
JavaScript: A Language of Many Contrasts
Secure ECMAScript Name Subject To Change
Introduction to Java 2 Programming Lecture 3 Writing Java Applications, Java Development Tools.
Chapter 7 Constructors and Other Tools. Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 7-2 Learning Objectives Constructors Definitions.
Special Topic JSON. Introducing JSON JSON (JavaScript ObjectNotation): A data format based on the object literal format Advantage of JSON over XML – JSON.
Singleton vs utility class  at first glance, the singleton pattern does not seem to offer any advantages to using a utility class  i.e., a utility class.
Composition CMSC 202. Code Reuse Effective software development relies on reusing existing code. Code reuse must be more than just copying code and changing.
Today Programming Style and Your Brain And Then There Was JavaScript Function the Ultimate The Metamorphosis of Ajax ES5: The New Parts.
An Evaluation of the Google Chrome Extension Security Architecture
Advanced JS The World's Most Misunderstood Programming Language ) Douglas Crockford( Shimon Dahan
An Empirical Study on the Rewritability of the with Statement in JavaScript Changhee Park (Joint work with Hongki Lee and Sukyoung Ryu) KAIST October.
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
Gatekeeper : Mostly Static Enforcement of Security & Reliability Policies for JavaScript Code Ben Livshits Salvatore Guarnieri.
Slides prepared by Rose Williams, Binghamton University Chapter 13 Interfaces and Inner Classes.
Kevin Reuter & Brian Guthrie.  Multi-paradigm  Prototype based objects  Dynamic, weak typing.
Taking JavaScript Seriously IS NOT THE WORST IDEA.
Programming Languages and Paradigms Object-Oriented Programming.
Chapter 12: Adding Functionality to Your Classes.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 13: Pointers, Classes, Virtual Functions, and Abstract Classes.
REFACTORING Lecture 4. Definition Refactoring is a process of changing the internal structure of the program, not affecting its external behavior and.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 14: Pointers, Classes, Virtual Functions, and Abstract Classes.
NDSS 2007 Philipp Vogt, Florian Nentwich, Nenad Jovanovic, Engin Kirda, Christopher Kruegel, Giovanni Vigna.
Operator Precedence First the contents of all parentheses are evaluated beginning with the innermost set of parenthesis. Second all multiplications, divisions,
1 JavaScript. 2 What’s wrong with JavaScript? A very powerful language, yet –Often hated –Browser inconsistencies –Misunderstood –Developers find it painful.
CSCI 6962: Server-side Design and Programming Web Services.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Classes: A Deeper Look Part.
SE-2840 Dr. Mark L. Hornick 1 Modifying webpage behavior using client-side scripting Javascript.
Introduction to JavaScript Gordon Tian
Chapter 6 Object-Oriented Java Script JavaScript, Third Edition.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
Objects and Classes Chapter 6 CSCI CSCI 1302 – Objects and Classes2 Outline Introduction Defining Classes for Objects Constructing Objects Accessing.
JavaScript Syntax and Semantics. Slide 2 Lecture Overview Core JavaScript Syntax (I will not review every nuance of the language)
Pointers and Dynamic Memory Allocation Copyright Kip Irvine 2003, all rights reserved. Revised 10/28/2003.
CSE 341 Lecture 29 a JavaScript, the bad parts slides created by Marty Stepp see also: JavaScript: The Good Parts, by.
ICOM 4035 – Data Structures Dr. Manuel Rodríguez Martínez Electrical and Computer Engineering Department.
Secure ECMAScript Name Subject To Change Douglas Crockford Yahoo!
Java Basics Opening Discussion zWhat did we talk about last class? zWhat are the basic constructs in the programming languages you are familiar.
 Objects versus Class  Three main concepts of OOP ◦ Encapsulation ◦ Inheritance ◦ Polymorphism  Method ◦ Parameterized ◦ Value-Returning.
Chapter 10: Classes and Data Abstraction. Objectives In this chapter, you will: Learn about classes Learn about private, protected, and public members.
CS-1030 Dr. Mark L. Hornick 1 Basic C++ State the difference between a function/class declaration and a function/class definition. Explain the purpose.
Introduction to Object-Oriented Programming Lesson 2.
“The world’s most misunderstood language has become the world’s most popular programming language” Akshay Arora
Inheritance and Polymorphism. Superclass and Subclass Inheritance defines a relationship between objects that share characteristics. It is a mechanism.
Rich Internet Applications 2. Core JavaScript. The importance of JavaScript Many choices open to the developer for server-side Can choose server technology.
MIT-AITI: Functions Defining and Invoking Functions Functions as Data Function Scope: The call Object Function Arguments: The arguments objects Function.
Chapter 10: Classes and Data Abstraction. Classes Object-oriented design (OOD): a problem solving methodology Objects: components of a solution Class:
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
Javascript Prof. Wenwen Li School of Geographical Sciences and Urban Planning 5644 Coor Hall
Copyright © 2002 Pearson Education, Inc. Slide 1.
Copyright © 2002 Pearson Education, Inc. Slide 1.
Introduction to JavaScript MIS 3502, Fall 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 9/29/2016.
Dynamic Storage Allocation
JavaScript: Good Practices
Friend Class Friend Class A friend class can access private and protected members of other class in which it is declared as friend. It is sometimes useful.
Modern JavaScript Develop And Design
JavaScript Syntax and Semantics
Web Systems Development (CSC-215)
Constructors and Other Tools
CS5220 Advanced Topics in Web Programming JavaScript Basics
CS3220 Web and Internet Programming JavaScript Basics
JavaScript CS 4640 Programming Languages for Web Applications
Chap 2. Identifiers, Keywords, and Types
CS3220 Web and Internet Programming JavaScript Basics
Corresponds with Chapter 5
SPL – PS1 Introduction to C++.
JavaScript CS 4640 Programming Languages for Web Applications
SPL – PS3 C++ Classes.
Threads and concurrency / Safety
Presentation transcript:

JSON, ADsafe, and Misty Douglas Crockford Yahoo!

JSON was the first safe subset It starts with JavaScript array literals and object literals, and removes all behavior, yielding a convenient data format.

ADsafe A system for safe web advertising.

Static validation only, no code rewriting. No impact on performance. JSLint is an ADsafe validator.

ADsafe ADsafe is a JavaScript subset that adds capability discipline by deleting features that cause capability leakage. No global variables or functions may be defined. No global variables or functions can be accessed except the ADSAFE object. Use of the [] subscript operator is limited. These words cannot be used: apply arguments call callee caller constructor eval prototype unwatch valueOf watch Words starting with _ cannot be used.

Impact on the programming model Use of [ ] for subscripting is extremely limited. ADSAFE.get( name ) and ADSAFE.set( name, value ) must be used instead. This can be annoying. this cannot be used because it can be made to bind to the global object. JavaScript is still quite useable without this.

Constructor Recipe 1.Make an object. Object literal new Object.create call another constructor

Constructor Recipe 1.Make an object. Object literal, new, Object.create, call another constructor 2.Define some variables and functions. These become private members and private methods of the new object.

Constructor Recipe 1.Make an object. Object literal, new, Object.create, call another constructor 2.Define some variables and functions. These become private members. 3.Augment the object with privileged methods.

Constructor Recipe 1.Make an object. Object literal, new, Object.create, call another constructor 2.Define some variables and functions. These become private members. 3.Augment the object with privileged methods. 4.Return the object.

Step One function myConstructor(x) { var that = otherMaker(x); }

Step Two function myConstructor(x) { var that = otherMaker(x); var secret = f(x); }

Step Three function myConstructor(x) { var that = otherMaker(x); var secret = f(x); that.priv = function () {... secret x... }; } The methods should use neither this nor that.

Step Four function myConstructor(x) { var that = otherMaker(x); var secret = f(x); that.priv = function () {... secret x... }; return that; }

Objects made with this pattern do not need hardening. Object tampering does not cause confusion.

ADsafe does not allow access to Date or random This is to allow human evaluation of ad content with confidence that behavior will not change in the future. This is for ad quality and contractual compliance, not for security.

ADsafe DOM Interface Light weight. JQuery-like. Scope of queries is strictly limited to the contents of a the widget's. Guest code cannot get direct access to any DOM node.

Widget Template HTML content goes here. "use strict"; ADSAFE.id("ADSAFEID_"); "use strict"; ADSAFE.go("ADSAFEID_", function (dom, lib) { Application initialization goes here. });

Library Template "use strict"; ADSAFE.lib("libraryname", function () { Create that library object return that; }); The widget accesses the library object with lib.libraryname.

ADsafe validation is not destructive, so it can be performed at any and every point in the ad delivery pipeline. It can even be done after consumer delivery to test compliance.

Multiple points of validation provide greater confidence that bad content will be blocked.

Dangers There may still be undiscovered weaknesses in ECMAScript and its many implementations. Those implementations are changing, introducing new weaknesses. The wrappers must be flawless. We are still subject to XSS attacks.

Misty An experimental object capability language.

Goal: Correct every problem in JavaScript Reasonable people will disagree on what the problems actually are.

Misty Objectives Make the language easier for beginners. Make the language unastonishing and low cruft. Make the language an object capability language.

Syntax := for assignment = for identity + for addition & for concatenation No semicolons. No blocks. for i to length koda do if koda[i].id is null then raise 'misshapen' fi od

No Global Object Each compilation unit is a function body, which gets the capability to return an object that exposes an interface that can be used by other compilation units. Compilation units share a vat, so communication is very fast. They can directly invoke methods. They can share object references.

Misty Object Hardening The fix operator produces an immutable reference. The original object is still mutable, but it cannot be changed with the fixed reference. define frozen := fix my_object frozen and my_object are references to the same object, but the frozen reference is attenuated. my_object.works := true frozen.works := false # raise 'fix'

Fixed References A fixed reference cannot be used to modify an object. All references obtained with a fixed reference will be fixed. This avoids the ICE-9 problem. Function values cannot be obtained with a fixed reference. The functions can only be invoked. This prevents confusion.

Methods A method can obtain a reference to the object of interest with the $ operator. A function that uses $ can only be called as a method. The $ operator can modify the object even if the object was fixed. $.status := true # succeeds struct := $.struct # struct is fixed return $ # returns fixed

$ could be viewed as a rights amplification, but it is only available to functions that are added to the object before it is fixed.

Simplicity Very simple operation. Just fix references before handing objects to strange code. Your own code is not inconvenienced by fixing. This level of simplicity is required for successful adoption.