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

Chiusa
#795 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Una pull request collegata è già stata integrata.

  • #803 di @lisachenko — integrata

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
18/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
php
Ambito
backend, security

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
PHP
Stelle
1.7k
Fork
166
Merge medio
1g 1h
PR unite (30g)
43

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di goaop/framework

Tutte le issue di goaop/framework

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.