php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25110 $_SESSION can be changed indirectly
Submitted: 2003-08-16 16:25 UTC Modified: 2003-08-16 23:52 UTC
From: carl at freeideas dot com Assigned:
Status: Not a bug Package: Session related
PHP Version: 4.3.2 OS: OSX and WIN2K
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: carl at freeideas dot com
New email:
PHP Version: OS:

 

 [2003-08-16 16:25 UTC] carl at freeideas dot com
Description:
------------
When register_globals is on, and after a session has already been started, $_SESSION values can be changed indirectly.

$_SESSION['userID'] = 'carl';
$userID = $_SESSION['userID'];
$userID = 'HAXOR';
# now $_SESSION['userID'] is 'HAXOR'

To me, this seems like a bad thing.

Happens under Mac OS 10.2, w/ PHP 4.3.2
Happens under Win2K w/ PHP 4.3.2
Doesn't happen under Linux w/ PHP 4.2.3


Reproduce code:
---------------
<?
# Demonstrates that $_SESSION can be changed indirectly.
# the alleged bug activates when register_globals is ON.

# set a userID in the session
session_start();
$_SESSION['userID'] = 'carl';
  
# copy userID into a global variable, $userID
$userID = $_SESSION['userID'];
  
# change only $userID
print "before: ". $_SESSION['userID'] ."<br>\n";
$userID = 'HAXOR';
print "after: ". $_SESSION['userID'] ."<br>\n";
if ( $_SESSION['userID']=='HAXOR' ) { print "bad"; }
  
# seems very wrong that $_SESSION['userID'] was changed
?>

Expected result:
----------------
After I run the script and reload it once, I should not see "bad" because changing $userID should not change $_SESSION['userID'].


Actual result:
--------------
bad

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-08-16 23:52 UTC] sniper@php.net
This can actually be called "feature" rather than bug.
If you don't like it, don't use 'register_globals = On' (it's a bad idea anyway)

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 10:01:31 2024 UTC