Re: Validing a utf-8 string from search textbox with javascript regular expression
- From: "Richard Cornford" <Richard@xxxxxxxxxxxxxxxxxxx>
- Date: Wed, 11 Jul 2007 17:12:02 +0100
getsanjay.sharma@xxxxxxxxx wrote:
On Jul 11, 2:58 pm, Richard Cornford wrote:frohlin...@xxxxxxxxx wrote:
Client-side code offers no protection of anything from anything.
Your 'hackers' can knock-out, replace or re-define your
client-side validation with trivial effort (and if they want to
inject something they probably will do so as a matter of course).
I can understand knocking out(disabling it), but how can someone
replace or redefine my own script?
By just doing it. Javascript, being very dynamic, allows object properties to be assigned new values at any time and web browsers facilitate the execution of arbitrary code by the user (at its simplest, by entering javascript pseudo-protocol URLs in the address/location bar). If you have a function called, say, 'validate' and I want to re-define it I just have to write - javascript:void validate = function(x, y){ /* new function body */ }; - into the address/location bar and hit return and now 'validate' is the function I defined. And if you try masking your code inside closures (like Google maps tried) I can still re-define it by getting the source code as a string (from an exposed property, from the SCRIPT element via the DOM and/or from an external file with (in a worst case) an XML HTTP request) replace the sections of that string I want changed and then - eval - the script in the global context to have the changed code replace the original. Or I can write a dynamic script loading javascript URL that will import any arbitrary script from any source, providing the option to replace your code with mine or any (scripted) tools I may need to step outside the limitations imposed upon the javascript pseudo-protocol, and play with the script environment you define to my hart's content.
And all of that is without the options of using dedicated content inserting proxies, 'greasemonkey' scripts in Firefox/Mozilla/Gecko browser or scripting an IE browser instance from windows scripting host (and so side-stepping most security and bringing the 'big guns' of ActiveX that are too dangerous to be allowed to run in normal IE into the game).
The javascript executing on the client is entirely at the mercy of the person sitting in front of the computer on which it is executing, and so client-side code provides precisely zero security.
Richard.
.
- References:
- Validing a utf-8 string from search textbox with javascript regular expression
- From: frohlinger
- Re: Validing a utf-8 string from search textbox with javascript regular expression
- From: d d
- Re: Validing a utf-8 string from search textbox with javascript regular expression
- From: frohlinger
- Re: Validing a utf-8 string from search textbox with javascript regular expression
- From: Richard Cornford
- Re: Validing a utf-8 string from search textbox with javascript regular expression
- From: getsanjay . sharma
- Validing a utf-8 string from search textbox with javascript regular expression
- Prev by Date: Re: History Replacement And New Location Combined
- Next by Date: Re: A very simple question (for you)
- Previous by thread: Re: Validing a utf-8 string from search textbox with javascript regular expression
- Next by thread: Re: Validing a utf-8 string from search textbox with javascript regular expression
- Index(es):
Relevant Pages
|