Measures to prevent XSS vulnerability (like Twitter's one a few days before)

后端 未结 3 1187
离开以前
离开以前 2021-02-09 14:37

Even famous sites like Twitter are suffering from XSS vulnerability, what should we do to prevent this kind of attack?

3条回答
  •  日久生厌
    2021-02-09 15:36

    Just like you can make SQL injection a non-issue by using prepared statements, you can make XSS non-issue by using templating engine (DOM serializer) that does similar thing.

    Design your application so that all output goes via templating engine. Make that templating engine HTML-escapes all data by default. This way you'll have system that's secure by default and does not rely on humans (and rest of the large system) being diligent in escaping of HTML.

提交回复
热议问题