SlideShare une entreprise Scribd logo
1  sur  32
Télécharger pour lire hors ligne
On Contracts, Sandboxes,
and Proxies for JavaScript
Matthias Keil, Peter Thiemann
University of Freiburg, Germany
October 5, 2015, 18. Kolloquium Programmiersprachen und Grundlagen der Programmierung, KPS 2015
P¨ortschach am W¨orthersee, ¨Osterreich
TreatJS
Language embedded contract system for JavaScript
Enforced by run-time monitoring
Standard abstractions for higher-order-contracts (base,
function, and dependent contracts) [Findler,Felleisen’02]
Systematic blame calculation
Contract constructors generalize dependent contracts
Internal noninterference
Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 2 / 14
Base Contract [Findler,Felleisen’02]
Base Contracts are built from predicates
Specified by a plain JavaScript function
Base Contract
function isNumber (arg) {
return (typeof arg) === ’number’;
};
var Number = Contract.Base(isNumber);
assert(1, Number ); 
assert(’a’, Number );  blame the subject
Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 3 / 14
Function Contract [Findler,Felleisen’02]
// Number × Number → Number
function plus (x, y) {
return (x + y);
}
Function Contract
var Plus = Contract.Function([ Number , Number ],
Number );
var plusNumber = assert(plus, Plus );
plusNumber(1, 1); 
plusNumber(’a’, ’a’);  blame the context
Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 4 / 14
JavaScript Proxies
Handler
Proxy Target Shadow
Meta-Level
Base-Level
Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 5 / 14
JavaScript Proxies
Handler
Proxy Target Shadow
proxy.x;
Meta-Level
Base-Level
Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 5 / 14
JavaScript Proxies
Handler
Proxy Target Shadow
proxy.x;
handler.get(target, ’x’, proxy);
Meta-Level
Base-Level
Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 5 / 14
JavaScript Proxies
Handler
Proxy Target Shadow
proxy.x;
handler.get(target, ’x’, proxy);
target[’x’];
Meta-Level
Base-Level
Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 5 / 14
JavaScript Proxies
Handler
Proxy Target Shadow
proxy.x;
proxy.y=1;
...
handler.get(target, ’x’, proxy);
handler.set(target, ’y’, 1, proxy);
...
target[’x’];
target[’y’]=1;
...
Meta-Level
Base-Level
Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 5 / 14
Noninterference
Noninterference
The contract system should not interfere with the execution of
application code.
External Noninterference arises from the interaction of the
contract system with the host program
1 Exceptions
2 Object equality
Internal Noninterference arises from executing unrestricted
code in predicates
Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 6 / 14
Internal Noninterference
No syntactic restrictions on predicates
Predicates may try to write to data that is visible to the
application
Solution: Predicate evaluation takes place in a sandbox
Faulty Predicate
function isNumber (arg) {
type = (typeof arg);
return type === ’number’;
};
Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 7 / 14
Internal Noninterference
No syntactic restrictions on predicates
Predicates may try to write to data that is visible to the
application
Solution: Predicate evaluation takes place in a sandbox
Faulty Predicate
function isNumber (arg) {
type = (typeof arg);  access forbidden
return type === ’number’;
};
Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 7 / 14
TreatJS Sandbox
All contracts guarantee noninterference
Read-only access is safe
Predicate with Read-Access
function isArray (arg) {
return (arg instanceof Array); 
}
Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 8 / 14
TreatJS Sandbox
Predicate execution may violate contracts
Solution: Sandbox redefines the responsibility
Predicate with Read-Access
function addOne (arg) {
return plusNumber(arg, ’1’);  blame the ?
}
Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 9 / 14
TreatJS Sandbox
Predicate execution may violate contracts
Solution: Sandbox redefines the responsibility
Predicate with Read-Access
function addOne (arg) {
return plusNumber(arg, ’1’);  blame the contract
}
Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 9 / 14
Sandbox Encapsulation
Faulty Predicate
function isNumber (arg) {
type = (typeof arg);
return type === ’number’;
};
1 Place a write protection on objects (e.g. this, arg)
2 Remove external bindings of functions (e.g. type)
Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 10 / 14
Identity Preserving Membrane
ProxyA
?ProxyB
ProxyC
TargetA
TargetB
TargetC
Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 11 / 14
Identity Preserving Membrane
ProxyA
?ProxyB
ProxyC
TargetA
TargetB
TargetC
x
Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 11 / 14
Identity Preserving Membrane
ProxyA
?ProxyB
ProxyC
TargetA
TargetB
TargetC
x x
Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 11 / 14
Identity Preserving Membrane
ProxyA
?ProxyB
ProxyC
TargetA
TargetB
TargetC
x x
Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 11 / 14
Identity Preserving Membrane
ProxyA
?ProxyB
ProxyC
TargetA
TargetB
TargetC
x
y
x
y
Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 11 / 14
Identity Preserving Membrane
ProxyA
?ProxyB
ProxyC
TargetA
TargetB
TargetC
x
z
y
x
z
y
Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 11 / 14
Shadow Objects
Handler
Proxy Target Shadow
proxy.x;
proxy.y=1;
handler.get(target, ’x’, proxy);
handler.set(target, ’y’, 1, proxy);
target[’x’];
target[’y’]=1;
Meta-Level
Base-Level
Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 12 / 14
Shadow Objects
Handler
Proxy Target Shadow
Meta-Level
Base-Level
Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 12 / 14
Shadow Objects
Handler
Proxy Target Shadow
proxy.x;
handler.get(target, ’x’, proxy);
target[’x’];
Meta-Level
Base-Level
Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 12 / 14
Shadow Objects
Handler
Proxy Target Shadow
proxy.x;
proxy.y=1;
handler.get(target, ’x’, proxy);
handler.set(target, ’y’, 1, proxy);
target[’x’]; shadow[’y’]=1;
Meta-Level
Base-Level
Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 12 / 14
Shadow Objects
Handler
Proxy Target Shadow
proxy.x;
proxy.y=1;
proxy.y;
handler.get(target, ’x’, proxy);
handler.set(target, ’y’, 1, proxy);
handler.get(target, ’y’, proxy);
target[’x’]; shadow[’y’]=1;
shadow[’y’];
Meta-Level
Base-Level
Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 12 / 14
Function Recompilation
var x = 1;
function f (){
function g (y) {
var z = 1;
return x+y+z;
}
}
Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 13 / 14
Function Recompilation
var x = 1;
function f (){
”function g (y) {
var z = 1;
return x+y+z;
}”
}
Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 13 / 14
Function Recompilation
var x = 1;
with(sbxglobal){
eval( ”function g (y) {
var z = 1;
return x+y+z;
}”);
}
Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 13 / 14
Function Recompilation
var x = 1;
with(sbxglobal){
function g (y) {
var z = 1;
return x+y+z;
}
}
Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 13 / 14
Conclusion
TreatJS:
Language embedded, dynamic, higher-order contract system
for full JavaScript
Guarantees noninterference
Sandbox:
Language embedded sandbox for full JavaScript
Runs JavaScript code in isolation isolation
Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 14 / 14

