end-to-end injection safety at scale...security engineer @ google hacks libraries, tools, languages...

29
2019 | March 2019 End-to-end Injection Safety at Scale Mike Samuel, Google Security Engineering

Upload: others

Post on 22-Feb-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: End-to-end Injection Safety at Scale...Security engineer @ Google Hacks libraries, tools, languages TC39 member ( JavaScript language committee ) Editor of "A Roadmap for Node.js Security"

2019 |

March 2019

End-to-end Injection Safety at ScaleMike Samuel, Google Security Engineering

Page 2: End-to-end Injection Safety at Scale...Security engineer @ Google Hacks libraries, tools, languages TC39 member ( JavaScript language committee ) Editor of "A Roadmap for Node.js Security"

2019 |

About me

Security engineer @ Google

Hacks libraries, tools, languages

TC39 member ( JavaScript language committee )

Editor of "A Roadmap for Node.js Security"

Mission: make the easiest way to express an idea in code, a secure way

@mvsamuel

Page 3: End-to-end Injection Safety at Scale...Security engineer @ Google Hacks libraries, tools, languages TC39 member ( JavaScript language committee ) Editor of "A Roadmap for Node.js Security"

2019 |

Trusted Types

● W3 Proposal

● Builds on 6+ years of experience

within Google

● Protects Gmail, many other complex apps

● Evidence of efficacy

Page 4: End-to-end Injection Safety at Scale...Security engineer @ Google Hacks libraries, tools, languages TC39 member ( JavaScript language committee ) Editor of "A Roadmap for Node.js Security"

2019 |

Trusted Types

1. Problem statement

2. Small change ⇨ big organizational effect

3. Adoption in practice

4. Early adopters welcome

Page 5: End-to-end Injection Safety at Scale...Security engineer @ Google Hacks libraries, tools, languages TC39 member ( JavaScript language committee ) Editor of "A Roadmap for Node.js Security"

2019 |

"Today, a novice programmer cannot write a complex but secure application."Breaking XSS mitigations via Script Gadgets - blackhat 2017

Page 6: End-to-end Injection Safety at Scale...Security engineer @ Google Hacks libraries, tools, languages TC39 member ( JavaScript language committee ) Editor of "A Roadmap for Node.js Security"

2019 |

Page 7: End-to-end Injection Safety at Scale...Security engineer @ Google Hacks libraries, tools, languages TC39 member ( JavaScript language committee ) Editor of "A Roadmap for Node.js Security"

2019 |

Page 8: End-to-end Injection Safety at Scale...Security engineer @ Google Hacks libraries, tools, languages TC39 member ( JavaScript language committee ) Editor of "A Roadmap for Node.js Security"

2019 |

Page 9: End-to-end Injection Safety at Scale...Security engineer @ Google Hacks libraries, tools, languages TC39 member ( JavaScript language committee ) Editor of "A Roadmap for Node.js Security"

2019 |

"Today, a novice programmer cannot write a complex but secure application."Breaking XSS mitigations via Script Gadgets - blackhat 2017

Page 10: End-to-end Injection Safety at Scale...Security engineer @ Google Hacks libraries, tools, languages TC39 member ( JavaScript language committee ) Editor of "A Roadmap for Node.js Security"

2019 |

Reduce developers' security burden.

Move it to security professionals.

Page 11: End-to-end Injection Safety at Scale...Security engineer @ Google Hacks libraries, tools, languages TC39 member ( JavaScript language committee ) Editor of "A Roadmap for Node.js Security"

2019 |

Client-side JavaScript

<div id=foo></div> <script> var foo = document.querySelector('#foo'); foo.innerHTML = 'raw-string'; </script>

Page 12: End-to-end Injection Safety at Scale...Security engineer @ Google Hacks libraries, tools, languages TC39 member ( JavaScript language committee ) Editor of "A Roadmap for Node.js Security"

2019 |

Client-side JavaScript

<meta http-equiv=... content="trusted-types p" />

<div id=foo></div> <script> var foo = document.querySelector('#foo'); foo.innerHTML = 'raw-string'; </script>

Page 13: End-to-end Injection Safety at Scale...Security engineer @ Google Hacks libraries, tools, languages TC39 member ( JavaScript language committee ) Editor of "A Roadmap for Node.js Security"

2019 |

Trusted Types make Trust decisions explicit

<meta http-equiv=... content="trusted-types p" />

<div id=foo></div> <script> var foo = document.querySelector('#foo'); var policy = TrustedTypes.createPolicy('p', {}); var trusted = policy.createHTML('raw-string'); foo.innerHTML = trusted; </script>

Page 14: End-to-end Injection Safety at Scale...Security engineer @ Google Hacks libraries, tools, languages TC39 member ( JavaScript language committee ) Editor of "A Roadmap for Node.js Security"

2019 |

Trusted Types make Trust decisions explicit

<meta http-equiv=... content="trusted-types p" />

<div id=foo></div> <script> var foo = document.querySelector('#foo'); var policy = TrustedTypes.createPolicy('p', {}); var trusted = policy.createHTML('raw-string'); foo.innerHTML = trusted; </script>

Page 15: End-to-end Injection Safety at Scale...Security engineer @ Google Hacks libraries, tools, languages TC39 member ( JavaScript language committee ) Editor of "A Roadmap for Node.js Security"

2019 |

Trusted Types make Trust decisions explicit

<meta http-equiv=... content="trusted-types p" />

<div id=foo></div> <script> var foo = document.querySelector('#foo'); var policy = TrustedTypes.createPolicy('p', {}); var trusted = policy.createHTML('raw-string'); foo.innerHTML = trusted; </script>

Our code is safe becausetrust decisions are explicit &reviewed by security teamand we check trustednessbefore doing the undoable.

