PC Review


Reply
Thread Tools Rate Thread

How to avoid website hijacking?

 
 
Anton
Guest
Posts: n/a
 
      5th Sep 2009
hi

I'm creating a website where people can posts comments etc, i fear that
someone can post script into the comment field and the script will redirect
the user to a different website - hijacking my website..

not sure how to avoid this

I know it some kind of test I should do on what the user types into the
comment field, but not sure how to do that test

any ideas?


 
Reply With Quote
 
 
 
 
Patrice
Guest
Posts: n/a
 
      5th Sep 2009
Do you want to allow some markup ?

Possible options are :

- use HTMLEncode, this way *all* markup will be considered as text and will
be just displayed (you could still recognize http scheme and add the link
yourself)

- if you want still to allow some code but not all you'll have to check the
input for sanity. Try Googling for "html sanitizer". I would recommend a
white list approach (i.e. rather than searching what is dangerous, all is
dangerous expect what you allowed). Also be aware of cases such as putting
javascript: in an src attribute which could perhaps run on some browser...

- AFAIK some are using special tags such as found in wikis. This way you
don't allow any HTML markup but still users are able to do some formatting

#3 would be likely my personal preference i..e comments are NOT html markup
still [http://www.mysite.com] or [http://mmy.site.com/myimage.png] could be
turned into a "a" and "img" tag but safely and used with explicit user
consent by clicking on the link. It is likely easier than avoiding to
introduce possisbly exploits in the allowed HTML markup.

--
Patrice


"Anton" <no_email> a écrit dans le message de
news:%(E-Mail Removed)...
> hi
>
> I'm creating a website where people can posts comments etc, i fear that
> someone can post script into the comment field and the script will
> redirect the user to a different website - hijacking my website..
>
> not sure how to avoid this
>
> I know it some kind of test I should do on what the user types into the
> comment field, but not sure how to do that test
>
> any ideas?
>


 
Reply With Quote
 
Scott M.
Guest
Posts: n/a
 
      5th Sep 2009
The ASP .NET engine contains code to check for cross site scripting attacks
and does this automatically for you. You don't need to worry about scripts
being entered into your controls.

-Scott


"Anton" <no_email> wrote in message
news:%(E-Mail Removed)...
> hi
>
> I'm creating a website where people can posts comments etc, i fear that
> someone can post script into the comment field and the script will
> redirect the user to a different website - hijacking my website..
>
> not sure how to avoid this
>
> I know it some kind of test I should do on what the user types into the
> comment field, but not sure how to do that test
>
> any ideas?
>



 
Reply With Quote
 
Patrice
Guest
Posts: n/a
 
      5th Sep 2009
> The ASP .NET engine contains code to check for cross site scripting
> attacks and does this automatically for you. You don't need to worry
> about scripts being entered into your controls.


Works but if you do nothing then you can't use < or > which could be a
problem depending on the kind of comments you expect (if the site is about
HTML or programming it won't fit as is...). I agree though this is where the
OP should start...

--
Patrice

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to avoid Compatibility Checker MsgBox? VBA to avoid or prevent? EagleOne@discussions.microsoft.com Microsoft Excel Programming 1 16th Jan 2009 08:54 PM
Re: How to avoid login window in restricte ASP.NET website? Mark Rae Microsoft ASP .NET 0 10th Jan 2007 04:53 PM
Re: How to avoid login window in restricte ASP.NET website? bruce barker Microsoft ASP .NET 0 10th Jan 2007 04:46 PM
Is the way i do, secure enought to avoid session hijacking Hope Paka Microsoft ASP .NET 13 15th Jul 2005 03:23 PM
How to avoid gaps in website when browser set for 'large text' =?Utf-8?B?bnU=?= Microsoft Frontpage 1 15th Jun 2005 06:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:06 PM.