6

I have an application which use the Thick box jQuery component to open a popup page .

And I pass my parameters in query string like this :

 <a id="btnShowPopup6" runat="server" class="thickbox" href='<%#"RollUp.aspx?TCode="+Eval("Code")+"...."+"&AR=1"+"&TBiframe=true&height=530&width=750"%>'>

This 's the only choice I have, I can't use session variables with this method or post parameters so just the query string way.

How can I secure my query string so the user can't play with them? What's the best way to encrypt my query string?

Polynomial
  • 132,208
  • 43
  • 298
  • 379

1 Answers1

5

Putting user-provided values into an eval() call is a horrible idea, because it essentially amounts to a remote code execution vulnerability. Let's say your code looks like this...

var data = eval(webRequest.Parameters["p"]);

Now imagine I put this into the p parameter...

System.IO.File.Delete(@"c:\windows\system32\ntoskrnl.exe");

Whoops! I just deleted your kernel.

No amount of messing around with escaping will work here - it's a fundamentally broken concept.

Encrypting parameters does nothing but complicate things. Go for the correct approach, and use a session variable like the language is designed to do.

Update: To be clear, I'm talking about eval() in a generic sense. If you're using the Eval binding method on a data controller in C#, you should be OK as long as no user parameters go in there, otherwise they can cause your code to dump out arbitrary values from your database, without even needing SQL injection.

Polynomial
  • 132,208
  • 43
  • 298
  • 379