Securing ASP.NET MVC Application Checklist

后端 未结 4 1333
轻奢々
轻奢々 2021-02-02 03:14

I am looking for a set of guidelines or a checklist that you can go over for securing a public ASP.NET MVC Website. I just want to make sure that I am not making any of the obvi

4条回答
  •  深忆病人
    2021-02-02 03:51

    1. As always, make sure you proper encode output - notice that I am here saying encode and not HtmlEncode. If you're outputting content out to HTML then you want to use Html.Encode - however if you're outputting to JavaScript then you want to use a JavaScript encode function. - This will help you against Cross Site Scripting (XSS)
    2. Use the helpers that help against CSRF attacks where needed (or maybe just everywhere)
    3. Depending how you access your data storage, if it's a SQL Database, remember to protect yourself against SQL injections, either through parameterized queries, stored procedures, LINQ or what have you.
    4. When you test - make sure your test data contains dodgy output (stuff where a fail to call Html.Encode would reveal itself easily, perhaps through XSS here!, same goes for stuff that's injected into JavaScript, make mistakes show up!)
    5. When model binding use a whitelisting approach for properties so users cannot make the binder bind properties that are not intended to be bound!

提交回复
热议问题