Skip to content

Suppress ERR997 for IL-only managed assemblies#1174

Open
danmoseley wants to merge 7 commits into
microsoft:mainfrom
danmoseley:binskim-suppress-err997-ilonly
Open

Suppress ERR997 for IL-only managed assemblies#1174
danmoseley wants to merge 7 commits into
microsoft:mainfrom
danmoseley:binskim-suppress-err997-ilonly

Conversation

@danmoseley
Copy link
Copy Markdown
Member

@danmoseley danmoseley commented Apr 16, 2026

Fixes #1173

Note

This is an AI-assisted draft.

Important

Breaking change: EnforcePdbLoadForManagedAssemblies is replaced by RequiresPdbForManagedAssemblies with inverted default (false instead of true). Any rule or external subclass that relied on the old property name or its true default will need to be updated.

Problem

ERR997.ExceptionLoadingPdb fires for IL-only managed assemblies even though
no current BinSkim rule requires PDB data for IL-only binaries. This creates
significant noise — for example, scanning dotnet/dotnet macOS artifacts produces
thousands of ERR997 entries on IL-only assemblies (including satellite resource
assemblies), none actionable.

Note — this makes the raw logs cleaner. ERR997 is not going to Guardian or S360
so it's just a tidiness thing.

Root cause

In WindowsBinaryAndPdbSkimmerBase.Analyze(), the old
EnforcePdbLoadForManagedAssemblies defaulted to true and no rule overrode
it, so the ERR997 condition always evaluated to true for IL-only assemblies
with no PDB.

Fix

Replace EnforcePdbLoadForManagedAssemblies (default true) with
RequiresPdbForManagedAssemblies (default false). This is a public API
breaking change
— the old property is removed, not obsoleted.

IL-only managed assemblies with no PDB now proceed to
AnalyzePortableExecutableAndPdb() instead of emitting ERR997 and returning
early. Resource-only assemblies (IsManagedResourceOnly) are also excluded
from the PDB requirement.

Rules that genuinely need PDB data for IL-only managed assemblies can override
RequiresPdbForManagedAssemblies to return true.

Why this is safe

Verified all 17 WindowsBinaryAndPdbSkimmerBase subclasses:

  • 14 rules reject IL-only in CanAnalyzePE (directly or via
    StackProtectionUtilities) — they never reach Analyze() for IL-only
    assemblies.
  • 3 rules (BA2004, BA2027, BA4001) do accept IL-only assemblies. All three
    already null-check Pdb at the top of AnalyzePortableExecutableAndPdb()
    and return early when it is null.

Native and mixed-mode binaries still trigger ERR997 as before.

Remove EnforcePdbLoadForManagedAssemblies from the ERR997 gate condition
so that IL-only managed assemblies (including satellite resource assemblies)
no longer trigger ERR997.ExceptionLoadingPdb. These assemblies typically
have no PDB, and no current rule requires PDB data for IL-only binaries.

Native and mixed-mode binaries still trigger ERR997 as before.

The two PDB-using rules applicable to IL-only assemblies (BA2004, BA2027)
already handle null PDB gracefully via LogPdbLoadException => false.

Mark EnforcePdbLoadForManagedAssemblies as [Obsolete] since it is public
virtual but no longer referenced in the gate logic.

Fixes microsoft#1173

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@danmoseley danmoseley requested a review from a team as a code owner April 16, 2026 19:08
@danmoseley
Copy link
Copy Markdown
Member Author

@martin-reznik

@danmoseley
Copy link
Copy Markdown
Member Author

For our dotnet/dotnet repo, while this doesn't produce noise in Guardian/S360, it is super noisy in local logs, and makes SARIF much bigger — 63,702 notification entries bloat the SARIF to 80MB. With this fix it is 50MB

danmoseley and others added 2 commits April 17, 2026 21:11
…Assemblies

- New property defaults to false (opt-in instead of opt-out)
- Add IsManagedResourceOnly unconditional skip for satellite DLLs
- Future rules can override RequiresPdbForManagedAssemblies => true to
  get the ERR997 safety net for IL-only managed assemblies

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@danmoseley
Copy link
Copy Markdown
Member Author

Changed to the alternative approach suggested by @martin-reznik -- note, this version is a public API breaking change, which I had avoided in the first change. I do not know whether that is a problem. Description updated above.

danmoseley and others added 3 commits April 20, 2026 09:20
…o false

Restore the original property name to avoid a breaking public API change.
The default is changed from true to false so IL-only managed assemblies
no longer trigger ERR997.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@Sasinkas Sasinkas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to test this one on our Internal repository, we have some additional rules that are using this.

  • buildAndTest is working

@danmoseley
Copy link
Copy Markdown
Member Author

@Sasinkas

@Sasinkas Sasinkas self-requested a review May 18, 2026 08:59
Copy link
Copy Markdown
Contributor

@Sasinkas Sasinkas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@danmoseley
Copy link
Copy Markdown
Member Author

@Sasinkas how can I get this merged? I've pinged Martin offline but he's quite busy. Can we merge?

@danmoseley
Copy link
Copy Markdown
Member Author

Oh - I see you just signed of today! thanks. Should I click merge?

Copy link
Copy Markdown
Contributor

@Sasinkas Sasinkas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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

Successfully merging this pull request may close these issues.

ERR997 should not fire on managed resource assemblies (lots of noise)

2 participants