Detect impossible DllCharacteristics flag combinations (HIGH_ENTROPY_VA without DYNAMIC_BASE, etc.)
Summary
Several DllCharacteristics flags have implicit dependencies on each other. Setting a dependent flag without its prerequisite is structurally valid per the PE spec (each bit is independently representable) but represents an impossible configuration — no real compiler emits these combinations because the loader cannot satisfy them.
IOCX currently does not catch these intra-field dependency violations. A binary can claim HIGH_ENTROPY_VA without DYNAMIC_BASE, and IOCX will decode the flags faithfully without surfacing that the configuration cannot function at runtime.
Context — known dependencies
The PE specification does not explicitly enumerate flag dependencies, but they exist implicitly via Windows loader behaviour:
HIGH_ENTROPY_VA (0x0020) requires DYNAMIC_BASE (0x0040). HIGH_ENTROPY_VA means "if you randomise my base address, use the wider 64-bit entropy space." DYNAMIC_BASE means "actually randomise my base address." HIGH_ENTROPY_VA without DYNAMIC_BASE is a no-op claim — the binary is requesting wide-entropy ASLR while opting out of ASLR entirely.
GUARD_CF (0x4000) effectively requires DYNAMIC_BASE (0x0040). Control Flow Guard's security model depends on indirect-call targets being randomised. CFG without ASLR is much weaker than CFG with ASLR; no Microsoft compiler emits the combination. This is a softer dependency than HIGH_ENTROPY_VA — technically the binary will run, but the configuration is meaningfully wrong.
FORCE_INTEGRITY (0x0080) is typically paired with specific signing requirements. A binary claiming FORCE_INTEGRITY without an Authenticode signature is contradictory. This crosses into the signature directory, making it potentially overlap with the cross-validator CFG consistency work — worth deciding whether this belongs here (intra-Optional-Header) or there (cross-validator).
Concrete example
A fixture in the contract test corpus produces:
"dll_characteristics": 32800,
"dll_characteristics_flags": [
"HIGH_ENTROPY_VA",
"TERMINAL_SERVER_AWARE"
]
HIGH_ENTROPY_VA is set without DYNAMIC_BASE. This is structurally valid per the decoder (the bits are correctly identified) but configurationally impossible — the binary is claiming a feature that depends on another feature it explicitly does not enable.
This pattern was first observed in a test fixture during the requirement 1 snapshot refresh review. It's a strong "no real compiler" signal because build tooling enforces these dependencies — you cannot ask MSVC or GCC to emit HIGH_ENTROPY_VA without DYNAMIC_BASE; the build will reject the combination or silently add the missing flag.
Proposed scope
Add a heuristic that checks DllCharacteristics for known dependency violations. Single new reason code with structured details:
PE_DLL_CHARACTERISTICS_INCONSISTENT
details: {
"reasons": [
"high_entropy_va_without_dynamic_base",
"guard_cf_without_dynamic_base",
...
],
"set_flags": ["HIGH_ENTROPY_VA", "TERMINAL_SERVER_AWARE"],
"missing_dependencies": ["DYNAMIC_BASE"]
}
Each detected violation appears as a separate entry in reasons[]. The set_flags and missing_dependencies fields give consumers complete context without requiring them to re-decode the raw value.
Initial rules to implement:
high_entropy_va_without_dynamic_base — HIGH_ENTROPY_VA set, DYNAMIC_BASE not set. Hard violation (cannot function).
guard_cf_without_dynamic_base — GUARD_CF set, DYNAMIC_BASE not set. Soft violation (works but configurationally wrong).
Future rules to consider (out of scope for initial implementation):
force_integrity_without_signature — would require coordination with the signature validator. May belong as a cross-validator check rather than intra-field.
Other combinations as they're identified.
Where this belongs in the architecture
This is an intra-field consistency check, distinct from both structural validation and cross-validator consistency:
Structural validators check that the field is well-formed per spec. DllCharacteristics' bit field is well-formed regardless of which bits are set.
Cross-validator heuristics check consistency between different structures (e.g., DllCharacteristics ↔ Load Config GuardFlags).
Intra-field heuristics (this issue) check consistency between bits within a single field.
The category is new for IOCX. The implementation home is a new heuristic module (iocx/heuristics/dll_characteristics_consistency.py) that reads from public metadata.
Dependencies
None. The check uses only dll_characteristics from public metadata, which is already exposed via requirement 1. This makes the issue straightforward to implement in isolation.
Out of scope
Subsystem-specific flag requirements. Some flags only make sense for certain subsystems (e.g., APPCONTAINER is a UWP concept; WDM_DRIVER is for kernel drivers). Subsystem-aware checks are a separate concern and would benefit from being scoped against the corpus before implementation.
Compiler-specific dependency models. MSVC and MinGW differ in which flag combinations they emit by default. The initial rules are conservative ("no compiler emits this") rather than aspirational ("MSVC would also emit this other flag").
Soft violations beyond GUARD_CF. Many flag combinations are unusual but not impossible. Only the two clearest violations are in scope for the initial implementation.
Cross-validator FORCE_INTEGRITY check. Listed in context for completeness but explicitly deferred — it crosses into the signature validator and is structurally different.
Acceptance criteria
New reason code PE_DLL_CHARACTERISTICS_INCONSISTENT added to the enum.
Heuristic detects high_entropy_va_without_dynamic_base.
Heuristic detects guard_cf_without_dynamic_base.
details["reasons"] lists each detected violation independently.
details["set_flags"] and details["missing_dependencies"] provide complete context for consumers.
Test fixtures: one per violation type, demonstrating each individually.
Negative-control fixture: a binary with HIGH_ENTROPY_VA and DYNAMIC_BASE correctly paired does not fire.
Negative-control fixture: a binary with GUARD_CF and DYNAMIC_BASE correctly paired does not fire.
Documentation updated to describe the heuristic and its sub-reasons, with explicit mention that the category (intra-field consistency) is distinct from structural and cross-validator checks.
Related context
This issue was identified during snapshot review of a binary producing dll_characteristics: 32800 (HIGH_ENTROPY_VA | TERMINAL_SERVER_AWARE). The output decoded correctly but the value itself is configurationally impossible.
Related work items: cross-validator CFG consistency (#TBD), implausibility heuristics for "cannot exist in wild" binaries (#TBD).
Methodology note: this is the third "consistency check" category being added to IOCX (alongside structural and cross-validator). If all three land, the methodology taxonomy should explicitly distinguish them as separate purpose categories.