Skip to content

ext/curl: accept SensitiveParameterValue in curl_setopt - #22960

Draft
Sjord wants to merge 1 commit into
php:masterfrom
Sjord:curl-setopt-sensitive-paramval
Draft

ext/curl: accept SensitiveParameterValue in curl_setopt#22960
Sjord wants to merge 1 commit into
php:masterfrom
Sjord:curl-setopt-sensitive-paramval

Conversation

@Sjord

@Sjord Sjord commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

This makes it possible to pass things to curl_setopt without them leaking in backtraces.

This makes it possible to pass things to curl_setopt without them
leaking in backtraces.
Comment thread ext/curl/interface.c
zval *inner_value;

inner_value = zend_read_property_ex(
zend_ce_sensitive_parameter_value,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
zend_ce_sensitive_parameter_value,
Z_OBJCE_P(zvalue),
Comment thread ext/curl/interface.c
if (Z_TYPE_P(zvalue) == IS_OBJECT
&& instanceof_function(Z_OBJCE_P(zvalue), zend_ce_sensitive_parameter_value))
{
zval rv;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This theoretically leaks rv. But we know that SensitiveParameterValue is final and has a real backing store for the property and &rv is unused. I would therefore suggest to just pass NULL instead of &rv.

Comment thread ext/curl/interface.c
zend_long lval;

if (Z_TYPE_P(zvalue) == IS_OBJECT
&& instanceof_function(Z_OBJCE_P(zvalue), zend_ce_sensitive_parameter_value))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for instanceof, SensitiveParameterValue is final. You can just compare the CE directly.

@Sjord

Sjord commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

@TimWolla What do you think about this conceptually? So far, SensitiveParameterValue was only created during backtraces. Is it meant to use in user code to pass parameters? Should passing SensitiveParameterValue be supported more generally than only curl_setopt? Should all functions transparently accept SensitiveParameterValue? That would also increase the risk that the content leaks.

@TimWolla

Copy link
Copy Markdown
Member

What do you think about this conceptually?

I think in this instance it is quite nice as a workaround for a terrible API. I would not make this a generic thing though (e.g. the unwrapping is likely going to be expensive for type checking).

Probably deserves a short mailing list discussion, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

2 participants