Make WordPress Core


Ignore:
Timestamp:
12/17/2024 11:56:28 PM (6 months ago)
Author:
SergeyBiryukov
Message:

Privacy: Use SHA-256 hashing algorithm for Gravatar.

This aims to improve privacy by switching to a more secure algorithm, as an MD5 string can be reversed.

Follow-up to [6748], [31107].

Props henry.wright, jucaduca, haozi, desrosj, dd32, SergeyBiryukov.
See #60638.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/link-template.php

    r59113 r59532  
    42904290 * @since 4.2.0
    42914291 *
    4292  * @param mixed $id_or_email The avatar to retrieve a URL for. Accepts a user ID, Gravatar MD5 hash,
     4292 * @param mixed $id_or_email The avatar to retrieve a URL for. Accepts a user ID, Gravatar SHA-256 or MD5 hash,
    42934293 *                           user email, WP_User object, WP_Post object, or WP_Comment object.
    42944294 * @param array $args {
     
    43544354 * @since 4.2.0
    43554355 * @since 6.7.0 Gravatar URLs always use HTTPS.
    4356  *
    4357  * @param mixed $id_or_email The avatar to retrieve. Accepts a user ID, Gravatar MD5 hash,
     4356 * @since 6.8.0 Gravatar URLs use the SHA-256 hashing algorithm.
     4357 *
     4358 * @param mixed $id_or_email The avatar to retrieve. Accepts a user ID, Gravatar SHA-256 or MD5 hash,
    43584359 *                           user email, WP_User object, WP_Post object, or WP_Comment object.
    43594360 * @param array $args {
     
    44754476     *
    44764477     * @param array $args        Arguments passed to get_avatar_data(), after processing.
    4477      * @param mixed $id_or_email The avatar to retrieve. Accepts a user ID, Gravatar MD5 hash,
     4478     * @param mixed $id_or_email The avatar to retrieve. Accepts a user ID, Gravatar SHA-256 or MD5 hash,
    44784479     *                           user email, WP_User object, WP_Post object, or WP_Comment object.
    44794480     */
     
    44974498        $user = get_user_by( 'id', absint( $id_or_email ) );
    44984499    } elseif ( is_string( $id_or_email ) ) {
    4499         if ( str_contains( $id_or_email, '@md5.gravatar.com' ) ) {
     4500        if ( str_contains( $id_or_email, '@sha256.gravatar.com' ) ) {
     4501            // SHA-256 hash.
     4502            list( $email_hash ) = explode( '@', $id_or_email );
     4503        } else if ( str_contains( $id_or_email, '@md5.gravatar.com' ) ) {
    45004504            // MD5 hash.
    45014505            list( $email_hash ) = explode( '@', $id_or_email );
     
    45314535
    45324536        if ( $email ) {
    4533             $email_hash = md5( strtolower( trim( $email ) ) );
     4537            $email_hash = hash( 'sha256', strtolower( trim( $email ) ) );
    45344538        }
    45354539    }
     
    45654569     *
    45664570     * @param string $url         The URL of the avatar.
    4567      * @param mixed  $id_or_email The avatar to retrieve. Accepts a user ID, Gravatar MD5 hash,
     4571     * @param mixed  $id_or_email The avatar to retrieve. Accepts a user ID, Gravatar SHA-256 or MD5 hash,
    45684572     *                            user email, WP_User object, WP_Post object, or WP_Comment object.
    45694573     * @param array  $args        Arguments passed to get_avatar_data(), after processing.
     
    45774581     *
    45784582     * @param array $args        Arguments passed to get_avatar_data(), after processing.
    4579      * @param mixed $id_or_email The avatar to retrieve. Accepts a user ID, Gravatar MD5 hash,
     4583     * @param mixed $id_or_email The avatar to retrieve. Accepts a user ID, Gravatar SHA-256 or MD5 hash,
    45804584     *                           user email, WP_User object, WP_Post object, or WP_Comment object.
    45814585     */
Note: See TracChangeset for help on using the changeset viewer.