Contenu connexe

En vedette (10)

100 років унр зош19
100 років унр  зош19100 років унр  зош19
100 років унр зош19
 
на сайт про права дитини
на сайт про права дитинина сайт про права дитини
на сайт про права дитини
 
документ Microsoft word
документ Microsoft wordдокумент Microsoft word
документ Microsoft word
 
білицька зош 8. свято україночка 2017.
білицька зош 8. свято україночка 2017.білицька зош 8. свято україночка 2017.
білицька зош 8. свято україночка 2017.
 
пожарные
пожарныепожарные
пожарные
 
Drug approval process
Drug approval processDrug approval process
Drug approval process
 
зош № 9 день добровольця
зош № 9 день добровольцязош № 9 день добровольця
зош № 9 день добровольця
 
100 річчя оригинал
100 річчя оригинал100 річчя оригинал
100 річчя оригинал
 
Sibylle Rudin: Erlebnis Bibliothek: Wiki für die Schule
Sibylle Rudin: Erlebnis Bibliothek: Wiki für die SchuleSibylle Rudin: Erlebnis Bibliothek: Wiki für die Schule
Sibylle Rudin: Erlebnis Bibliothek: Wiki für die Schule
 
Compu training (1)
Compu training (1)Compu training (1)
Compu training (1)
 

Similaire à On Contracts, Sandboxes, and Proxies for JavaScript

Similaire à On Contracts, Sandboxes, and Proxies for JavaScript (6)

On Contracts and Sandboxes for JavaScript
On Contracts and Sandboxes for JavaScriptOn Contracts and Sandboxes for JavaScript
On Contracts and Sandboxes for JavaScript
 
Transparent Object Proxies for JavaScript
Transparent Object Proxies for JavaScriptTransparent Object Proxies for JavaScript
Transparent Object Proxies for JavaScript
 
