This is a discussion on "idea for "securing" Robs FormFunction" within the Classic ASP section. This forum, and the thread "idea for "securing" Robs FormFunction are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
idea for "securing" Robs FormFunction
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
idea for "securing" Robs FormFunction
So, Rob wrote this really cool set of functions that convert form variables, cookies, and query strings to variables, hidden form fields and cookies.
Sample of Robs code: <% function GetVariables(type1,type2) if lcase(type1)="form" or lcase(type2)="form" or lcase(type1)="all" then For Each Field In Request.Form TheString = Field & "=Request.Form(""" & Field & """)" Execute(TheString)'Executes the command contained in the string(This will set all VBScript variables) Next end if if lcase(type1)="cookies" or lcase(type2)="cookies" or lcase(type1)="all" then For Each Field In Request.cookies TheString = Field & "=Request.cookies(""" & Field & """)" Execute(TheString)'Executes the command contained in the string(This will set all VBScript variables) Next end if if lcase(type1)="querystring" or lcase(type2)="querystring" or lcase(type1)="all" then For Each Field In Request.querystring TheString = Field & "=Request.querystring(""" & Field & """)" Execute(TheString)'Executes the command contained in the string(This will set all VBScript variables) Next end if END function %> I wrote him to say that I added a functionallity, which was to print the data to the screen because it's very useful for debugging. He said that he doesn't distribute it anymore because of the security issues. I know that one of the big ones is joining SQL onto the end of strings that will be used as variables and to through text into a numeric field to get the DB engine to throw an error (or run the SQL). In my searching of the web, I found this really cool function that I think largely circumvents this on a string by string basis.. it looks like this: (it also converts multiple spaces to single spaces because of what I'm doing with my data) <% 'a function to replace single quotes with two single quotes to pass the SQL engine. because I didn't want to keep typing it 'also looks for pipe and percent as recommended on experts-exchange.com function switchQuotes(text) text = Replace( _ Replace( _ Replace( _ Replace( _ Replace( _ Replace( Trim(text), "'", "''"), _ "\n", " "), _ vbcrlf, " "), _ "|", ""), _ "%", ""), _ chr(34), """") while instr(text, " ") > 0 text = Replace(text, " ", " ") wend switchQuotes = text end function %> So I thought that if you integrated this that would take care of the string issues. So the guts of the loop would look something like: myfield = switchquotes(request.form(field)) theString = field & "=" myfield Execute(TheString) This way, the checking for "red flags" in strings is checked on form (or whatever) load and the user doesn't have to do separate checks. Then there's the numeric peice. I don't have code for this but I was thinking something along the lines of opening up the recordset and looking for fields that are datatyped numeric (would this include boolean? how about dates?) After you load all your stuff into the variables, you could create an array and loop the recordset, loading fieldnames of fields with vulnerable datatypes into the array. If you've names your form variables (or cookies, or whatever) the same name as your recordset field names then you could loop the array of field names saying something like this: dim blnNotNumeric blnNotNumeric = true for i = 0 to ubound(array) if not isNumeric(array[i]) then blnNotNumeric = false next if not blnNotNumeric then response.redirect "error.html" or something like that. Comments? Thoughts? Threats to knock me upside the head? jakyra |
|
|
|
#2
|
|||
|
|||
|
I believe its Execute() thats the problem...
|
|
#3
|
|||
|
|||
|
What is the issue with the Execute() function? I haven't seen that exploit.
Thanks jakyra |
|
#4
|
|||
|
|||
|
AFAIK its something to do with denial of service..... Rob
|
|
#5
|
||||
|
||||
|
I really don't want to go into 'how' this can be exploited... purely because there are so many copies of these functions on the net... I recieve 2 or 3 emails a day from people thanking me for them.
I have basically stopped supporting them, because I can figure out 3 ways of exploiting them... 1 of the exploits, as Smokie says, is indeed a DoS another allows SQL queries to be executed, depending on how the script is being used... and the other, again depending how the script is used, can give access to the filesystem. Please do not ask me to elaborate on how, coz I wont! I would only recommend the use of my scripts that deal with variables using the 'EXECUTE' function on an Intranet.. .away from the public domain.
__________________
Click the 'Thanks!' button if this post has helped you Rob - Webforumz Founder
Last Blog Entry: Creative Labs threaten developer over home made drivers.... (Apr 1st, 2008)
|
|
#6
|
|||
|
|||
|
Ok, I won't ask how. I promise!
Thanks for the information. jakyra |
|
#7
|
||||
|
||||
|
Ah, the memories. This variable thing is how we met Rob. Man that was many years ago. :-)
|
|
#8
|
|||
|
|||
|
<blockquote id="quote"><font size="1" face="geneva, verdana, arial" id="quote">quote:<hr height="1" noshade id="quote">Originally posted by Rob
I really don't want to go into 'how' this can be exploited... purely because there are so many copies of these functions on the net... I recieve 2 or 3 emails a day from people thanking me for them. I have basically stopped supporting them, because I can figure out 3 ways of exploiting them... 1 of the exploits, as Smokie says, is indeed a DoS another allows SQL queries to be executed, depending on how the script is being used... and the other, again depending how the script is used, can give access to the filesystem. Please do not ask me to elaborate on how, coz I wont! I would only recommend the use of my scripts that deal with variables using the 'EXECUTE' function on an Intranet.. .away from the public domain. <hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote"> Aww, Rob you gotta tell us how to hack these!!! I wanna have a look, why don't we have a competition where we all look at the code and see how many serious security issues we can find? Security through obscurity. I like it. Very Microsoft... hehe. |
|
#9
|
|||
|
|||
|
sounds good to me, lil hacking contest!
|
|
#10
|
|||
|
|||
|
ok, I'm stubborn and lazy.
(Just thought I'd start there Since my site isn't an intranet site, I'm trying to find a work around for the glorious idea of not having to type all my own form fields/cookies/recordset fields/etc. Also, I've read that manipulating data right from the recordset is very inefficient/slow/etc. So I wrote one for a recordset. It loads the recordset into an array using getrows, but then I want to be able to reference the data by name, not by number (for updating ease). So I came up with these paired functions:
Is there a better way that doesn't involve hard coding? Thanks! jakyra (On the endless quest for non-hardcoded code) |
![]() |
| Tags |
| idea, securing, robs, formfunction |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Is this idea new or already taken? | CloudedVision | Website Planning | 4 | Mar 26th, 2008 10:29 |
| Securing test enviroment | Spartan0510 | PHP Forum | 6 | Nov 15th, 2007 15:51 |
| Securing Web Forms | russellbain | JavaScript Forum | 2 | Jan 11th, 2007 20:06 |
| securing email scripts from spam | maniac | Classic ASP | 1 | Nov 16th, 2006 12:08 |