SQL Server Windows Authentication Security

2020-07-19 23:47发布

We have an application that uses Windows authentication to authenticate users with the database, and the SQL Server user accounts need to have certain read/write access to database tables.

The trouble is that the users can then install SQL Server Management Studio and potentially use the database in ways it's not supposed to be used, which isn't what I want.

Everything that I have read says that using integrated authentication is more secure but at the moment, any user can use Management Studio or Access/Excel to just connect to the database.

I have read question SQL Server Authentication or Integrated Security?, which suggests some workarounds, but I don't really have the option of changing the app as drastically as re-factoring all of the stored procedures etc. so I was hoping there might be another option?

Thank you,

NIco

标签: sql-server
2条回答
等我变得足够好
2楼-- · 2020-07-20 00:29

Everything that I have read says that using integrated authentication is more secure

--> It's more secure in a way because it's more difficult to get the password.

If you use SQL Server authentication, the connection string contains user and password. If you know where the connection string is (often in a config file), you can open it and see user and password.
On the other hand, if you use Windows authentication, the connection string just says "Integrated Security=True" and you connect to the server with your Windows account, with the actual password buried somewhere deep in Windows' guts and more difficult to retrieve.

Of course, the big downside of Windows authentication is that if your users need write permissions on a certain table for your application, this means that they can write to the same table with ANY other application as well.

There are some workarounds, but none of them is THE silver bullet:

If your app only needs certain tables of the DB, you can just give permissions on these. So at least, the users can't do stuff in all the other tables

If the users are not allowed to access any tables at all from outside your application, there are unfortunately only two things you can do:

  • Change your app to SQL authentication and remove all permissions for Windows users
    (you can also use a proxy service like Will Hughes suggested, but the effect is the same when the app accesses the DB directly...the point is that your users' Windows accounts don't have any permissions anymore!)
  • Create views and stored procedures (if they don't already exist anyway) for the stuff your app can do with the database. Give the users permissions to use these, and remove the permissions to the real tables.
    --> the users can access the views and SPs directly with other tools (even if they don't have any permissions on the underlying tables...permissions on the views and SPs are enough), but they can't do anything that they can't do in your app as well.
查看更多
霸刀☆藐视天下
3楼-- · 2020-07-20 00:30

If you don't want users to have access to your database, don't grant them access.

If you need to control what they can do - then you should do your access control in a webservice (or some other form of proxy service), which will then execute approved queries, return data, etc.

查看更多
登录 后发表回答