Efficient Dynamic Access Analysis Using JavaScript Proxies
Efficient Dynamic Access Analysis Using JavaScript ProxiesEfficient Dynamic Access Analysis Using JavaScript Proxies
Efficient Dynamic Access Analysis Using JavaScript Proxies
 
Building a (Really) Secure Cloud Product
Building a (Really) Secure Cloud ProductBuilding a (Really) Secure Cloud Product
Building a (Really) Secure Cloud Product
 
Interacting with the Exchange Web Services
Interacting with the Exchange Web ServicesInteracting with the Exchange Web Services
Interacting with the Exchange Web Services
 
Istio Cloud Native Online Series - Intro to Istio Security
Istio Cloud Native Online Series - Intro to Istio SecurityIstio Cloud Native Online Series - Intro to Istio Security
Istio Cloud Native Online Series - Intro to Istio Security
 

Plus de Matthias Keil (6)

Blame Assignment for Higher-Order Contracts with Intersection and Union
Blame Assignment for Higher-Order Contracts with Intersection and UnionBlame Assignment for Higher-Order Contracts with Intersection and Union
Blame Assignment for Higher-Order Contracts with Intersection and Union
 
TreatJS: Higher-Order Contracts for JavaScripts
TreatJS: Higher-Order Contracts for JavaScriptsTreatJS: Higher-Order Contracts for JavaScripts
TreatJS: Higher-Order Contracts for JavaScripts
 
Symbolic Solving of Extended Regular Expression Inequalities
Symbolic Solving of Extended Regular Expression InequalitiesSymbolic Solving of Extended Regular Expression Inequalities
Symbolic Solving of Extended Regular Expression Inequalities
 
TreatJS: Higher-Order Contracts for JavaScript
TreatJS: Higher-Order Contracts for JavaScriptTreatJS: Higher-Order Contracts for JavaScript
TreatJS: Higher-Order Contracts for JavaScript
 
Type-based Dependency Analysis for JavaScript
Type-based Dependency Analysis for JavaScriptType-based Dependency Analysis for JavaScript
Type-based Dependency Analysis for JavaScript
 
Type-based Dependency Analysis
Type-based Dependency AnalysisType-based Dependency Analysis
Type-based Dependency Analysis
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Dernier (20)

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 

