Commit 84d809d
committed
fix: add path containment check in View.prototype.lookup()
View.prototype.lookup() used path.resolve(root, name) without verifying
the resolved path stayed within the configured views directory. This
inconsistency with res.sendFile() (which uses the send library root
containment check) could allow path traversal when user input is passed
to res.render() unsanitized.
Added a containment check that skips any resolved path not starting with
resolve(root) + sep. Absolute paths are intentionally exempted since
Express supports passing absolute paths directly to res.render().
Fixes #71401 parent e509919 commit 84d809d
1 file changed
Lines changed: 10 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
| |||
112 | 114 | | |
113 | 115 | | |
114 | 116 | | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
115 | 124 | | |
116 | 125 | | |
117 | 126 | | |
| |||
202 | 211 | | |
203 | 212 | | |
204 | 213 | | |
205 | | - | |
| 214 | + | |
0 commit comments