Jump to content

Things I should know regarding the $_SERVER['HTTP_HOST'] variable?


Attilitus

Recommended Posts

I have developed a lightweight, but very secure, php licensing system using fairly simple methods.

 

My main question is, how reliable is the $_SERVER['HTTP_HOST'] variable? I have dealt with security on all other levels, but I have my doubts as to whether or not using that variable as an authentification method would be completely secure. Are there any known methods for manipulating that value to display something other than the actual domain running the script? If so are there any ways to counteract these efforts, or perhaps a better method of verification?

Link to comment
Share on other sites

In order for them to do something like that though, they'd need to change the server side script. Attilitus wants to know if it's possible on the client side to change that. I'm unsure of this myself, but I believe that data is sent over as part of the headers to the server, so I'm sure it could be changed by doing some packet manipulation.

 

Then again, I might be wrong on that, but that's how I think it's implemented.

Link to comment
Share on other sites

No this is part of a php script licensing system, so being able to change the variable by modifying server-side script is indeed a problem. The code itself would of course be encrypted but, inclusion would be easily possible.

 

Is there anyway to set the server variable to the proper domain, or perhaps a better means of verifying the information of the server running the file?

 

Thanks in advance!

Link to comment
Share on other sites

HTTP_HOST is given to PHP by Apache/IIS (the server) so you shouldn't be able to manipulate it on the client side.

 

No this is part of a php script licensing system, so being able to change the variable by modifying server-side script is indeed a problem. The code itself would of course be encrypted but, inclusion would be easily possible.

 

Is there anyway to set the server variable to the proper domain, or perhaps a better means of verifying the information of the server running the file?

 

You _could_ use the Server IP to reverse DNS and get the hostname by then I assume they could change the IP.

 

I briefly tested and changing $_SERVER['HTTP_HOST'] does not affect getenv( 'HTTP_HOST' ); which also returns the host.

Link to comment
Share on other sites

Hm... So would that be a relatively unfakable method of returning the domain name of the script?

 

Any additional anti-cheating methods would be greatly appreciated too, to prevent the bypassing of an external call-home.

 

edit: I believe that php merely treats the getenv function variables as merely "different" but still modifiable ones. Can someone confirm/deny this?

Link to comment
Share on other sites

Perhaps... if I were to store the variable before including any other files would it be possible to bypass it at all? (eg. would they be able to modify the variables or include code?)

 

Here is an example:

 

<?php

//You get the picture...

$storevariable=SERVER[DOMAIN] ;

 

require_once('./include/non-encryptedinclude.php');

 

Checklicense($storevariable);

 

Main script;

 

?>

Link to comment
Share on other sites

Usually it's only good if you want to store session variables. However, when you use a session_start() everything else will error out if the session_start() isn't the first thing. So if you place a file with say:

 

<?php

session_start();

//backup variable

?>

 

That will have to execute first, or the page will error out. This will make it so you will always get that backed up.

 

For that matter, you can also store the backed up copy in a session variable just to make use of it, or call a session_end() in the same file.

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.