Make WordPress Core

Changeset 59671


Ignore:
Timestamp:
01/21/2025 01:17:32 PM (5 months ago)
Author:
johnbillion
Message:

Security: Set the HttpOnly flag for the test cookie and the wp_lang cookie on the login screen.

These cookies are only accessed server-side and don't need to be exposed to JavaScript in the browser.

Props earthman100, kevinlearynet

Fixes #61322

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-login.php

    r59138 r59671  
    529529// Set a cookie now to see if they are supported by the browser.
    530530$secure = ( 'https' === parse_url( wp_login_url(), PHP_URL_SCHEME ) );
    531 setcookie( TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN, $secure );
     531setcookie( TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN, $secure, true );
    532532
    533533if ( SITECOOKIEPATH !== COOKIEPATH ) {
    534     setcookie( TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN, $secure );
     534    setcookie( TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN, $secure, true );
    535535}
    536536
    537537if ( isset( $_GET['wp_lang'] ) ) {
    538     setcookie( 'wp_lang', sanitize_text_field( $_GET['wp_lang'] ), 0, COOKIEPATH, COOKIE_DOMAIN, $secure );
     538    setcookie( 'wp_lang', sanitize_text_field( $_GET['wp_lang'] ), 0, COOKIEPATH, COOKIE_DOMAIN, $secure, true );
    539539}
    540540
Note: See TracChangeset for help on using the changeset viewer.