Pergunta

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!

Foi útil?

Solução 2

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

Outras dicas

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top