スレーブ サンドボックス ドメインの ApplicationBase をホスティング ドメインと同じパスに設定することの正確なセキュリティ上の影響は何ですか?
ApplicationBase はスレーブ ドメインでは異なる必要があると述べている MSDN のガイドラインを見つけました。 (p. 3):
http://msdn.microsoft.com/en-us/library/bb763046.aspx
このエクスプロイトはどのように機能しますか?
私のシナリオでは、ApplicationBase の下にあるすべてのアセンブリを完全に信頼して実行します。そのドメイン内で動的に生成されたアセンブリの権利を制限するために、スレーブ AppDomain を排他的にサンドボックス化しています。ガイドラインに従ってみましたが、ApplicationBase プロパティを変更すると、アセンブリが LoadFrom コンテキストに読み込まれるため、ドメイン間の双方向通信ブリッジが壊れるように見えるので、避けたいと思います。
個別の ApplicationBase 値に関する問題を示すサンプル F# コード:
module Main =
open System
open System.Diagnostics
open System.IO
open System.Reflection
open System.Security
open System.Security.Permissions
open System.Security.Policy
/// Change this switch to observe the problem.
let useSameApplicationBase = true
let getStrongName (a: Assembly) =
match a.Evidence.GetHostEvidence<StrongName>() with
| null -> None
| sn -> Some sn
let getAssemblies () =
[|
Assembly.GetExecutingAssembly()
|]
let buildAppDomain () =
let fullTrust =
getAssemblies ()
|> Array.choose getStrongName
let evidence = null
let appBase =
if useSameApplicationBase then
AppDomain.CurrentDomain.BaseDirectory
else
Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Untrusted")
let setup = AppDomainSetup(ApplicationBase = appBase)
let perms = PermissionSet(PermissionState.None)
AppDomain.CreateDomain("SLAVE", null, setup, perms, fullTrust)
[<Sealed>]
type Backer() =
inherit MarshalByRefObject()
member this.Pong() =
Console.WriteLine("PONG IN DOMAIN = {0}", AppDomain.CurrentDomain.FriendlyName)
[<Sealed>]
type Sandbox() =
inherit MarshalByRefObject()
member this.Start(backer: obj) =
Console.WriteLine("RUN IN SLAVE DOMAIN = {0}", AppDomain.CurrentDomain.FriendlyName)
(backer :?> Backer).Pong()
let test () =
let dom = buildAppDomain ()
try
let handle =
Activator.CreateInstanceFrom(dom,
typeof<Sandbox>.Assembly.Location,
typeof<Sandbox>.FullName)
let sandbox = handle.Unwrap() :?> Sandbox
sandbox.Start(Backer())
finally
AppDomain.Unload(dom)
test ()