Skip to content

Commit 9abe00e

Browse files
committed
MAGETWO-71156: [Backport for 2.1.x] Magento 2.x default configuration leaks custom PHP settings via .user.ini
1 parent 4ebfa1d commit 9abe00e

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

.htaccess

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,15 @@ DirectoryIndex index.php
114114
order allow,deny
115115
deny from all
116116
</Files>
117+
<Files .user.ini>
118+
<IfVersion < 2.4>
119+
order allow,deny
120+
deny from all
121+
</IfVersion>
122+
<IfVersion >= 2.4>
123+
Require all denied
124+
</IfVersion>
125+
</Files>
117126
ErrorDocument 404 /pub/errors/404.php
118127
ErrorDocument 403 /pub/errors/404.php
119128
<IfModule mod_headers.c>

.htaccess.sample

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,15 @@ DirectoryIndex index.php
278278
order allow,deny
279279
deny from all
280280
</Files>
281+
<Files .user.ini>
282+
<IfVersion < 2.4>
283+
order allow,deny
284+
deny from all
285+
</IfVersion>
286+
<IfVersion >= 2.4>
287+
Require all denied
288+
</IfVersion>
289+
</Files>
281290

282291
# For 404s and 403s that aren't handled by the application, show plain 404 response
283292
ErrorDocument 404 /pub/errors/404.php

nginx.conf.sample

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ charset UTF-8;
3333
error_page 404 403 = /errors/404.php;
3434
#add_header "X-UA-Compatible" "IE=Edge";
3535

36+
# Deny access to sensitive files
37+
location /.user.ini {
38+
deny all;
39+
}
40+
3641
# PHP entry point for setup application
3742
location ~* ^/setup($|/) {
3843
root $MAGE_ROOT;

pub/.htaccess

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,18 @@ ErrorDocument 403 /errors/404.php
210210
deny from all
211211
</Files>
212212

213+
###########################################
214+
## Deny access to .user.ini
215+
<Files .user.ini>
216+
<IfVersion < 2.4>
217+
order allow,deny
218+
deny from all
219+
</IfVersion>
220+
<IfVersion >= 2.4>
221+
Require all denied
222+
</IfVersion>
223+
</Files>
224+
213225
<IfModule mod_headers.c>
214226
############################################
215227
## Prevent clickjacking

0 commit comments

Comments
 (0)