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

Secure errors directory #20212

Merged
merged 1 commit into from
Mar 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion nginx.conf.sample
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ location /media/downloadable/ {
location /media/import/ {
deny all;
}
location /errors/ {
location ~* \.xml$ {
deny all;
}
}

# PHP entry point for main application
location ~ ^/(index|get|static|errors/report|errors/404|errors/503|health_check)\.php$ {
Expand Down Expand Up @@ -198,6 +203,6 @@ gzip_types
gzip_vary on;

# Banned locations (only reached if the earlier PHP entry point regexes don't match)
location ~* (\.php$|\.htaccess$|\.git) {
location ~* (\.php$|\.phtml$|\.htaccess$|\.git) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@schmengler maybe forbid both xml and phtml in both occurrences here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was tempted to, but not sure if that could block legit requests

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't that block sitemaps?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@schmengler, ok, noticed

For Nginx: deny access to PHTML files in general and XML files within errors directory (nginx.conf.sample)

Do we need to give access for some xml in reality?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @wigman!) That's the case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

although they should not be, sitemaps can be named dynamically so this is not possible I guess?
so for now maybe only excluding .xml in the errors directory could do it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidverholen aren't they placed in some specific directory with name corresponding to some mask?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can choose a relative path and filename under the pub directory, so it's not possible to determine (at least by filename)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a solution could be, to block the errors directory completely and only explicitly allow files that need to be public? Could be difficult for custom error themes as they lie in sub directories of errors and also can be named dynamically

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a satisfying general solution here yet

deny all;
}
3 changes: 3 additions & 0 deletions pub/errors/.htaccess
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
Options None
<FilesMatch "\.(xml|phtml)$">
Deny from all
</FilesMatch>
<IfModule mod_rewrite.c>
RewriteEngine Off
</IfModule>