Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent JavaScript Injection Attacks

Tags:

javascript

Currently I have developed a site which is used for handle financial transactions. I have seen that some of my customers have done JavaScript injection attacks and have done some transactions which are not possible. As a example I have checked his cash balance before he place the order. But some of them did change that by running the following javascript in the address bar. They have taken the varible name by looking in to page source.

javascript:void(document.accounts.cashBalence.value="10000000")

Since this is critical I want to fixed it quickly. So is there a way to prevent JavaScript injection attacks?

like image 813
nath Avatar asked Oct 15 '10 05:10

nath


1 Answers

You can obfuscate or hash variable names and/or values. However,
Don't use JavaScript, do every logic in the server-side instead.

like image 172
Ming-Tang Avatar answered Oct 19 '22 22:10

Ming-Tang