On Contracts, Sandboxes, and Proxies for JavaScript

  • 1. On Contracts, Sandboxes, and Proxies for JavaScript Matthias Keil, Peter Thiemann University of Freiburg, Germany October 5, 2015, 18. Kolloquium Programmiersprachen und Grundlagen der Programmierung, KPS 2015 P¨ortschach am W¨orthersee, ¨Osterreich
  • 2. TreatJS Language embedded contract system for JavaScript Enforced by run-time monitoring Standard abstractions for higher-order-contracts (base, function, and dependent contracts) [Findler,Felleisen’02] Systematic blame calculation Contract constructors generalize dependent contracts Internal noninterference Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 2 / 14
  • 3. Base Contract [Findler,Felleisen’02] Base Contracts are built from predicates Specified by a plain JavaScript function Base Contract function isNumber (arg) { return (typeof arg) === ’number’; }; var Number = Contract.Base(isNumber); assert(1, Number ); assert(’a’, Number ); blame the subject Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 3 / 14
  • 4. Function Contract [Findler,Felleisen’02] // Number × Number → Number function plus (x, y) { return (x + y); } Function Contract var Plus = Contract.Function([ Number , Number ], Number ); var plusNumber = assert(plus, Plus ); plusNumber(1, 1); plusNumber(’a’, ’a’); blame the context Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 4 / 14
  • 5. JavaScript Proxies Handler Proxy Target Shadow Meta-Level Base-Level Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 5 / 14
  • 6. JavaScript Proxies Handler Proxy Target Shadow proxy.x; Meta-Level Base-Level Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 5 / 14
  • 7. JavaScript Proxies Handler Proxy Target Shadow proxy.x; handler.get(target, ’x’, proxy); Meta-Level Base-Level Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 5 / 14
  • 8. JavaScript Proxies Handler Proxy Target Shadow proxy.x; handler.get(target, ’x’, proxy); target[’x’]; Meta-Level Base-Level Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 5 / 14
  • 9. JavaScript Proxies Handler Proxy Target Shadow proxy.x; proxy.y=1; ... handler.get(target, ’x’, proxy); handler.set(target, ’y’, 1, proxy); ... target[’x’]; target[’y’]=1; ... Meta-Level Base-Level Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 5 / 14
  • 10. Noninterference Noninterference The contract system should not interfere with the execution of application code. External Noninterference arises from the interaction of the contract system with the host program 1 Exceptions 2 Object equality Internal Noninterference arises from executing unrestricted code in predicates Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 6 / 14
  • 11. Internal Noninterference No syntactic restrictions on predicates Predicates may try to write to data that is visible to the application Solution: Predicate evaluation takes place in a sandbox Faulty Predicate function isNumber (arg) { type = (typeof arg); return type === ’number’; }; Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 7 / 14
  • 12. Internal Noninterference No syntactic restrictions on predicates Predicates may try to write to data that is visible to the application Solution: Predicate evaluation takes place in a sandbox Faulty Predicate function isNumber (arg) { type = (typeof arg); access forbidden return type === ’number’; }; Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 7 / 14
  • 13. TreatJS Sandbox All contracts guarantee noninterference Read-only access is safe Predicate with Read-Access function isArray (arg) { return (arg instanceof Array); } Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 8 / 14
  • 14. TreatJS Sandbox Predicate execution may violate contracts Solution: Sandbox redefines the responsibility Predicate with Read-Access function addOne (arg) { return plusNumber(arg, ’1’); blame the ? } Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 9 / 14
  • 15. TreatJS Sandbox Predicate execution may violate contracts Solution: Sandbox redefines the responsibility Predicate with Read-Access function addOne (arg) { return plusNumber(arg, ’1’); blame the contract } Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 9 / 14
  • 16. Sandbox Encapsulation Faulty Predicate function isNumber (arg) { type = (typeof arg); return type === ’number’; }; 1 Place a write protection on objects (e.g. this, arg) 2 Remove external bindings of functions (e.g. type) Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 10 / 14
  • 17. Identity Preserving Membrane ProxyA ?ProxyB ProxyC TargetA TargetB TargetC Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 11 / 14
  • 18. Identity Preserving Membrane ProxyA ?ProxyB ProxyC TargetA TargetB TargetC x Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 11 / 14
  • 19. Identity Preserving Membrane ProxyA ?ProxyB ProxyC TargetA TargetB TargetC x x Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 11 / 14
  • 20. Identity Preserving Membrane ProxyA ?ProxyB ProxyC TargetA TargetB TargetC x x Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 11 / 14
  • 21. Identity Preserving Membrane ProxyA ?ProxyB ProxyC TargetA TargetB TargetC x y x y Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 11 / 14
  • 22. Identity Preserving Membrane ProxyA ?ProxyB ProxyC TargetA TargetB TargetC x z y x z y Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 11 / 14
  • 23. Shadow Objects Handler Proxy Target Shadow proxy.x; proxy.y=1; handler.get(target, ’x’, proxy); handler.set(target, ’y’, 1, proxy); target[’x’]; target[’y’]=1; Meta-Level Base-Level Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 12 / 14
  • 24. Shadow Objects Handler Proxy Target Shadow Meta-Level Base-Level Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 12 / 14
  • 25. Shadow Objects Handler Proxy Target Shadow proxy.x; handler.get(target, ’x’, proxy); target[’x’]; Meta-Level Base-Level Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 12 / 14
  • 26. Shadow Objects Handler Proxy Target Shadow proxy.x; proxy.y=1; handler.get(target, ’x’, proxy); handler.set(target, ’y’, 1, proxy); target[’x’]; shadow[’y’]=1; Meta-Level Base-Level Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 12 / 14
  • 27. Shadow Objects Handler Proxy Target Shadow proxy.x; proxy.y=1; proxy.y; handler.get(target, ’x’, proxy); handler.set(target, ’y’, 1, proxy); handler.get(target, ’y’, proxy); target[’x’]; shadow[’y’]=1; shadow[’y’]; Meta-Level Base-Level Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 12 / 14
  • 28. Function Recompilation var x = 1; function f (){ function g (y) { var z = 1; return x+y+z; } } Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 13 / 14
  • 29. Function Recompilation var x = 1; function f (){ ”function g (y) { var z = 1; return x+y+z; }” } Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 13 / 14
  • 30. Function Recompilation var x = 1; with(sbxglobal){ eval( ”function g (y) { var z = 1; return x+y+z; }”); } Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 13 / 14
  • 31. Function Recompilation var x = 1; with(sbxglobal){ function g (y) { var z = 1; return x+y+z; } } Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 13 / 14
  • 32. Conclusion TreatJS: Language embedded, dynamic, higher-order contract system for full JavaScript Guarantees noninterference Sandbox: Language embedded sandbox for full JavaScript Runs JavaScript code in isolation isolation Matthias Keil, Peter Thiemann On Contracts, Sandboxes, and Proxies October 5, 2015 14 / 14