#[\SensitiveParameter] values leak through joinpoint frames in stack traces
メンテナーはふだん 1 日以内に返信
関連するプルリクエストがすでにマージされています。
- #803 @lisachenko による — マージ済み
評価
調査の方向性
Start with the joinpoint __invoke() methods named in the issue: DynamicTraitAliasMethodInvocation, StaticTraitAliasMethodInvocation, ReflectionFunctionInvocation and ReflectionConstructorInvocation, plus the ClassFieldAccess read and write values. Reproduce the leaked frame with zend.exception_ignore_args=0 and check Throwable::getTrace(). The work is already claimed by open pull request #803, so coordinate there before starting.
索引モデルが issue の本文から書いたものです。
説明
What happens
Proxies keep #[\SensitiveParameter], so the proxy frame and the original method frame are redacted correctly. The joinpoint frames between them, though, receive the arguments as a plain array, and Throwable::getTrace() exposes the secret there:
public function fail(string $user, #[\SensitiveParameter] string $password): never { throw new RuntimeException('boom'); }
#0 Demo\Auth->failOriginalAlias ["bob","SensitiveParameterValue"]
#1 ReflectionMethod->invokeArgs ["Demo\\Auth",["bob","s3cr3t"]] <- leaked
#2 Go\Aop\Framework\DynamicTraitAliasMethodInvocation->proceed []
#3 Demo\LogAspect->around [...]
#4 Go\Aop\Framework\AroundInterceptor->invoke [...]
#5 Go\Aop\Framework\DynamicTraitAliasMethodInvocation->proceed []
#6 Go\Aop\Framework\DynamicTraitAliasMethodInvocation->__invoke ["Demo\\Auth",["bob","s3cr3t"]] <- leaked
#7 Demo\Auth->fail ["bob","SensitiveParameterValue"]
(reproduced with zend.exception_ignore_args=0)
The string form of the trace prints Array, so the usual log line is safe. Error trackers that serialize getTrace() (Sentry and similar) capture the value. PHP 8.6 puts more weight on argument display (error_include_args and more #[\SensitiveParameter] markings in core). This leak exists on all supported versions.
Proposed fix
- Mark the
$arguments/$variadicArgumentsparameters of every joinpoint__invoke()with#[\SensitiveParameter]:DynamicTraitAliasMethodInvocation,StaticTraitAliasMethodInvocation,ReflectionFunctionInvocation,ReflectionConstructorInvocation, and theClassFieldAccessread/write values. The parameter values stay visible in the proxy frame, where#[\SensitiveParameter]is applied per parameter. There is no runtime cost on the hot path (check withcomposer test:performance). - The
ReflectionMethod::invokeArgs()frame (#1) can't carry the attribute because the method is internal. Fixing that frame means calling the original body through a closure whose parameter is marked, for example withClosure::call(). That's a separate trade-off: the class docblock explains whyinvokeArgs()was chosen (speed, by-reference arguments).
Part of #789.
- 主要言語
- PHP
- スター
- 1.7k
- フォーク
- 166
- 平均マージ
- 1日 1時間
- マージ済み PR(30日)
- 43
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
goaop/framework のほかの issue
-
Bug
難易度 4/5 1〜2日 初心者へのやさしさ 56/100
メンテナーはふだん 1 日以内に返信
-
Bug
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
メンテナーはふだん 1 日以内に返信
-
Enhancement Performance
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
メンテナーはふだん 1 日以内に返信
-
Enhancement Performance To Be Discussed
難易度 5/5 1週間以上 初心者へのやさしさ 28/100
goaop/framework#814 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Enhancement PHP-8.6
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
goaop/framework の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 69/100
opnsense/core#11171 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
getgrav/grav-plugin-form#664 ·
-
claude
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
sprain/sprainocchio#26 ·
-
sync-en
難易度 1/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
sync-en
難易度 1/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信