Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are .NET assemblies without strong names protected against accidental corruption?

Suppose I build a .NET assembly and don't have it signed with a strong name, then it is copied to some storage, then to another and then it ends up in production. If a bit or two of the assembly contents get accidentally changed (some hardware problem or something like that) is there a chance that .NET runtime doesn't notice it and still considers the assembly image valid?

like image 346
sharptooth Avatar asked Jul 03 '15 08:07

sharptooth


1 Answers

Write this program:

using System;

namespace ConsoleApplication13
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello world!");
        }
    }
}

compile it, run it...

Now open it in Notepad++, go to Find, select Extended research type, search for H\0... Find the H NUL e NUL l... and replace the H with a X... Save and relaunch...

Xello world!

Note that strong named assemblies aren't verified normally... Try to add a strong name... compile... run

sn -v yourprogram.exe

and check that it is correct...

now modify it... rerun the

sn -v yourprogram.exe

and see that the validation fails...

now try to run it... It runs correctly!

From MSDN

Starting with the .NET Framework version 3.5 Service Pack 1 (SP1), strong-name signatures are not validated when an assembly is loaded into a full-trust AppDomain object, such as the default AppDomain for the MyComputer zone.

like image 74
xanatos Avatar answered Oct 04 '22 00:10

xanatos