Skip to content
This repository was archived by the owner on Sep 5, 2018. It is now read-only.

Commit 4747c51

Browse files
committed
Merge pull request #93 from yahoo/minor-touchup-readme
Update README.md
2 parents 102fe1e + e09088b commit 4747c51

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ SecureHandlebars
1414
## Introduction
1515
Security is of utmost importance!
1616

17-
Imagine a template is written like so: `<a href="{{url}}">{{url}}</a>`. When it is compiled with an untrusted user data like `{url: 'javascript:alert(666)'}`, secure-handlebars automatically applies contextual escaping and generates the HTML `<a href="x-javascript:alert(666)">javascript:alert(666)</a>` as a result.
17+
Imagine a template is written like so: `<a href="{{url}}">{{url}}</a>`. When it is compiled with an untrusted user data like `{"url": "javascript:alert(666)"}`, secure-handlebars automatically applies contextual escaping and generates the HTML `<a href="x-javascript:alert(666)">javascript:alert(666)</a>` as a result.
1818

19-
Clearly, the same `{{url}}` is accurately escaped according to its output contexts to prevent malicious script executions, which otherwise is vulnerable if the original Handlebars is used alone.
19+
Clearly, the same `{{url}}` must be escaped according to different output contexts to prevent malicious script executions, which otherwise would be vulnerable if the original [Handlebars](http://handlebarsjs.com/) is used alone.
2020

21-
This is archived by enhancing the original [Handlebars](http://handlebarsjs.com/) to perform the following major steps:
21+
This is archived by enhancing the original Handlebars to perform the following steps:
2222

2323
![alt Visualizing the architecture of secure-handlebars](https://yahoo.github.io/secure-handlebars/assets/images/secure-handlebars.png)
2424

@@ -96,20 +96,20 @@ On the other hand, this utility also faciilates statistics collection. For insta
9696
npm test
9797
```
9898
## Known Limitations & Issues
99-
- Templates MUST be in UTF-8 encoding and using HTML 5 doctype (i.e., <!doctype html>).
99+
- Templates MUST be in UTF-8 encoding and using HTML 5 doctype (i.e., `<!doctype html>`).
100100
- There is no support to the JavaScript contexts and `<style>` tags yet. See the [section](#warnings-and-workarounds) below for details.
101101
- Our approach involves only static analysis on the template files, and thus data dynamically binded through raw output expressions that may alter the execution context on the rendered HTML CANNOT be taken into account.
102-
- We now assume that `{{>partial}}` and `{{{{rawblock}}}}` is always placed in the HTML Data context, and by itself will result in the same Data context after its binding (hence, in-state and out-state are both of the data context).
102+
- We now assume that `{{>partial}}` and `{{{{rawblock}}}}` are always placed in the HTML Data context, and that they will result in the same Data context after data binding (hence, in-state and out-state are both of the data context).
103103

104104
### Warnings and Workarounds
105-
When output expressions are found inside dangerous (yet-to-be-supported) contexts, we echo warnings and gracefully fallback to apply the default Handlebars [`escapeExpression()`](http://handlebarsjs.com/#html-escaping). These warnings are indications of potential security exploits, and thus require closer inspections. Instead of simply abusing raw expressions to suppress the warnings, here are some alternative suggestions to secure your applications.
106-
- Output placeholder in the `<script>` tag:
105+
When output expressions are found inside dangerous (yet-to-be-supported) contexts, we echo warnings and gracefully fallback to apply the default Handlebars [`escapeExpression()`](http://handlebarsjs.com/#html-escaping). These warnings are indications of potential security exploits, and thus require closer inspections. Instead of simply abusing `{{{raw_expression}}}` to suppress the warnings, here are some alternative suggestions to secure your applications.
106+
- Output expression in the `<script>` tag:
107107
```html
108108
<!-- Rewrite <script>var strJS = {{strJS}};</script> as: -->
109-
<input id="strJS" value="{{strJS}}">
109+
<input type="hidden" id="strJS" value="{{strJS}}">
110110
<script>var strJS = document.getElementById('strJS').value;</script>
111111
```
112-
- Output placeholder in an event attribute (e.g., `onclick=""`):
112+
- Output expression in an event attribute (e.g., `onclick=""`):
113113
```html
114114
<!-- Rewrite <div onclick="hello({{name}})"> as: -->
115115
<div onclick="hello(this.getAttribute('data-name'))" data-name="{{name}}">

0 commit comments

Comments
 (0)