10

我已经设置了一个使用 Mutex 的单实例 WPF 应用程序,如果您使用用户切换,这允许应用程序在每个用户帐户中运行。该应用程序设置了一个 WCF 命名管道,以便我可以从另一个进程与单个实例进行通信(即,当第二个进程在由于互斥体而终止之前运行时)。

我想知道是否应该采取任何措施(最佳实践)来保护命名管道?

另外我想知道命名管道消息是否会到达系统内的所有正在运行的进程或仅在当前用户会话中。如果命名管道在系统范围内发送,那么将通信限制为当前用户会话的最佳实现是什么?

4

3 回答 3

7

Named pipes in WCF are not accessible from the network and no encryption is required to secure them. However, WCF services are not secure against the attack mentioned by romkyns.

I suggest you read this posts:

Exploring the WCF Named Pipe Binding - Part 1

Exploring the WCF Named Pipe Binding - Part 2

Exploring the WCF Named Pipe Binding - Part 3

Exploring the WCF Named Pipe Binding - Part 4

about the security problems involved.

In short WCF allows ANY process to masquerade itself as the service and:

  1. Either simulate the service OR
  2. Eavesdrop and tamper data assuming that the rogue process itself connect to the service. However, if the service uses access security to check the identity of the calling user this may not be possible.
于 2010-08-26T11:53:24.593 回答
2

命名管道意味着通信在同一台机器上是点对点的。我相信默认情况下它是安全的,但由于通信永远不会离开机器,即使在同一个网络上,安全性并不是最需要担心的事情——至少在命名管道组件与其之间的通信方面消费者。

查看 Juval Lowy 的“Programming WCF Services 2nd Edition”。第 10 章是关于组件安全的。在第 514 页,他写道“在 IPC 上使用消息安全性没有任何意义,因为使用 IPC,从客户端到服务始终只有一跳。该页面上的图表显示默认情况下,传输安全性已为命名管道。

于 2009-06-23T15:43:40.793 回答
1

这篇关于命名管道安全的论文非常详细地讨论了这个话题。

简而言之,如果您不小心,您可能会允许以标准用户权限运行的恶意程序利用管道将自身提升到与命名管道服务器相同的特权级别。

恐怕我不知道默认情况下 WCF 实现是否可以安全地抵御此类攻击。

于 2010-04-27T15:19:30.370 回答