Skip to content

Commit 36830df

Browse files
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 #7140
1 parent 2d0f088 commit 36830df

1 file changed

Lines changed: 0 additions & 2 deletions

File tree

lib/view.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ function View(name, options) {
103103
* @private
104104
*/
105105

106-
// ← ONLY ONE View.prototype.lookup — the fixed version (Bug 2 fix)
107106
View.prototype.lookup = function lookup(name) {
108107
var path;
109108
var roots = [].concat(this.root);
@@ -176,7 +175,6 @@ View.prototype.render = function render(options, callback) {
176175
* @private
177176
*/
178177

179-
// ← View.prototype.resolve RESTORED (Bug 3 fix)
180178
View.prototype.resolve = function resolve(dir, file) {
181179
var ext = this.ext;
182180

0 commit comments

Comments
 (0)