确保 RPC 服务的安全
我正在编写一个小型服务,它将在磁盘上存储文件,然后根据请求将它们返回给客户端。
在保护此服务时,我正在检查我的选项,以便未经授权的程序无法读取/写入数据。
最简单的解决方案是使用模拟,以便处理调用的服务线程模拟客户端,并让文件系统确定可以做什么或不能做什么。
这里的问题是服务本身必须能够在没有模拟的情况下读取文件(在后台运行的周期性函数)。
我确实已阅读 MSDN 上的以下章节,我正在寻找您或其他人过去使用过的实用技巧来确保此类服务的安全。
http://msdn.microsoft.com/en-我们/library/aa373582(v=vs.85).aspx
I'm writing a small services which will store files on disk and later, on request, return them to the client.
I'm looking over my options when it comes to securing this service so no unauthorized program can read/write the data.
The simplest solution would use impersonation so that the service thread handling the call impersonate the client and have the file system sort out what can be done or not.
The problem here is that the service itself has to be able to read the files without the impersonation (periodical functions running in the background).
I do have read the following chapter on MSDN, I'm looking for practical tips that you or other have used in the past to secure such service.
http://msdn.microsoft.com/en-us/library/aa373582(v=vs.85).aspx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您通常仅在处理客户端请求时进行模拟。其余时间,服务被配置为使用具有(或配置为具有)完全权限的系统帐户(通常是 THE 系统帐户)来执行其必要的任务。
当然,需要注意的安全问题是确保用户无法将自己提升到该帐户。
当您安装服务时,您需要考虑的事情之一是选择服务帐户。使用内置帐户之一,或为您的服务创建一个特殊用途帐户。有“LocalService”、“NetworkService”、“LocalSystem”iirc 的内置帐户,否则您可以选择现有或新的用户或管理帐户(不推荐)。
当您创建文件时(假设您没有传递任何显式 ACL 信息),它们将继承所属文件夹的可继承访问权限。
您设置这些,以便“用户(包括您模拟的用户的组)”具有创建权限。 “所有者”具有读/写权限。并且“您的默认服务帐户”具有完全控制权。
这意味着您的服务在不冒充任何人的情况下可以完全访问这些文件。冒充某人时,只能读/写该特定用户文件。
登录服务器的任何常规用户也将无法访问这些文件(除非他们碰巧是模拟用户)。不过,管理员可以取得所有权,然后为自己分配读/写访问权限。本地管理员没有(也不应该有)防御措施。
You typically only impersonate while handling a client request. The rest of the time, the service is configured to use a system account (usually THE system account) that has (or is configured to have) full privileges to do its necessary tasks.
The security issue to watch out for is of course, ensuring that a user can't elevate themselves to that account.
When you install a service, one of the things you need to put some thought into is choosing the service account. Either using one of the built in accounts, or creating a special purpose account for your service. There are built in accounts for "LocalService", "NetworkService", "LocalSystem" iirc, otherwise you can pick an existing or new user or administrative account (not recommended).
When you create the files (assuming you don't pass any explicit ACL information) they inherit the inheritable access rights of the owning folder.
These you setup such that "users (a group including your impersonated users)" have create rights. "owners" have read/write. and "your default service account" has full control.
This means that your service, when not impersonating anyone, has full access to the files. When impersonating someone, can only read/write that particular users file.
Any regular users logged onto the Server will also not be able to access the files (unless they happen to be the impersonated users). Administrators can take ownership however, and then assign themselves read/write access. There is no defense (nor should there be) from local administrators.