Skip to:
Content

BuddyPress.org

Changeset 9023


Ignore:
Timestamp:
09/16/2014 02:47:06 PM (11 years ago)
Author:
boonebgorges
Message:

Use JSON encoding rather than PHP serialization for storing group creation details in a browser cookie

PHP serialization and unserialization of user-provided input introduces
security vulnerabilities.

This is a port of r9017 to trunk.

Props DJPaul

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/bp-groups-actions.php

    r8678 r9023  
    135135    // Fetch the currently completed steps variable
    136136    if ( isset( $_COOKIE['bp_completed_create_steps'] ) && !isset( $reset_steps ) )
    137         $bp->groups->completed_create_steps = unserialize( stripslashes( $_COOKIE['bp_completed_create_steps'] ) );
     137        $bp->groups->completed_create_steps = json_decode( base64_decode( stripslashes( $_COOKIE['bp_completed_create_steps'] ) ) );
    138138
    139139    // Set the ID of the new group, if it has already been created in a previous step
    140140    if ( isset( $_COOKIE['bp_new_group_id'] ) ) {
    141         $bp->groups->new_group_id = $_COOKIE['bp_new_group_id'];
     141        $bp->groups->new_group_id = (int) $_COOKIE['bp_new_group_id'];
    142142        $bp->groups->current_group = groups_get_group( array( 'group_id' => $bp->groups->new_group_id ) );
    143143
     
    227227        // Reset cookie info
    228228        setcookie( 'bp_new_group_id', $bp->groups->new_group_id, time()+60*60*24, COOKIEPATH );
    229         setcookie( 'bp_completed_create_steps', serialize( $bp->groups->completed_create_steps ), time()+60*60*24, COOKIEPATH );
     229        setcookie( 'bp_completed_create_steps', base64_encode( json_encode( $bp->groups->completed_create_steps ) ), time()+60*60*24, COOKIEPATH );
    230230
    231231        // If we have completed all steps and hit done on the final step we
Note: See TracChangeset for help on using the changeset viewer.