Skip to content

Commit

Permalink
セキュリティ関連のヘッダ出力を PHP から送信するよう修正
Browse files Browse the repository at this point in the history
- see also
  - EC-CUBE#48
  - EC-CUBE#49
  - EC-CUBE#206
- X-Frame-Options DENY の影響で phpinfo が表示されなかったのを修正
  • Loading branch information
nanasess committed May 31, 2019
1 parent 2b69746 commit 9a2b7bd
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
13 changes: 13 additions & 0 deletions data/class/pages/LC_Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class LC_Page
*/
public function init()
{
$this->sendAdditionalHeader();
// 開始時刻を設定する。
$this->timeStart = microtime(true);

Expand Down Expand Up @@ -510,4 +511,16 @@ public function checkLimitPostMode()
trigger_error($msg, E_USER_ERROR);
}
}

/**
* 追加の HTTP ヘッダを送信する.
*
* 主にセキュリティ関連のヘッダを送信する.
*/
public function sendAdditionalHeader()
{
header('X-XSS-Protection: 1; mode=block');
header('X-Content-Type-Options: nosniff');
header('X-Frame-Options: DENY');
}
}
1 change: 1 addition & 0 deletions data/class/pages/admin/LC_Page_Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class LC_Page_Admin extends LC_Page_Ex
*/
public function init()
{
$this->sendAdditionalHeader();
$this->template = MAIN_FRAME;

//IP制限チェック
Expand Down
10 changes: 10 additions & 0 deletions data/class/pages/admin/system/LC_Page_Admin_System_System.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,14 @@ public function getSystemInfo()

return $arrSystemInfo;
}

/**
* {@inheritdoc}
*/
public function sendAdditionalHeader()
{
header('X-XSS-Protection: 1; mode=block');
header('X-Content-Type-Options: nosniff');
header('X-Frame-Options: SAMEORIGIN');
}
}
6 changes: 0 additions & 6 deletions html/.htaccess
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
<ifModule mod_headers.c>
Header always set X-XSS-Protection "1; mode=block"
Header always set X-Content-Type-Options "nosniff"
Header always set X-Frame-Options DENY
</ifModule>

# 基本は SC_Initial.php で設定するが、ini_setで反映されないものはここで設定する
<IfModule mod_php5.c>
php_value mbstring.language Japanese
Expand Down

0 comments on commit 9a2b7bd

Please sign in to comment.