Prevent malicious user from executing JavaScript

后端 未结 2 1947
深忆病人
深忆病人 2021-01-23 04:14

In my JSP I have a function like fnGetTicketDetails:

function fnGetTicketDetails(record){
    $(\"#TicketNumber\").val(record);
    $(\"#TicketDeta         


        
相关标签:
2条回答
  • 2021-01-23 04:59

    You can't prevent the user from doing this.

    You must treat all input from the user including all requests sent by your JavaScript as untrusted.

    That means that the server must verify that the request from the user is legitimate (i.e. it must check if the current user has permission to read the specified detail).

    Relying on hidden fields and JavaScript to keep your data secure is a very easy way of getting your data stolen.

    0 讨论(0)
  • 2021-01-23 05:00

    You can't. Any data stored on the client is going to be visible to the end user.

    The issue here is that your server is willing to show the details to anyone who asks for them. Don't even try to stop the user asking. Just do a check server side to make sure that that user is allowed to view those ticket details. If they're not, don't deliver them!

    0 讨论(0)
提交回复
热议问题