Skip to content

Commit fcaca7f

Browse files
committed
Add warning around securing locals to render
1 parent 5e918ea commit fcaca7f

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

_includes/api/en/4x/app-locals.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
The `app.locals` object has properties that are local variables within the application,
44
and will be available in templates rendered with [res.render](#res.render).
55

6+
<div class="doc-box doc-warn" markdown="1">
7+
The `locals` object is used by view engines to render a response. The object
8+
keys may be particularly sensitive and should not contain user-controlled
9+
input, as it may affect the operation of the view engine or provide a path to
10+
cross-site scripting. Consult the documentation for the used view engine for
11+
additional considerations.
12+
</div>
13+
614
```js
715
console.dir(app.locals.title)
816
// => 'My App'

_includes/api/en/4x/app-render.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ disk and evaluating Node.js modules, and as so for security reasons should not
1515
contain input from the end-user.
1616
</div>
1717

18+
<div class="doc-box doc-warn" markdown="1">
19+
The `locals` object is used by view engines to render a response. The object
20+
keys may be particularly sensitive and should not contain user-controlled
21+
input, as it may affect the operation of the view engine or provide a path to
22+
cross-site scripting. Consult the documentation for the used view engine for
23+
additional considerations.
24+
</div>
25+
1826
<div class="doc-box doc-notice" markdown="1">
1927
The local variable `cache` is reserved for enabling view cache. Set it to `true`, if you want to
2028
cache view during development; view caching is enabled in production by default.

_includes/api/en/4x/res-locals.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ Use this property to set variables accessible in templates rendered with [res.re
44
The variables set on `res.locals` are available within a single request-response cycle, and will not
55
be shared between requests.
66

7+
<div class="doc-box doc-warn" markdown="1">
8+
The `locals` object is used by view engines to render a response. The object
9+
keys may be particularly sensitive and should not contain user-controlled
10+
input, as it may affect the operation of the view engine or provide a path to
11+
cross-site scripting. Consult the documentation for the used view engine for
12+
additional considerations.
13+
</div>
14+
715
In order to keep local variables for use in template rendering between requests, use
816
[app.locals](#app.locals) instead.
917

_includes/api/en/4x/res-render.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ disk and evaluating Node.js modules, and as so for security reasons should not
1616
contain input from the end-user.
1717
</div>
1818

19+
<div class="doc-box doc-warn" markdown="1">
20+
The `locals` object is used by view engines to render a response. The object
21+
keys may be particularly sensitive and should not contain user-controlled
22+
input, as it may affect the operation of the view engine or provide a path to
23+
cross-site scripting. Consult the documentation for the used view engine for
24+
additional considerations.
25+
</div>
26+
1927
<div class="doc-box doc-notice" markdown="1">
2028
The local variable `cache` enables view caching. Set it to `true`,
2129
to cache the view during development; view caching is enabled in production by default.

0 commit comments

Comments
 (0)