Skip to content

Document SensitiveParameter attribute in callbacks #5734

Closed

Description

@Sjord

Affected page

https://www.php.net/manual/en/curl.constants.php

Current issue

E.g. CURLOPT_SSH_HOSTKEYFUNCTION:

The callback must have the following signature:

function callback(
resource $curlHandle,
int $keyType,
string $key,
int $keyLength
): int

Suggested improvement

I think it would be better if it said #[\SensitiveParameter]string $key.

Additional context (optional)

PHP: SensitiveParameter - Manual

Activity

  1. jordikroon commented on Aug 5, 2026

    @jordikroon
    Member

    Related: #5631

  2. jordikroon commented on Oct 5, 2026

    @jordikroon
    Member

    I've just had another look at this. The callback is a user-defined function. Curl doesn't define it. So the true question is if $key is a parameter that should be marked as sensitive. Sensitive enough for the documentation to encourage it. I believe it isn't, because:

    1. $key is the server's public host key. The server sends it to every client that connects, before any authentication happens. Anyone can retrieve it and leaking it in a stack trace discloses nothing an attacker couldn't already get.

    2. It matches how php-src itself uses the attribute. It is applied to secrets (passwords, private keys, plaintext), not to public keys.

  3. Sjord commented on Oct 5, 2026

    @Sjord
    ContributorAuthor

    Ok, thanks for looking into it. My point was indeed for the documentation to encourage use of #[\SensitiveParameter]. That when people copy/paste the signature from the docs, it already includes the recommended attribute. But it seems I misinterpreted $key as a private key instead of a public key.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions