Jump to content

code injection into crypt function?


tarka dhal

Recommended Posts

Hi, I am writing a function to authenticate against a NIS server (If I had a choice to not use NIS I would... but that is a seperate discussion!). I always make sure that user supplied input is properly validated before using it anywhere but the problem I have is that a users password in this case can contain pretty much any special character (I have no control over this). Now the only place I reference the user supplied password is within the crypt function as follows... (the field array being the fields from the passwd.byname map/password file).

if (crypt($_POST['password'], substr($field[1], 0, 12)) == $field[1]) {
         echo "authenticated";
}

Obviously using add_slashes etc is going to break the password checking, so my concern is whether it is possible to inject code into the crypt function. eg something like...

$_POST['password'] = "'a')) { echo 'hacked'; #";

I have tested setting the variable like this and can't break it or produce any sort of error or undesired behaviour, but I just wanted reassurance about the way the crypt function works eg does it expand the variable passed to it hence allowing some form of code injection or does it simply do what you want it to with the variable regardless of what it contains?

Sorry, was going to try and keep it short... didn't turn out that way!

Cheers!
Link to comment
Share on other sites

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.