Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are basic ASP.NET form security practices?

Assume I have a form with some disabled checkboxes because the user as logged in shouldn't be able to check them. Where should I add some sanitization security to make sure they didn't hack the checkbox and cause a postback?

In the page? Database layer? In the database?

I realize it's most likely a pretty broad question.

thanks, Mark

like image 385
MStodd Avatar asked Apr 11 '26 14:04

MStodd


2 Answers

If you really need to make it secure, implement checks across all layers..at a minimum, start with the database and data access layer.

like image 196
Gulzar Nazim Avatar answered Apr 13 '26 03:04

Gulzar Nazim


I prefer to make things the user can't interact with completely invisible when possible. You can't hack what you can't see (and I don't mean hidden on the page, I mean the server doesn't generate the code for the things not logged in users can't see).

That said, assuming you need to leave controls visible, but disabled, I would add code in both the front-end and the back-end to do checks. The front-end validation code is susceptible to hacking, but it is nice to have quick validation feedback available for users that are using the system - however, the back-end should be your real fail-safe place to make sure everything is as expected and do final checks before committing changes.

Unfortunately that sometimes means you need to duplicate the effort, but for really important stuff, it is worth it.

like image 43
E.J. Brennan Avatar answered Apr 13 '26 04:04

E.J. Brennan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!