Jim said:
I accepted that a long time ago...
I'm not sure you have, unless I misunderstand the following:
It's not that I am running code before validation, it's concern
for code a hacker may have input into a form field that will get
executed before my form gets validated. (if that's even possible
- I don't know)
I can't tell if you are talking about client-side or server-side validation.
If client, you can assume you have no validation. If server, then consider
the following:
Each named form element passes a name-value pair (select-multiples send as
many pairs as elements selected) as part of the request. These are parsed
and put into the .Form or .QueryString collection of the Request object.
Each element in the collection has .Key, .Item and .Count properties. .Count
is an integer, while the other two are strictly strings. .Item is the
default property, so if you are using VBScript, references to
Request.Form(key) will actually point to Request.Form(key).Item.
These values are ordinary strings. They cannot execute anything in your
script unless you use the Execute Statment (VBScript) or the eval Method
(JScript).
http://msdn.microsoft.com/library/en-us/script56/html/vsstmexecute.asp
http://msdn.microsoft.com/library/en-us/script56/html/js56jsmtheval.asp
Most of us don't use either, for good reason. Strangely enough, some of the
same people who would never do so seem to think it's OK to execute SQL
strings constructed with user input. But that's another topic.
What could a hacker enter into a form to compromise my security?
That's a bit like asking what he could type on paper that would cause a
security breach in your computer. Unless you use Execute/eval() (or re-type
his words into your computer), you're not at risk.
There's always a slim chance that he could craft a request that exploits
some existing vulnerability, but then it would be an IIS problem, and your
script would be no more vulnerable than any other.
I've tried entering vbscript code lines into my form fields and
at best all I can do is break the form and get an ASP error.
How are you even able to get an ASP error in that manner? Are you talking
about something other than a type mismatch? Perhaps you could show some
code.
I know I can htmlencode fields before sending back to the screen,
but what happens to malicious code inserted into a form when it's
just stored in the form collection before ever being output to the
screen? Anything?
What happens when a malicious letter just sits in an unopened envelope?
Anything? No - it's just text.
Can a hacker use a form I've created to somehow view the asp
source for my pages, or gain access to the server itself (which
is hosted and not my responsibility, but nevertheless a concern)?
Curiously enough, maybe.
Suppose, for example, you expect one of the values to be numeric, but you
don't bother verifying it. If that value contains a non-numeric string and
you try an operation that requires a number, you could get a run-time ASP
error.
Suppose further that the error occurs in an include file, which you have
conveniently named "myInclude.inc" without bothering to assign asp.dll as an
ISAPI extension for .inc files, and your server is configured to use the
default 500;100 error page.
Lucky you! Your error triggers an error that reads something like this:
Type mismatch error
myInclude.inc
Line 32, character 10
The hacker types the following into his browser...
http://yoursite.com/path/myInclude.inc
....and gets to read your entire include.
Scary? Only if you (a) don't validate your incoming data before using it,
(b) use includes with extensions that are not parsed by asp.dll**, (c) use
no exception handling, and (d) give away the farm on your 500;100 error
page.
**I just avoid the whole mess by using .asp for everything. This caused no
end of confusion for a vendor I was working with once, so I now use
something along the lines of myInclude.js.inc.asp or myInclude.vbs.inc.asp
--
Dave Anderson
Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.