简体   繁体   English

如何安全地存储Windows应用程序的数据库凭据?

[英]How to securely store database credentials for Windows application?

I have a python application designed to run as a service on Linux, and I've been asked to install it on a Windows XP box in an office where there are no Linux machines (for me, this makes it a bizarre and confusing place as I have virtually no experience developing for Windows). 我有一个设计为在Linux上作为服务运行的python应用程序,被要求将其安装在没有Linux机器的办公室的Windows XP盒中(对我来说,这使它成为一个离奇而混乱的地方我几乎没有为Windows开发的经验。

On Linux the application has its own user, and the application and database credential file reside in an encrypted folder accessible only by that user. 在Linux上,应用程序拥有自己的用户,应用程序和数据库凭据文件位于仅该用户可以访问的加密文件夹中。 (I'd like to state that I am not a cryptologist, and that if there are already glaring security errors in this set up I'm very happy to have them pointed out to me!) (我想声明自己不是密码学家,并且如果此设置中已经存在明显的安全错误,我很高兴将它们指出给我!)

How can I achieve an equivalent level of security by similar or different means on a Windows XP machine? 如何在Windows XP计算机上通过类似或不同的方法达到同等的安全级别? That is to say, how can I prevent those who have access to the computer or the disk altering the program or reading the credentials? 也就是说,如何防止那些有权访问计算机或磁盘的人更改程序或读取凭据?

A little background: the host windows box is a workstation used every day by users with non-administrative privileges. 背景知识:主机窗口框是具有非管理特权的用户每天使用的工作站。 The secure assets are personal data roughly as sensitive as, for example, a school report. 安全资产是大约与学校报告一样敏感的个人数据。 The application is intended to be used by about 10 people who authenticate to the application with individual passwords (stored salted and hashed in the database). 该应用程序打算供大约10个人使用各自的密码(存储在数据库中的盐分和哈希值)向应用程序进行身份验证。

There is a very similar question that received the answer: 有一个非常相似的问题得到了答案:

on Windows you would store the credentials in the registry in a location protected by an ACL 在Windows上,您将凭据存储在注册表中受ACL保护的位置中

However, it doesn't touch on the aspect of protecting the program files, and further it seems to assume a higher level of Windows experience than I currently enjoy :) I have no idea how to protect registry items with an ACL, nor how I would then be able to access the protected keys from my program. 但是,它并没有涉及保护程序文件的方面,而且它似乎假定了比我现在喜欢的更高的Windows体验:)我不知道如何使用ACL保护注册表项,也不知道这样便可以从我的程序访问受保护的密钥。 Simple instructions for a developer in an unfamiliar environment would be greatly appreciated! 对于不熟悉环境中的开发人员的简单说明,将不胜感激!

Your question is unclear about what your application does and what your security requirements are. 您的问题不清楚您的应用程序做什么以及您的安全要求是什么。 I'm going to make some assumptions, and provide an answer based on them. 我将做一些假设,并根据这些假设提供答案。 If these assumptions are incorrect, please clarify in a comment and I'll update. 如果这些假设不正确,请在评论中进行澄清,我将进行更新。

I'm assuming you have an application that: 我假设您有一个应用程序:

  • stores sensitive data in a database stored in a DBMS installed on the workstation 将敏感数据存储在数据库中,该数据库存储在工作站上安装的DBMS中
  • is installed on a shared workstation 安装在共享工作站上
  • each user has their own login (non-admin) 每个用户都有自己的登录名(非管理员)
  • allows different users to log on and interract with their data 允许不同的用户登录并干扰他们的数据
  • user runs applicaiton which connects to a service 用户运行连接到服务的应用程序
  • service connects with database, delivers data to users 服务与数据库连接,将数据传递给用户
  • service runs under its own user account 服务以其自己的用户帐户运行

If this is correct, then you shouldn't have much issue. 如果这是正确的,那么您应该不会有太大问题。

The service can run under any account, but it would be easy enough to have it run under one of the standards (Local Machine or Network Service). 该服务可以在任何帐户下运行,但是很容易让它在一种标准(本地计算机或网络服务)下运行。 Configure the database so that only this account can access it. 配置数据库,以便只有该帐户可以访问它。 In Sql Server, I'd only grant that user account (and admins on the box) login and access rights to the database. 在Sql Server中,我只授予该用户帐户(和包装上的管理员)登录和对数据库的访问权限。

This is the only security you need, if the users aren't admins. 如果用户不是管理员,则这是您唯一需要的安全性。 Now, when the frontend connects to the service, the user can provide the username/password and the service can authenticate against salted and hashed passwords stored in the database. 现在,当前端连接到服务时,用户可以提供用户名/密码,并且服务可以针对存储在数据库中的盐化密码和哈希密码进行身份验证。 All this is secure as long as 1) each user has their own login 2) communications are secure (using named pipes or SSL) and 3) no virii or keyloggers are running under an admin's credentials. 所有这些都是安全的,只要1)每个用户都有自己的登录名2)通信是安全的(使用命名管道或SSL),并且3)没有病毒或键盘记录程序在管理员的凭据下运行。


You can configure your service as to what account it runs under by running services.msc (or right-clicking on MyComputer and selecting Manage or clicking on Services under the Admin tools menu in Control Panel or probably in a number of different ways). 您可以通过运行services.msc(或右键单击MyComputer并选择“管理”,或在“控制面板”中的“管理工具”菜单下单击“服务”)来配置服务的运行方式。

Bring up the list of services, right click on your app and hit Properties. 调出服务列表,右键单击您的应用程序,然后单击“属性”。 From there, make it look like this: 从那里开始,使其看起来像这样: 替代文字

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM