摘要
如果 XOML (Extensible Object Markup Language) 檔案參照特定類型,並且檔案以 Visual Studio 開啟時導致執行任意程式碼,表示 Microsoft Visual Studio 2019 和 Visual Studio 2017 存在遠端執行程式碼弱點。
現在,對於 .xoml 檔案中允許使用哪些類型已有限制。 如果 .xoml 檔案包含最近未經授權的其中一個類型,並且已開啟,則您會收到錯誤訊息,指出類型未經授權。
若要深入了解弱點,請前往 CVE-2019-1113。
因應措施
如果已開啟的 .xoml 檔案未造成安全性問題,您可以停用檢查未經授權類型的程序。 若要執行這項操作,請在 devenv.exe.config 檔案的 <appSettings> 區段新增機碼,如下所示:
...
<appSettings>
<add key="microsoft:WorkflowComponentModel:DisableXOMLSerializerTypeChecking" value="true"/>
</appSettings>
...
這個 appSetting 值會完全停用在 XOML (Extensible Object Markup Language) 序列化程式中的類型檢查。 如果值設定為 true,則優先順序高於僅不允許特定類型的下列新 appSetting 值。
如果您希望僅不允許某些特定類型,則必須對 devenv.exe.config 檔案進行下列變更:
...
<appSettings>
<add key="microsoft:WorkflowComponentModel:DisableXOMLSerializerDefaultUnauthorizedTypes" value="true"/>
</appSettings>
...
這項變更預設會允許所有未經授權的類型。 若要將特定類型標示為未經授權,您也必須對 devenv.exe.config 檔案進行下列變更:
...
<configuration>
...
<configSections>
<sectionGroup name="System.Workflow.ComponentModel.WorkflowCompiler" type="System.Workflow.ComponentModel.Compiler.WorkflowCompilerConfigurationSectionGroup, System.Workflow.ComponentModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="authorizedTypes" type="System.Workflow.ComponentModel.Compiler.AuthorizedTypesSectionHandler, System.Workflow.ComponentModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</sectionGroup>
</configSections>
...
<System.Workflow.ComponentModel.WorkflowCompiler>
<authorizedTypes>
<foo version="v4.0">
<authorizedType Assembly="System.Activities.Presentation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Activities.Presentation" TypeName="WorkflowDesigner" Authorized="false"/>
</foo>
</authorizedTypes>
</System.Workflow.ComponentModel.WorkflowCompiler>
...
</configuration>
...
這些變更只會將 System.Activities.Presentation 組件中的 WorkflowDesigner 類型標示為未經授權,如下所示:
-
Version: 4.0.0.0
-
Culture:neutral
-
PublicKeyToken: 31bf3856ad364e35
若要將其他類型標示為未經授權,您可以針對那些類型新增類似的項目。