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

Out of memory exception occurs while inspecting certain binaries during BA2004.EnableSecureSourceCodeHashing rule #924

Open
schlaman-ms opened this issue Jun 14, 2023 · 3 comments

Comments

@schlaman-ms
Copy link
Contributor

schlaman-ms commented Jun 14, 2023

This issue is not BinSkim version specific.

BA2004.EnableSecureSourceCodeHashing inspects the binary and uses low level code that is experiencing an out of memory exception during the P/Invoke call.

  • We are now looking at trying a new version of this low level code to see if it addresses this issue.
  • Here is the code that is failing.

`IDiaDataSource diaSource = MsdiaComWrapper.GetDiaSource();

try
{
diaSource.loadDataFromPdb(pdbPath);
}
catch (OutOfMemoryException ex)
{
// Here is where the problem shows up with the specific binary you have
`

@andriipatsula
Copy link
Member

andriipatsula commented Jul 14, 2023

We are attempting to configure BinSkim to execute on artifacts generated by the official dotnet build, and I am encountering the same problem when running it on the dotnet/runtime repository. (it's a company requirement to scan all binaries we are shipping) issue: dotnet/arcade-services#2744
Do we have any workarounds for this issue, or is anyone working on solving it?

@tkapin
Copy link
Member

tkapin commented Jul 19, 2023

@schlaman-ms - enabling BinSkim is a priority for the .NET team. Could you please advise on who would be the best person to help us troubleshoot this issue? Thanks

@shaopeng-gh
Copy link
Collaborator

Hello, I have checked a few cases of the out of memory pdb files user reported,
what I saw is BinSkim is behaving the same as the Microsoft DIA lib we used. BinSkim depends on DIA to load pdb files, and the error "out of memory" is coming from the DIA lib.
Below is one of the analyze before:

use the latest installed VS 2022 DIA SDK Dia2Dump which is provided by Microsoft
dumping the pdb file from user, has the 8007000E which is basically same error as what we see in our BinSkim tool:
image

definition of 8007000E
image

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

4 participants