php / php/php-src

Add option to hide Environment Variables from all Globals

オープン
#13,110 コメント 1 件 リアクション 3 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Feature SAPI: fpm
主要言語
C
スター
40.4k
フォーク
8.2k
平均マージ
2日 13時間
マージ済み PR(30日)
96

説明

Description

I am looking for a way to hide Environment Variables from $_SERVER or from all Global Arrays.
I would prefer to secure my environment variables as much as possible and make them explicit when using.

I only require getenv('my_env_var');
I do not want or need $_SERVER['my_env_var'] or $_ENV['my_env_var'].

There are many third-party tools and libraries that might expose $_SERVER in logs or debugging. Also if the code is compromised dumping $_SERVER is very easy. This could be mitigated by encrypting Environment Variables, but I would also like to make accessing them very explicit.

Currently I can set clear_env to yes and change variables_order to "GPCS" and ignore "E" to remove $_ENV, but I can't remove "S" as that is needed for REMOTE_ADDR, etc.

Changing clear_env does remove any server configured environment variables, but it still adds any environment variables being added from php-fpm config file when doing env[some_name] = some_value. I would need all those to be hidden from $_SERVER as well and only accessible via getenv().

It would be nice to have another php config option to do that and have that option accessible from php-fpm config as well like clear_env or variables_order

Maybe something like expose_env. Default is yes, but can be set to no.
no should remove it from $_SERVER as well as $_ENV or any other Global data.

Bonus points if no can also remove it from, errors, functions (like debug_backtrace), etc.

Thanks

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、既存の clear_env オプションと variables_order オプションが $_SERVER と $_ENV にどのように値を設定するか、および php-fpm の env[...] 値がどのように処理されるかを確認してください。オプションの範囲を定義し、公開を無効にするとそれらの値がグローバル配列から隠される一方で、getenv() は引き続き使用できることを検証してください。要求されているエラーと debug_backtrace の動作については、追加の未解決事項です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
php
領域
backend, security
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
30/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。