473,378 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

ASP Security

I am trying to prevent users from submitting HTML pages from their
local machine to our website and I was wondering what the best way of
doing this was.

I was thinking about using the HTTP_REFERER server variable (to check
where the user has submitted a page from) as a blanket fix however
when you use the javascript document.location on a page the
HTTP_REFERER is always blank, which makes that a flawed fix.

I have seen other sites protect against this, so I know it can be
done. Whats the best way.

Thanks for listening.
Jul 19 '05 #1
6 1593
GingerNinja wrote:
I am trying to prevent users from submitting HTML pages from their
local machine to our website and I was wondering what the best way of
doing this was.

I was thinking about using the HTTP_REFERER server variable (to check
where the user has submitted a page from) as a blanket fix however
when you use the javascript document.location on a page the
HTTP_REFERER is always blank, which makes that a flawed fix.

I have seen other sites protect against this, so I know it can be
done. Whats the best way.


There is no such thing as client-side security.

You can't even guarantee that HTTP_REFERER isn't spoofed. With Mozilla
FireFox, I can already edit my headers and re-send the request (I can also
"unhide" your hidden inputs and change their values while I'm at it). How
would your ability to sense HTTP_REFERER help you in any way.

--
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.
Jul 19 '05 #2
Try this (pseudo code)

<%
strTemp = Request.Servervariables("SERVER_NAME")
if Not request.servervariables("HTTP_REFERER")=strTemp Then
Response.Write "Woops, your not supposed to be doing this, now go
away"
else
Response.Write "Thats the way to do it"
end if
%>

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!
"GingerNinja" <gr*******@hotmail.com> wrote in message
news:71**************************@posting.google.c om...
I am trying to prevent users from submitting HTML pages from their
local machine to our website and I was wondering what the best way of
doing this was.

I was thinking about using the HTTP_REFERER server variable (to check
where the user has submitted a page from) as a blanket fix however
when you use the javascript document.location on a page the
HTTP_REFERER is always blank, which makes that a flawed fix.

I have seen other sites protect against this, so I know it can be
done. Whats the best way.

Thanks for listening.

Jul 19 '05 #3
Here's a sample piece of code that might give some ideas and provide at
least some security:

' If there's a referer (such as from a form post), be sure it's from
this site.
If Request.ServerVariables("HTTP_REFERER") <> "" Then
' If this pg opened with SSL.
If Request.ServerVariables("HTTPS") = "on" Then
If jpsvbPartOfURL(Request.ServerVariables("HTTP_REFER ER"), "host") <>
mstrSiteHostSecure Then
Response.Redirect mstrSiteMainSecure & "/login.asp"
End If
Else
If jpsvbPartOfURL(Request.ServerVariables("HTTP_REFER ER"), "host") <>
mstrSiteHost Then
Response.Redirect mstrSiteMainSecure & "/login.asp"
End If
End If
End If

Best regards,
J. Paul Schmidt, Freelance ASP Web Designer
http://www.Bullschmidt.com
ASP Designer Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #4
> How would your ability to sense HTTP_REFERER help you in any way.

On a basic level HTTP_REFERER would allow the ASP script to detect
where the HTML page was posted from, you could check the domain. If it
were posted from a HTML page on someones PC there would be no
HTTP_REFERER, unless ofcouse you spoof it. Like I said its a flawed
method. WHICH IS WHY I ASKED FOR HELP!
Jul 19 '05 #5
Thanks for the response, that solution would work a treat.
Unfortunitely if you use javascript to redirect to a page i.e.
document.location = 'mypage.asp' there doesnt seem to be a
HTTP_REFERER, so it would think that a legit page is infact an access
volilation and kick them out in error. Its probably design intent, but
a pain none the same. I'll have to get rid of all the
document.location's unfortunitely I have inherited the original code
and I cant be certain that I'll catch all the document.locations,
guess I'll have to trust a find and replace eh? :-P

Cheers again
Try this (pseudo code)

<%
strTemp = Request.Servervariables("SERVER_NAME")
if Not request.servervariables("HTTP_REFERER")=strTemp Then
Response.Write "Woops, your not supposed to be doing this, now go
away"
else
Response.Write "Thats the way to do it"
end if
%>

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Jul 19 '05 #6
GingerNinja wrote:
On a basic level HTTP_REFERER would allow the ASP script to detect
where the HTML page was posted from, you could check the domain. If it
were posted from a HTML page on someones PC there would be no
HTTP_REFERER, unless ofcouse you spoof it. Like I said its a flawed
method. WHICH IS WHY I ASKED FOR HELP!


My point is that, while HTTP_REFERER can be useful, you should try to avoid
depending on it for your application to function.

And your application *security* should never depend on it. If you have
something worth protecting, that is.

What should you use? SSL, for one thing. I know it's expensive, but anything
worthwhile usually is. Besides, you probably don't need to use SSL for the
entire application.

Amazon represents a decent model for web applications that mix secure and
non-secure segments. Most of what you do on their site requires no security.
You get to queue up a transaction -- and quite possibly an enormous one --
while your identity has not been confirmed (and might be entirely unknown),
then commit to it only after logging in through the secure server.

While you are using Amazon's site, your session is tracked, whether you have
logged in or not. That session spans their entire server farm, and in some
circumstances can even be resumed from another computer/browser session.

Do yourself a favor, and trace a visit to Amazon**. Put something in your
shopping cart and proceed to checkout (no need to actually check out). Look
at the progression of redirections and cookies in the process. Consider what
Amazon gets from each request and how that maps to WHAT AMAZON KNOWS. For
example, I typed in http://amazon.com/ and this was what my browser sent
(cleaned up for display and privacy):

GET http://amazon.com/ HTTP/1.1
Host: amazon.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.7)
Gecko/20040614 Firefox/0.9
Accept: text/xml,application/xml,application/xhtml+xml,text/html;
q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Proxy-Connection: keep-alive
Cookie: x-main=X6u4uuCVtnpcgyxVkjY4DkoHxqK01gzx;
session-id-time=1095667200;
ubid-main=430-2712009-5438522;
session-id=102-3281207-0584588;
order_cache_primed=1A3DQZB9MCKXADJ;
obidos_path_continue-shopping=continue-shopping-url=
/subst/home/home.html/102-3281207-0584588&
continue-shopping-post-data=
&continue-shopping-description=generic.gateway.default

