1

Hi i was thinking about if there could be any way of disable the ability to change the javascript/jquery from the inspector console?

Just in case you want to avoid that a user interacts and change things from the DOM using the console, or maybe send forms avoiding some checks from javascript.

Or is impossible to do that and you just have to do all the security or this kind of things on the serverside?

Thanks!

0

2 Answers 2

3

Anything on the client side is never going to be fully secure. This is because it can be manipulated not only by the browser's developer tools, but by any number of other 3rd party tools.

The server itself must be fully secured, because there is no way of guaranteeing that a request is even being made from the web site itself, let alone that the javascript validation was not tampered with.

Sign up to request clarification or add additional context in comments.

1 Comment

however still I guess it's cool option. At least will prevent getting user info by leaving changed website on some public PCs eg in libraries or something. Most people would only check url
0

Yes to disable the console just run this on the client

Object.defineProperty(console, '_commandLineAPI', {
    get : function() {
        throw "Console is disabled";
    }
});

This won't leave then to use the console.

Note: There isn't a 100% secure option to get around this, but at least doing this won't allow console usage. Add security to your server to see which request are legit.

Also this will only work in Chrome this is because Chrome wraps all the console code in:

with ((console && console._commandLineAPI) || {}) {
  <code area>
 }

Firefox has a different way to wrap the code from the console. This is why this is not a 100% secure protection from console commands

10 Comments

except that anyone could run some javascript from the URL anyway, which could embed their own custom console, or simply remove what you've added.
The point is that i don't wont to disable javascript, just the abilty to execute javascript from inspector console.
There is no 100% secure options but at least with this they can't just press F12 and send a $.ajax with the info they want. Even Facebook has this on his login page.
Edited this will disable the console. The javascript will work as normal but the console will be disabled it will return the error.
But yes as @Will says the server itself must be fully secured to see which request to respond.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.