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::file() & directory traversal [3.x] #7015

Closed
quickapps opened this issue Jul 15, 2015 · 2 comments · Fixed by #7021
Closed

Response::file() & directory traversal [3.x] #7015

quickapps opened this issue Jul 15, 2015 · 2 comments · Fixed by #7021
Assignees
Milestone

Comments

@quickapps
Copy link
Contributor

Currently the method Response::file() performs a very basic checking against "Directory Traversal" attacks by doing this:

if (strpos($path, '..') !== false) {
    throw new NotFoundException('The requested file contains `..` and will not be read.');
}

This approach doesn't allow us to work with file names containing two consecutive dots symbols, e.g. Some truncated name ... .pdf

Proposed solution, remove filename from $path before checking:

if (strpos(dirname($path), '..') !== false) {
    throw new NotFoundException('The requested file contains `..` and will not be read.');
}
@lorenzo lorenzo added this to the 3.0.9 milestone Jul 15, 2015
@markstory markstory self-assigned this Jul 15, 2015
@antograssiot
Copy link
Contributor

@quickapps would you like to submit a PR for this ?

@antograssiot
Copy link
Contributor

closed with #7021

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

Successfully merging a pull request may close this issue.

4 participants