hi everyone!
I have just developed an authentication script to protect some php content...
It authenticates users against a mysql database using php sessions and session_cookies.
What i would like to know is simply whether it is safe or not. What are the potential most serious security flaws?
Let me describe the authentication process (which may be familiar to most of the readers)...
- session_start()
- not authenticated? -> login request form
- after the request form, pass entered username and password to some session variables
- check against database if there is any entry matching entered username+password strings
4.1. If there is a match, pass some other variables from the database into session variables.
4.2. If there is no match, remove all session variables and give error message. Script ends
- intended content is rendered. Script ends
The way i built it makes it usable via an include() or require() call in any php file. That include() does all the authentication work. If the authentication comes out true, the script simply allows the execution of the rest of the file. If not, it stops... i think you know what i mean.
Another feature is that it allows one to stay "logged in" in every page requesting that script. The thing is that once you login, the session is created with your data, so that when you try to include() the script again in another file, it executes the session_start() and the variables are there. The verification is then made transparently, no login form this time.
This is where i think the script fails... There is allways the username+password among the session variables. Is there a way to access those variables from the outside??
Another thing is that if i login with that script from one browser window, and make a new window, i try to login again and i am already logged. This is another flaw... i figured out that the browser sends some kind of a hash and that the php sessions use that hash to identify a session... or something like that.
Is there any way to create a unique session_name everytime i log in? Of course, that name must be maintained so that the "login" effect stays.
How are "professional" authentication scripts made? What kind of php functions do the pros use??
Sorry for the long post, sorry for the lousy english and please relocate this form if the moderators/admins think it is out of place.
Thank you very much!
[]