Jump to content

Recommended Posts

Hi Everyone,

 

Hoping you can help. I've been using session authentication for a while on a few small sites without any problems up until now. 

 

I have recently been getting some html injections into a form that only members can view thought session authentication. I set up a log on the login page and compromised form to see if they were gaining access through the login form then injecting into the other form but the entries didn't match up so I assume they are bypassing my authentication script for that form.

 

Here is my authentication script which is called at the start of every member only page:

 

function memberAuth(){

session_start();

if($_SESSION['MEMBER'] !== "YES"){

session_destroy();

header("Location: memberLogin.php");

}

}

 

Is there any easy way to bypass this? I've used this for a while and never ran into any problems before.

 

If you need any additional info, please let me know.

 

Thx.

Link to comment
https://forums.phpfreaks.com/topic/89494-solved-form-injection-problems/
Share on other sites

In case you don't understand the difference between != and !==

 

<?php
// In PHP, both of these mean true...
$a = true;
$b = 1;

// Both $a and $b are true, but !== also checks to see if they are of the same type, $a is a boolean and $b is an integer.
if( $a !== $b ) echo( 'false' );
// Will return false.
?>

 

Did you consider session fixation?  What's important is what you're doing in memberLogin.php.  This topic is discussed in many places, including an article that they've linked to on the php.net page for sessions, and there's also this article that's php specific by Chris Shifflet.  http://shiflett.org/articles/session-fixation

 

 

What does your code do after it calls that function? The header() redirect is performed by the browser. If your code just continues execution and the browser (or a script that could care less about headers your code sends out) does not redirect, then they will access the protected content on the page. You must execute an exit; statement at some point after the header() statement to stop the code on the rest of the page from executing.

There is no code after the redirect, it just loads up the form page.

 

So if they aren't using a browser or have some modded browser that doesn't recognize the header cmd then it will just send them my form and they can post to it?

 

Will exit; stop the html afterwards from loading?

 

Thx.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.