473,805 Members | 2,191 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Validating User Input to Avoid Attacks

Hi All,

I am working on a web application that uses both asp classic and asp.net
pages. We need to validate user input to avoid attacks like sql injection.
Can a component be created that both page types can use? Is that the best
approach? Would I simply use pattern matching to validate strings and/or
remove any unwanted characters?

Thanks in advance.
Jul 12 '06 #1
3 2327
A TO Consultant wrote:
Hi All,

I am working on a web application that uses both asp classic and
asp.net pages. We need to validate user input to avoid attacks like
sql injection. Can a component be created that both page types can
use? Is that the best approach? Would I simply use pattern matching
to validate strings and/or remove any unwanted characters?

Thanks in advance.
For SQL Injection, while validation is important, it is not enough to
prevent it. If you truly wish to prevent SQL Injection, you will avoid
all use of dynamic sql*, using parameters to pass values instead.

I do not believe that validation can be made as generic as you are
hoping it can be: some data should not contain sql keywords, and other
data should.

*I am defining dynamic sql as the act of concatenating user input into
sql statements which are subsequently executed.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 12 '06 #2
Thanks Bob.

When you say to use parameters to pass values instead, do you mean to use
stored procedures and call them with the values as parameters?

"Bob Barrows [MVP]" wrote:
A TO Consultant wrote:
Hi All,

I am working on a web application that uses both asp classic and
asp.net pages. We need to validate user input to avoid attacks like
sql injection. Can a component be created that both page types can
use? Is that the best approach? Would I simply use pattern matching
to validate strings and/or remove any unwanted characters?

Thanks in advance.
For SQL Injection, while validation is important, it is not enough to
prevent it. If you truly wish to prevent SQL Injection, you will avoid
all use of dynamic sql*, using parameters to pass values instead.

I do not believe that validation can be made as generic as you are
hoping it can be: some data should not contain sql keywords, and other
data should.

*I am defining dynamic sql as the act of concatenating user input into
sql statements which are subsequently executed.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 12 '06 #3
That's my preferred technique, but it's not necessary. Both ADO and
ADO.Net allow the use of parameter markers to facilitate the passing of
parameter values into ad hoc sql strings. Here is a description of the
ADO implementation of this:

http://groups-beta.google.com/group/...e36562fee7804e
A TO Consultant wrote:
Thanks Bob.

When you say to use parameters to pass values instead, do you mean to
use stored procedures and call them with the values as parameters?

"Bob Barrows [MVP]" wrote:
>A TO Consultant wrote:
>>Hi All,

I am working on a web application that uses both asp classic and
asp.net pages. We need to validate user input to avoid attacks like
sql injection. Can a component be created that both page types can
use? Is that the best approach? Would I simply use pattern
matching to validate strings and/or remove any unwanted characters?

Thanks in advance.
For SQL Injection, while validation is important, it is not enough to
prevent it. If you truly wish to prevent SQL Injection, you will
avoid all use of dynamic sql*, using parameters to pass values
instead.

I do not believe that validation can be made as generic as you are
hoping it can be: some data should not contain sql keywords, and
other data should.

*I am defining dynamic sql as the act of concatenating user input
into sql statements which are subsequently executed.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get
a quicker response by posting to the newsgroup.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 12 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2895
by: The Plankmeister | last post by:
Hi... What's the best method of validating input characters? I would like to prevent users submitting exotic characters (such as those acquired on Windows Systems by pressing ALT+) and thought a way of doing this would be to compare the submitted strings with the array keys returned by get_html_translation_table(HTML_ENTITIES), but padding this array out with all the remaining normal keyboard characters. But... am I reinventing the...
3
3335
by: chotiwallah | last post by:
how can i validate reasonably safe that post data sent by a form is sent by my form and not by anyone elses? any help appreciated, micha
2
5205
by: bildad | last post by:
The following 'book example' of validating input seems to be incomplete. Since it is a beginner's book it may be intentional for simplicity. But I would like to know how to make this program work for all invalid input. Just for example, if user inputs 'abc' an error is caught, but if user inputs '432' the program hangs. Any clarification appreciated. Thanks, Bill
1
1528
by: Paul | last post by:
Hi, I'm developing a search facility for my web app. In order for the search criteria to be valid the user must (a) enter some text in a text box and check and least one checkbox (of which there are two) and/or (b) select at least one item from a multiple select list box. I've written the javascript to do the client side validation which gets called on the click event of my search button. I'd like to implement server side validation...
2
1149
by: Buddy Ackerman | last post by:
I have a form into which users will enter text. I want the user to be able to enter "some" HTML however I would like to prevent "bad" HTML. The "bad" HTML would be things like <SCRIPT>, <OBJECT>, <APPLET>, etc. Does anyone know of a good server side validator that will catch this type of "bad" HTML input while allowing the acceptable input? --Buddy
5
1245
by: Peter Morris [Air Software Ltd] | last post by:
Hi all I want to allow users to enter HTML, but I want to ensure that A) The HTML entered only contains a subset of html tags (a, img, div, etc) and not certain other elements (html, body, script) etc. B) The HTML is syntactically correct, so a <li> would have a corresponding </li>, a <td> would have a </td>, etc.
0
3242
by: joseph conrad | last post by:
Hi, I tried to implement my own session handler in order to keep control on the process the drawback I foun it is not creating and storing in my cookie the PHPSESSID variable anymore. reading te documentation it seems it should do it anyway any advice?
9
5850
by: chuck | last post by:
I need some help with validating user input. I am writing a C computer program for an intro to C course. Here is the situation. I am creating an application that will do currency conversions. The user will be presented with a list of 5 selections they can make. They will then be prompted for which selection they want to enter (which can only be 1-5, no characters or anything like it). Once they select the number, 1 for Euro, 2 for...
5
2327
by: Kavya | last post by:
I saw these two ways for validating input First Way -------------- #include <iostream> #include <limits> using namespace std; int main() {
0
9718
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9596
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10614
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10363
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10369
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5544
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4327
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.