Jump to content

possible to "id=123" -> "id='all'"?


Recommended Posts

Just a quick question.

Possible for an outside user to make the code assume "all" for a url var, like for example: "show_topic.php?id=12345", to make it "show" all ID's isntead of just a specific number?

 

Actually asking for a delete function for a forum, where 'outside' moderators could have a 'delete' option, but could be exploited somehow... Just trying to figure out all the options.

Link to comment
https://forums.phpfreaks.com/topic/47303-possible-to-id123-idall/
Share on other sites

In any even your code should ALWAYS validate any input by the user this includes values passed on the query string as well as through form input.

 

'all' would have no meaning unless you specifically coded it to have meaning. However, if you aren't carefull a user could use sql injection to delete all records.

 

For example, if you were using th following query

DELETE FROM table WHERE id = '$id'

 

A malicious user could try and pass an id value of 1' OR 1 = '1

 

The resulting query would look like this

DELETE FROM table WHERE id = '1' OR 1 = '1'

 

And the second half of that OR would cause all records to be deleted. The solution Barand would be perfect for this situation, but I am just elaborating to emphasize that all user input needs to be validated.

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.