Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IsAuthenticodeSigned is true, but IsTrustedAuthenticodeSignature is false #288

Open
BerndK opened this issue Aug 11, 2023 · 1 comment
Open

Comments

@BerndK
Copy link

BerndK commented Aug 11, 2023

I had problems when testing Authenticode,
the issue is that IsTrustedAuthenticodeSignature is most times false (on my files).
I was able to reproduce this with your test files: (the firefox tests fails 2 out of 5):
see PeFileTest.cs - add last line to test also IsTrustedAuthenticodeSignature (when using explorer the signatures are reported as valid)

        [SkippableTheory]
        [InlineData(@"../../../Binaries/firefox_x86.exe", true)]
        [InlineData(@"../../../Binaries/firefox_x64.exe", true)]
        [InlineData(@"C:\Windows\System32\kernel32.dll", true)]
        [InlineData(@"C:\Windows\explorer.exe", true)]
        [InlineData(@"../../../Binaries/TLSCallback_x86.exe", false)]
        public void IsSigned_PathToSignedBinary_ReturnsSignedOrNot(string file, bool expected)
        {
            Skip.IfNot(RuntimeInformation.IsOSPlatform(OSPlatform.Windows));

            var peFile = new PeFile(file);
            Assert.Equal(expected, peFile.IsAuthenticodeSigned);
            Assert.Equal(expected, peFile.IsTrustedAuthenticodeSignature);
        }

obviously signedCms.CheckSignature(true); fails
Forgot to mention that I'm working on Windows, using .net 7

@BerndK
Copy link
Author

BerndK commented Aug 12, 2023

Update:
This works on Framework 4.8, but not on .net 7.0!
So it might still be the issue discussed here dotnet/runtime#28252 !?
If this is the case, I think it is hard to fix.

However IsTrustedAuthenticodeSignature fails on both systems!
perhaps here dotnet/runtime#83478 or https://www.sysadmins.lv/blog-en/retrieve-timestamp-attribute-from-digital-signature.aspx are some additional infos, not sure.

Some suggestions:

  • include the check in the unit tests and make them explicit, to at least document this 'non perfect' behavior
  • consider to cache the AuthenticodeInfo property, it is used by some other properties and is parsed every time, assuming that the underlying crypto funcs like hashing and SignedCms are expensive, this would help to increase performance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant