Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

response.sendfile() fails with Error: Forbidden with path includes a symlink #1465

Closed
jefflage opened this issue Jan 10, 2013 · 5 comments
Closed

Comments

@jefflage
Copy link

here's the stack:

Error: Forbidden
at SendStream.error (/Users/jlage/Development/web/server/bootstrap/node_modules/express/node_modules/send/lib/send.js:145:16)
at SendStream.pipe (/Users/jlage/Development/web/server/bootstrap/node_modules/express/node_modules/send/lib/send.js:307:39)
at ServerResponse.res.sendfile (/Users/jlage/Development/web/server/bootstrap/node_modules/express/lib/response.js:336:8)
at module.exports.load_funds_list (/Users/jlage/Development/web/amber/controllers/ref-data.js:23:12)
at Object.oncomplete (fs.js:297:15)

@dougwilson
Copy link
Contributor

That error comes from the path containing .. (up parent directory) and you didn't supply the root option. Try using sendfile like so:

res.sendfile(path, {'root': '/path/to/root/directory'});

The root option should be the directory you want to serve the files from. It is intended to prevent the path from containing things like .. so a user may get the server to serve a file outside that directory.

@jefflage
Copy link
Author

are you saying that it explicitly prevents you from using .. in any case?

@dougwilson
Copy link
Contributor

Yes, path cannot contain .. unless you specify the root option.

@tj
Copy link
Member

tj commented Jan 13, 2013

yeah if you're not restricting with a root dir it's a potential security issue. You can resolve() to absolute paths to get around that but if you're accepting user input in those cases that's still a flaw, but if you're not then no big deal!

@Zabi1112
Copy link

Zabi1112 commented Oct 27, 2023

Done these things but its not working but the same code works in other sysytem whta will be the fault or permissions i am missing
installed dependencie properly here are the dependencies
Linux
Webpack
Node

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants