Details
Reachability depends on the application evaluating operand | view.items() (reflected union) or view.items() - operand (subtraction) over a sequence of 2-tuples whose count is remote-influenced. The forward union view.items() | operand routes to or1_impl, which clears correctly and does not leak; a non-tuple operand element takes the parse_item early-return and does not leak. Set algebra over items views is not the most common multidict usage, which bounds exposure and is why this is Medium, not High. This is distinct from PR #1413, which fixed a temporary-tuple leak in the second loop and did not release these per-element objects.
---
Remediation
Recommended fix. Clear the two per-element references at the end of the first parse loop in both functions, exactly as every sibling path does. In or2_impl (views.h:575) and sub1_impl (views.h:696), replace the lone Py_CLEAR(arg); with:
Py_CLEAR(arg);
Py_CLEAR(identity);
Py_CLEAR(value);
This is an in-repo change to a static internal function; it alters no public API, type, or signature, and asks callers to change nothing. A leak test in the existing tests/test_leaks.py style would lock it in.
Workaround. Avoid operand | view.items() and view.items() - operand on attacker-influenced operands, or install with MULTIDICT_NO_EXTENSIONS=1 to use the unaffected pure-Python build.
---