#[\SensitiveParameter] values leak through joinpoint frames in stack traces

クローズ
#795 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

関連するプルリクエストがすでにマージされています。

  • #803 @lisachenko による — マージ済み

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
18/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
php
領域
backend, security

調査の方向性

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 の本文から書いたものです。

説明

Bug PHP-8.4 PHP-8.5 PHP-8.6

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 / $variadicArguments parameters of every joinpoint __invoke() with #[\SensitiveParameter]: DynamicTraitAliasMethodInvocation, StaticTraitAliasMethodInvocation, ReflectionFunctionInvocation, ReflectionConstructorInvocation, and the ClassFieldAccess read/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 with composer 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 with Closure::call(). That's a separate trade-off: the class docblock explains why invokeArgs() was chosen (speed, by-reference arguments).

Part of #789.

主要言語
PHP
スター
1.7k
フォーク
166
平均マージ
1日 1時間
マージ済み PR(30日)
43

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

goaop/framework のほかの issue

goaop/framework の issue をすべて見る

似ている issue

PHP の issue をもっと見る

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

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