Page 16: End-to-end Injection Safety at Scale...Security engineer @ Google Hacks libraries, tools, languages TC39 member ( JavaScript language committee ) Editor of "A Roadmap for Node.js Security"

2019 |

Step 1. Flip the switch

● Trust decisionsImplicit

● No separation btw.sensitive and othercode

● Un-undoable actsnot checked

● Bugs non-obvious● Fails unsafe

● Trust decisionsImplicit

● No separation btw.sensitive and othercode

● Un-undoable actschecked

● Bugs obvious● Fails safe

Page 17: End-to-end Injection Safety at Scale...Security engineer @ Google Hacks libraries, tools, languages TC39 member ( JavaScript language committee ) Editor of "A Roadmap for Node.js Security"

2019 |

Step 2. Consolidate tricky code

● Trust decisionsImplicit

● No separation btw.sensitive and othercode

● Un-undoable actschecked

● Bugs obvious● Fails safe

● Trust decisionsexplicit

● Separation btw.sensitive and othercode

● Un-undoable actschecked

● Bugs obvious, fewer● Fails safe● Sensitive code not

scrutinized

Page 18: End-to-end Injection Safety at Scale...Security engineer @ Google Hacks libraries, tools, languages TC39 member ( JavaScript language committee ) Editor of "A Roadmap for Node.js Security"

2019 |

Step 3. Automatically loop in reviewers

● Trust decisionsexplicit

● Separation btw.sensitive and othercode

● Un-undoable actschecked

● Bugs obvious, fewer● Fails safe● Sensitive code not

scrutinized

● Trust decisionsexplicit

● Separation btw.sensitive and othercode

● Un-undoable actschecked

● Bugs obvious, fewer● Fails safe● Sensitive code

scrutinized

Page 19: End-to-end Injection Safety at Scale...Security engineer @ Google Hacks libraries, tools, languages TC39 member ( JavaScript language committee ) Editor of "A Roadmap for Node.js Security"

2019 |

Lightweight process

help.github.com/en/articles/about-code-owners"Code owners are automatically requested for review when someone opens a pull request that modifies code that they own."

CODEOWNERS# Files under sensitive/ need extra sign-offsensitive/ @securityperson

Page 20: End-to-end Injection Safety at Scale...Security engineer @ Google Hacks libraries, tools, languages TC39 member ( JavaScript language committee ) Editor of "A Roadmap for Node.js Security"

2019 |

Trusted Types make Trust decisions explicit

<meta http-equiv=... content="trusted-types p" />

<div id=foo></div> <script> var foo = document.querySelector('#foo'); var policy = TrustedTypes.createPolicy('p', {}); var trusted = policy.createHTML('raw-string'); foo.innerHTML = trusted; </script>

Our code is safe becausetrust decisions are explicit &reviewed by security teamand we check trustednessbefore doing the undoable.

Page 21: End-to-end Injection Safety at Scale...Security engineer @ Google Hacks libraries, tools, languages TC39 member ( JavaScript language committee ) Editor of "A Roadmap for Node.js Security"

2019 |

RealWorld React App github.com/gothinkster/realworld

Page 22: End-to-end Injection Safety at Scale...Security engineer @ Google Hacks libraries, tools, languages TC39 member ( JavaScript language committee ) Editor of "A Roadmap for Node.js Security"

2019 |

RealWorld React Apppublic/index.html

Page 23: End-to-end Injection Safety at Scale...Security engineer @ Google Hacks libraries, tools, languages TC39 member ( JavaScript language committee ) Editor of "A Roadmap for Node.js Security"

2019 |

RealWorld React Appsrc/components/Article/index.js

Page 24: End-to-end Injection Safety at Scale...Security engineer @ Google Hacks libraries, tools, languages TC39 member ( JavaScript language committee ) Editor of "A Roadmap for Node.js Security"

2019 |

RealWorld React Appsrc/components/Article/index.js

Page 25: End-to-end Injection Safety at Scale...Security engineer @ Google Hacks libraries, tools, languages TC39 member ( JavaScript language committee ) Editor of "A Roadmap for Node.js Security"

2019 |

RealWorld React Appsrc/index.js

Page 26: End-to-end Injection Safety at Scale...Security engineer @ Google Hacks libraries, tools, languages TC39 member ( JavaScript language committee ) Editor of "A Roadmap for Node.js Security"

2019 |

RealWorld React Appsrc/trustedtypes.js

Page 27: End-to-end Injection Safety at Scale...Security engineer @ Google Hacks libraries, tools, languages TC39 member ( JavaScript language committee ) Editor of "A Roadmap for Node.js Security"

2019 |

Tools Integration

Most trust decisions in common infrastructure that is safe-by-construction:

● Template Systems (strict, contextually autoescaped)● Sanitizers● Programmatic Builder APIs● Protobufs bridge server- and client-side trusted values.

Page 28: End-to-end Injection Safety at Scale...Security engineer @ Google Hacks libraries, tools, languages TC39 member ( JavaScript language committee ) Editor of "A Roadmap for Node.js Security"

2019 |

Trusted Types

Gets security eyes on decisions to trust

Long experience migrating projectsReduces XSS payments to vulnerability hunters

Proposed as web standardAvailable in Chrome with origin trial tokenContributors in Munich, NY, Prague, Seattle, Zürich

Page 29: End-to-end Injection Safety at Scale...Security engineer @ Google Hacks libraries, tools, languages TC39 member ( JavaScript language committee ) Editor of "A Roadmap for Node.js Security"

2019 |

Resources

● Early adopters: [email protected]● Specification: github.com/WICG/trusted-types● "Securing the Tangled Web" by C. Kern, ACM Queue 2014

@mvsamuel (Ask me about tools integration)