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

已关闭
#795 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

已经有一个关联 PR 被合并了。

  • #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 小时
30 天内合并 PR
38

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

goaop/framework 的其他 Issue

查看 goaop/framework 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。