Skip to content

Reject invalid enum underlying metadata - #4331

Open
siegfriedpammer wants to merge 1 commit into
masterfrom
fix/validate-enum-underlying-type
Open

siegfriedpammer wants to merge 1 commit into
masterfrom
fix/validate-enum-underlying-type

Conversation

@siegfriedpammer

Copy link
Copy Markdown
Member

Malformed enum metadata can declare an array as the value__ field type. The C# conversion pipeline then repeatedly converts a pointer to the enum through an unknown underlying type until the process stack overflows.

Only classify enum value__ fields with supported primitive scalar underlying types as enums. Preserve the existing handling of Boolean, Char, native integers, and the standard signed/unsigned integral types.

Addresses scan finding ANT-2026-VS1139M4.

Tests:

  • OPENSSL_ENABLE_SHA1_SIGNATURES=1 dotnet test --project ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj --no-restore --report-trx --filter "FullyQualifiedName~ILPrettyTestRunner.WeirdEnums|FullyQualifiedName~TypeSystemLoaderTests" (139 passed)

Enum conversion assumes the value__ field has a scalar primitive underlying type. Treat malformed signatures such as arrays as non-enums, preventing ConvertTo from recursively retrying an unchanged pointer-to-enum conversion while preserving supported native integer enums.

Assisted-by: OpenCode:gpt-5.6-luna:OpenCode
@siegfriedpammer
siegfriedpammer force-pushed the fix/validate-enum-underlying-type branch from 05e66a5 to 26c6995 Compare November 8, 2026 11:26

This branch has not been deployed

No deployments
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.

1 participant