🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Chrome console security

Started by
0 comments, last by hplus0603 7 years, 2 months ago

So I've been playing around with my site trying to send stuff to the server which isn't intended. I noticed that Chrome console really lets you do what you want. I can even redefine whole functions, glean into the inner-eds of my closures and then fire off stuff to the server that wasn't intended. :unsure: However, I did notice that within a closure if a variable is not apart of the return function such as


var myfunction = (function (){
   var a = 'ha!';
   var b = 'boo!';
  
   return function( x ){
      console.log( b + ' ' + x );
   };
};

Then 'a' is not actually retrievable by chrome console in any way shape or form. is this true??

[EDIT]: please disregard this question. I have learned that it is impossible to harden client script and prevent the client from sending malicious stuff to the server. The objective is to harden the server.

Advertisement

First: yes, you cannot "harden" the client, because the user can write whatever code he wants and run it any way he wants.

Second: in JavaScript, a closure closes over (captures) all variables that it uses out of the lexical scope when it is defined. It doesn't have to be part of the return value; it just has to be used in the function for it to be captured (closed into the closure.)

enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement