...

View Full Version : Is session_id() secure?



iLochie
11-19-2011, 10:01 AM
I'm using the session_id() method to directly (that is, without sanitation) input the resulting id into a MySQL database. Assuming I've done everything right (the user is not able to change the cookie through the URL, for example), is it still possible to inject some sort of malicious SQL into this ID? Or is it completely free from user modification?

For example, if a user were to modify his cookie to be a SQL injection, would I run into a problem?

tangoforce
11-19-2011, 01:44 PM
If a user modified their cookie and you're using this id in a SQL query then of course its dangerous. It's still potentially dangerous SQL and it will be just like any other string.

Sanitise it. Job done. It's only one function at a minimum so why is this a big issue?

iLochie
11-19-2011, 06:45 PM
If a user modified their cookie and you're using this id in a SQL query then of course its dangerous. It's still potentially dangerous SQL and it will be just like any other string.

Sanitise it. Job done. It's only one function at a minimum so why is this a big issue?
It's not a big issue, however I wanted to make sure I understood the functional use of session_id and who has access to modifying it.

Hah, I actually forgot I have a whole sanitation/validation function already programmed, and I'm using it! It just looks like the session_id function is being inputted directly, but the sanitation runs before any other part of script, so it's fine.

Thanks for the reassurance.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum