From 3bca18fb4c35616074c7e9daabcef183521b8e6c Mon Sep 17 00:00:00 2001 From: "Leigh B. Stoller" Date: Mon, 10 Nov 2003 15:22:12 +0000 Subject: [PATCH] More security hacking: Do not allow and random user from the internet to logout any random user on the testbed; only logged in admin users can do that now! --- www/TOCHECK | 6 +++--- www/logout.php3 | 51 ++++++++++++++++++++++++++++++++----------------- www/menu.php3 | 2 +- www/tbauth.php3 | 7 ++++++- 4 files changed, 43 insertions(+), 23 deletions(-) diff --git a/www/TOCHECK b/www/TOCHECK index 097d3a206..e7cfb5c23 100644 --- a/www/TOCHECK +++ b/www/TOCHECK @@ -73,8 +73,8 @@ freezeuser.php3 index.php3 joinproject.php3 loadimage.php3 -login.php3 -logout.php3 +login.php3 X +logout.php3 X menu.php3 menu.php3.java modifyexp.php3 @@ -146,7 +146,7 @@ start.php3 survey.php3 swapexp.php3 tbauth.php3 -toggle.php +toggle.php X top2image.php3 tutorial/docwrapper.php3 X tutorial/tutorial.php3 X diff --git a/www/logout.php3 b/www/logout.php3 index e5095b698..9d451429b 100644 --- a/www/logout.php3 +++ b/www/logout.php3 @@ -1,7 +1,7 @@ +

You do not have permission to logout '$target_uid' +

\n"; + PAGEFOOTER(); + return; +} -echo "

Logout attempt failed!

\n"; +if (DOLOGOUT($target_uid) != 0) { + PAGEHEADER("Logout"); + echo "

Logout '$target_uid' failed!

\n"; + PAGEFOOTER(); + return; +} # -# Standard Testbed Footer +# Success. Zap the user back to the front page, in nonsecure mode. # -PAGEFOOTER(); +header("Location: $TBBASE/"); ?> + + diff --git a/www/menu.php3 b/www/menu.php3 index 2d73d1000..d9d3c8eba 100644 --- a/www/menu.php3 +++ b/www/menu.php3 @@ -362,7 +362,7 @@ function WRITESIDEBAR() { if ($login_status & (CHECKLOGIN_LOGGEDIN|CHECKLOGIN_MAYBEVALID)) { echo ""; echo ""; - echo ""; + echo ""; echo "\"logoff\"\n"; echo "\n"; diff --git a/www/tbauth.php3 b/www/tbauth.php3 index cfb984452..38dc6d282 100644 --- a/www/tbauth.php3 +++ b/www/tbauth.php3 @@ -494,6 +494,11 @@ function VERIFYPASSWD($uid, $password) { function DOLOGOUT($uid) { global $TBDBNAME, $TBSECURECOOKIES, $CHECKLOGIN_STATUS; + # Pedantic check. + if (!TBvalid_uid($uid)) { + return 1; + } + $CHECKLOGIN_STATUS = CHECKLOGIN_NOTLOGGEDIN; $query_result = @@ -501,7 +506,7 @@ function DOLOGOUT($uid) { # Not logged in. if (($row = mysql_fetch_array($query_result)) == 0) { - return 0; + return 1; } $hashkey = $row[hashkey]; -- GitLab