Skip to content

Harden dbgutil Windows PE export walk against corrupted or incomplete module data#131363

Open
hoyosjs wants to merge 1 commit into
mainfrom
juhoyosa/harden-dbgutil-pe-export-walk
Open

Harden dbgutil Windows PE export walk against corrupted or incomplete module data#131363
hoyosjs wants to merge 1 commit into
mainfrom
juhoyosa/harden-dbgutil-pe-export-walk

Conversation

@hoyosjs

@hoyosjs hoyosjs commented Jul 25, 2026

Copy link
Copy Markdown
Member

The Windows-host PE export-directory walk in dbgutil's TryGetSymbol parses an image's export table using data read from an ICorDebugDataTarget. All of that data must be treated as untrusted: it can come from a corrupt/unmapped data in the target process.

Zero out the initial value defensively, be defensive about modules with no export directory to about interpretting data that's not present, and ensure there's enough ordinal exports to support the request.

The Windows-host PE export-directory walk in dbgutil's `TryGetSymbol` parses an image's export table using data read from an `ICorDebugDataTarget`. All of that data must be treated as untrusted: it can come from a corrupt/unmapped data in the target process.

Zero out the initial value defensively, be defensive about modules with no export directory to about interpretting data that's not present, and ensure there's enough ordinal exports to support the request.
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag
See info in area-owners.md if you want to be subscribed.

@hoyosjs hoyosjs changed the title Harden dbgutil Windows PE export walk against untrusted image data Harden dbgutil Windows PE export walk against corrupted or incomplete module data Jul 25, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens the Windows PE export-directory parsing in dbgutil’s TryGetSymbol when reading PE data from an ICorDebugDataTarget, to better tolerate missing/corrupt/unmapped target memory and avoid unsafe interpretation of untrusted image metadata.

Changes:

  • Initializes the output address defensively and avoids walking exports when the export-directory RVA is zero.
  • Adds validation that a named export’s ordinal is within the export address table bounds before using it.
  • Fixes a spelling error in a comment.

Comment on lines 447 to 451
TryGetSymbol(ICorDebugDataTarget* dataTarget, uint64_t baseAddress, const char* symbolName, uint64_t* symbolAddress)
{
*symbolAddress = 0;

DWORD exportTableRva;
@hoyosjs
hoyosjs enabled auto-merge (squash) July 25, 2026 05:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants