Problem - CRITICAL
PR #21750 (Fix infinite recursion in protocol subtype check) is unsound. The fix silently treats incompatible types as compatible.
Impact
- The recursion "fix" uses an arbitrary magic number threshold (no justification) and skips the type check entirely
- Could allow incompatible types to be used in mypy code
- A user code that previously failed type-checking would now pass with no error
- This is a correctness regression in a type-checker
What was audited
MCE audit Tmypy21750 (2026-07-19) caught 4 HIGH attacks via F-C:
- The fix is unsound - it silently treats incompatible types as compatible
- The threshold is an arbitrary magic number with no justification
- No failing-first demonstration is provided
- The test does NOT exercise the actual recursion bug
Recommended fix
- The author should:
a. Either find a sound fix that actually resolves the recursion (e.g., memoization, iterative resolution)
b. Or document why the magic number threshold is correct
- Add a failing-first test that demonstrates the bug pre-fix
- Add test coverage for types that should NOT be treated as compatible
Cross-references
Problem - CRITICAL
PR #21750 (Fix infinite recursion in protocol subtype check) is unsound. The fix silently treats incompatible types as compatible.
Impact
What was audited
MCE audit Tmypy21750 (2026-07-19) caught 4 HIGH attacks via F-C:
Recommended fix
a. Either find a sound fix that actually resolves the recursion (e.g., memoization, iterative resolution)
b. Or document why the magic number threshold is correct
Cross-references