為什麼強命名程序集不能使用未簽名的程序集? (Why can't strongly named assemblies use assemblies that aren't signed?)


問題描述

為什麼強命名程序集不能使用未簽名的程序集? (Why can't strongly named assemblies use assemblies that aren't signed?)

To sign an assembly A you have to make sure all assemblies B, C, D that are used by A are signed, and then all assemblies that are used by B, C, D, and so on. I don't understand what's the security benefit of this. I think it's supposed to prevent tampering, but assembly A is allowed to open any file, and these can be tampered. The same goes for an external webserver.

Also, it's too easy to sign an assembly with a .snk file that you make public, sidestepping the requirement.

‑‑‑‑‑

參考解法

方法 1:

The point is that otherwise you could replace assembly B/C/D with a different (hacked) one, and A would never notice; it would load them and execute the code. With strong naming, you can't do this without either re‑signing the hacked B/C/D with the same key, or by hacking A.

方法 2:

Another reason for strong naming is versioning. If you reference a strong named assembly, you get that specific version ‑ and it will load its dependencies at the specific versions it relies upon.

EDIT

Example scenario: If you put an assembly in the GAC, it has to be strong named to allow side‑by‑side versioning. You couldn't put it in the GAC, though, unless its dependencies were also there (otherwise, they'd fail to load at run time). In order for those assemblies to be loaded reliably, they need to be strong named too, and in the GAC.

方法 3:

It's because the a strongly named assembly implies that it can be trusted, and levels of granted security are based on the idea that the code is from a legitimate source.  This means that all other items that it interacts with must also be trusted, because it executes under the same security context.  

If strongly named objects didn't work this way, a method of attack would be to replace the items which aren't signed with rogue code the attacker wants to execute.  The rogue code would execute under the trusted security context of the signed item.  

(by Bruno MartinezMarc Gravelluser96705kemiller2002)

參考文件

  1. Why can't strongly named assemblies use assemblies that aren't signed? (CC BY‑SA 3.0/4.0)

#assemblies #code-signing #.net






相關問題

Nhận các phương thức giao diện từ một lớp được tải động trong .NET (Getting interface methods from a dynamically loaded class in .NET)

支持超過 2 個版本的項目 (Supporting more then 2 versions of a project)

無法加載混淆程序集 (Cannot load obfuscated assembly)

如何禁止引用 .NET DLL 類庫 (How to forbid a .NET DLL class library to be referenced)

我可以從命令行運行 .NET 程序集的代碼嗎? (Can I run code from a .NET assembly from a command line?)

如何將一個應用程序組裝到另一個應用程序中? (How to use assembly of one application in to another application?)

從程序集中復制 DLL 以進行部署 (Copy DLL From Assembly For Deployment)

是否可以查看程序集的源代碼?如果是,那麼如何? (Is it possible to view source code of assembly? If yes then How?)

組裝成字節 (Assembly to Bytes)

DLL 與程序集 (DLL versus Assembly)

pdb 是否提供有關源文件中類型定義的信息? (Does pdb provide information about type definitions in source files?)

如何在 .NET 程序集中重命名 [空格] 類型 (How can I rename[space] a type in a .NET assembly)







留言討論