Jump to content

preventing injection attacks etc


ess14

Recommended Posts

just curious, is it better to use regex to check input into databases than using stripslashes/addslashes etc?

 

I figure that using regex to make sure there is only alphanumeric characters in strings no attacks could occur. is this correct? or am i missing something?

 

of course sometimes you want special characters in your DB, so in which case you would addslashes or use other php functions (real escape string etc).

 

 

Link to comment
Share on other sites

Regex is a GREAT way to sanitize user input. The stricter you are, the harder it is to inject. This does limit the end-user slightly, so you have to trade off.

 

Your best method to protect is know how your attacks are being performed. The better you know your attacker, the less strict you have to be with your sanitization

 

On the other hand, the more strict you make your sanitzation, the better protected you are against future exploits :)

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.