Not much in there about me, right? But it did greet me with "Hello, Dave
Anderson", and there was even an item in my shopping cart from a session I
initiated at a different computer several days ago. Interestingly, each
browser has a unique cookie signature, and each of MY combinations of
cookies maps to the same common "session".

At this point, you're probably wondering what this has to do with security.
Well, it has *everything* to do with security. Amazon understands that a
request is just a bundle of unverified stuff thrown at its servers. It knows
not to trust most of the information in the request -- and that includes
HTTP_REFERER. I would venture a guess that Amazon trusts nothing whatsoever
in this request.

The site uses a token to track the session. It only puts the token into a
relationship of trust when I log in through the SSL segment. Everything
leading up to that point is a staging step. Nothing important happens out
there.

In short, you should act as though the client is free to change anything he
likes in the request. If you are unable to accept that, then you should
reconsider having a web application at all.


**SUGGESTION: Use Mozilla FireFox (http://www.mozilla.org/products/firefox/)
and the LiveHTTPHeaders extension
(http://extensionroom.mozdev.org/more...ivehttpheaders) to view the
traffic. The default filter (/$|.html$) helps cut some of the noise at the
beginning, but you can't see the entire picture if you leave it on.

--
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.
Jul 19 '05 #7

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

Similar topics

2
by: robert | last post by:
well, talk about timely. i'm tasked to implement a security feature, and would rather do so in the database than the application code. the application is generally Oracle, but sometimes DB2. ...
116
by: Mike MacSween | last post by:
S**t for brains strikes again! Why did I do that? When I met the clients and at some point they vaguely asked whether eventually would it be possible to have some people who could read the data...
4
by: Ashish | last post by:
Hi Guys I am getting the following error while implementing authentication using WS-security. "Microsoft.Web.Services2.Security.SecurityFault: The security token could not be authenticated...
0
by: prithvi g via .NET 247 | last post by:
Hi I am a newbie to .NET remoting, I am trying to implementauthorization using SSPI example provided by Michael Barnett. Ihave included the required dll(Microsoft.Samples.Security.SSPI.dll...
1
by: Earl Teigrob | last post by:
Background: When I create a ASP.NET control (User or custom), it often requires security to be set for certain functionality with the control. For example, a news release user control that is...
7
by: Magdelin | last post by:
Hi, My security team thinks allowing communication between the two IIS instances leads to severe security risks. Basically, we want to put our presentation tier on the perimeter network and the...
0
by: Jay C. | last post by:
Jay 3 Jan. 11:38 Optionen anzeigen Newsgroups: microsoft.public.dotnet.framework.webservices.enhancements Von: "Jay" <p.brunm...@nusurf.at> - Nachrichten dieses Autors suchen Datum: 3 Jan...
3
by: Velvet | last post by:
I ran FxCop on one of the components for my web site and the security rules what me to add " tags like the ones listed below: This breaks my ASP.NET application. So my question is,...
1
by: Jeremy S. | last post by:
..NET's code Access Security enables administrators to restrict the types of things that a .NET application can do on a local computer. For example, a ..NET Windows Forms application can be...
2
by: Budhi Saputra Prasetya | last post by:
Hi, I managed to create a Windows Form Control and put it on my ASP .NET page. I have done the suggestion that is provided by modifying the security settings. From the stack trace, I would...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.