{"abstract":"An attachment nested in a mixed part inside a signed message is stripped, silently breaking the signature.","category":"Email MIME structure","checks":7,"contract":"Leaves {type, filename, disp, size}. A leaf is blocked when its last filename extension (trimmed, lower-cased) is in blocked_ext, its type is application/x-msdownload, or its size exceeds max_size. A non-attachment leaf without a filename (a body) is never blocked. Blocked leaves become \"strip\", others \"keep\"; a blocked leaf anywhere under multipart/signed cannot be stripped, and then the whole message is \"reject\". Result: the per-leaf action list or \"reject\".","evaluation_group":"w2-email_mime_structure-attachment-stripping","failed_approach":"Resetting the signed state at a nested multipart/mixed repeats the same mistake. The attempted `t == 'multipart/signed' or (signed and t != 'multipart/mixed')` still disagrees with a fixture.","family":"w2-email_mime_structure-attachment-stripping-signed-inheritance","id":"FA-76806","implementations":{"attempt":{"sha256":"366b6528fd3a60c18cf6e3511fa5a6e83dd383e5410756f1e43dfe2f6f34b49f","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(tree, blocked_ext, max_size):\n    actions = []\n    def walk(n, signed):\n        t = n['type'].lower()\n        if t.startswith('multipart/'):\n            for c in n['parts']:\n                walk(c, t == 'multipart/signed' or (signed and t != 'multipart/mixed'))\n            return\n        name = (n.get('filename') or '').strip().lower()\n        ext = name.rsplit('.', 1)[-1] if '.' in name else ''\n        bad = ext in blocked_ext or t == 'application/x-msdownload' or n.get('size', 0) > max_size\n        if (n.get('disp') or '').lower() != 'attachment' and not name:\n            bad = False\n        if bad and signed:\n            actions.append('reject')\n        else:\n            actions.append('strip' if bad else 'keep')\n    walk(tree, False)\n    return 'reject' if 'reject' in actions else actions\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\n_CASES = {1: [('double extension', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'size': 10}, {'type': 'application/pdf', 'filename': 'invoice1.pdf.exe', 'disp': 'attachment', 'size': 10}]}, ['exe'], 1000), ['keep', 'strip']), ('upper-case padded extension', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/octet-stream', 'filename': 'SETUP1.EXE ', 'disp': 'attachment', 'size': 5}]}, ['exe'], 1000), ['keep', 'strip']), ('blocked part inside signed mixed', ({'type': 'multipart/signed', 'parts': [{'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/zip', 'filename': 'x.js', 'disp': 'attachment', 'size': 1}]}, {'type': 'application/pgp-signature'}]}, ['js'], 1000), 'reject'), ('large body and named inline part', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'size': 5001}, {'type': 'application/octet-stream', 'filename': 'tool.exe', 'disp': 'inline', 'size': 3}, {'type': 'application/zip', 'disp': 'attachment', 'size': 5000}]}, ['exe'], 1000), ['keep', 'strip', 'strip']), ('size boundaries', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'image/png', 'filename': 'a.png', 'disp': 'attachment', 'size': 1000}, {'type': 'image/png', 'filename': 'b.png', 'disp': 'attachment', 'size': 1001}]}, [], 1000), ['keep', 'keep', 'strip']), ('executable type in signed', ({'type': 'multipart/signed', 'parts': [{'type': 'text/plain'}, {'type': 'application/x-msdownload', 'filename': 'a.bin', 'disp': 'attachment', 'size': 1}]}, [], 50), 'reject'), ('clean message', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/pdf', 'filename': 'r1.pdf', 'disp': 'attachment', 'size': 10}]}, ['exe'], 100), ['keep', 'keep'])], 2: [('double extension', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'size': 10}, {'type': 'application/pdf', 'filename': 'invoice2.pdf.exe', 'disp': 'attachment', 'size': 10}]}, ['exe'], 1000), ['keep', 'strip']), ('upper-case padded extension', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/octet-stream', 'filename': 'SETUP2.EXE ', 'disp': 'attachment', 'size': 5}]}, ['exe'], 1000), ['keep', 'strip']), ('blocked part inside signed mixed', ({'type': 'multipart/signed', 'parts': [{'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/zip', 'filename': 'x.js', 'disp': 'attachment', 'size': 2}]}, {'type': 'application/pgp-signature'}]}, ['js'], 1000), 'reject'), ('large body and named inline part', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'size': 5002}, {'type': 'application/octet-stream', 'filename': 'tool.exe', 'disp': 'inline', 'size': 3}, {'type': 'application/zip', 'disp': 'attachment', 'size': 5000}]}, ['exe'], 1000), ['keep', 'strip', 'strip']), ('size boundaries', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'image/png', 'filename': 'a.png', 'disp': 'attachment', 'size': 2000}, {'type': 'image/png', 'filename': 'b.png', 'disp': 'attachment', 'size': 2001}]}, [], 2000), ['keep', 'keep', 'strip']), ('executable type in signed', ({'type': 'multipart/signed', 'parts': [{'type': 'text/plain'}, {'type': 'application/x-msdownload', 'filename': 'a.bin', 'disp': 'attachment', 'size': 1}]}, [], 50), 'reject'), ('clean message', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/pdf', 'filename': 'r2.pdf', 'disp': 'attachment', 'size': 10}]}, ['exe'], 100), ['keep', 'keep'])], 3: [('double extension', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'size': 10}, {'type': 'application/pdf', 'filename': 'invoice3.pdf.exe', 'disp': 'attachment', 'size': 10}]}, ['exe'], 1000), ['keep', 'strip']), ('upper-case padded extension', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/octet-stream', 'filename': 'SETUP3.EXE ', 'disp': 'attachment', 'size': 5}]}, ['exe'], 1000), ['keep', 'strip']), ('blocked part inside signed mixed', ({'type': 'multipart/signed', 'parts': [{'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/zip', 'filename': 'x.js', 'disp': 'attachment', 'size': 3}]}, {'type': 'application/pgp-signature'}]}, ['js'], 1000), 'reject'), ('large body and named inline part', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'size': 5003}, {'type': 'application/octet-stream', 'filename': 'tool.exe', 'disp': 'inline', 'size': 3}, {'type': 'application/zip', 'disp': 'attachment', 'size': 5000}]}, ['exe'], 1000), ['keep', 'strip', 'strip']), ('size boundaries', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'image/png', 'filename': 'a.png', 'disp': 'attachment', 'size': 3000}, {'type': 'image/png', 'filename': 'b.png', 'disp': 'attachment', 'size': 3001}]}, [], 3000), ['keep', 'keep', 'strip']), ('executable type in signed', ({'type': 'multipart/signed', 'parts': [{'type': 'text/plain'}, {'type': 'application/x-msdownload', 'filename': 'a.bin', 'disp': 'attachment', 'size': 1}]}, [], 50), 'reject'), ('clean message', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/pdf', 'filename': 'r3.pdf', 'disp': 'attachment', 'size': 10}]}, ['exe'], 100), ['keep', 'keep'])], 4: [('double extension', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'size': 10}, {'type': 'application/pdf', 'filename': 'invoice4.pdf.exe', 'disp': 'attachment', 'size': 10}]}, ['exe'], 1000), ['keep', 'strip']), ('upper-case padded extension', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/octet-stream', 'filename': 'SETUP4.EXE ', 'disp': 'attachment', 'size': 5}]}, ['exe'], 1000), ['keep', 'strip']), ('blocked part inside signed mixed', ({'type': 'multipart/signed', 'parts': [{'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/zip', 'filename': 'x.js', 'disp': 'attachment', 'size': 4}]}, {'type': 'application/pgp-signature'}]}, ['js'], 1000), 'reject'), ('large body and named inline part', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'size': 5004}, {'type': 'application/octet-stream', 'filename': 'tool.exe', 'disp': 'inline', 'size': 3}, {'type': 'application/zip', 'disp': 'attachment', 'size': 5000}]}, ['exe'], 1000), ['keep', 'strip', 'strip']), ('size boundaries', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'image/png', 'filename': 'a.png', 'disp': 'attachment', 'size': 4000}, {'type': 'image/png', 'filename': 'b.png', 'disp': 'attachment', 'size': 4001}]}, [], 4000), ['keep', 'keep', 'strip']), ('executable type in signed', ({'type': 'multipart/signed', 'parts': [{'type': 'text/plain'}, {'type': 'application/x-msdownload', 'filename': 'a.bin', 'disp': 'attachment', 'size': 1}]}, [], 50), 'reject'), ('clean message', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/pdf', 'filename': 'r4.pdf', 'disp': 'attachment', 'size': 10}]}, ['exe'], 100), ['keep', 'keep'])], 5: [('double extension', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'size': 10}, {'type': 'application/pdf', 'filename': 'invoice5.pdf.exe', 'disp': 'attachment', 'size': 10}]}, ['exe'], 1000), ['keep', 'strip']), ('upper-case padded extension', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/octet-stream', 'filename': 'SETUP5.EXE ', 'disp': 'attachment', 'size': 5}]}, ['exe'], 1000), ['keep', 'strip']), ('blocked part inside signed mixed', ({'type': 'multipart/signed', 'parts': [{'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/zip', 'filename': 'x.js', 'disp': 'attachment', 'size': 5}]}, {'type': 'application/pgp-signature'}]}, ['js'], 1000), 'reject'), ('large body and named inline part', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'size': 5005}, {'type': 'application/octet-stream', 'filename': 'tool.exe', 'disp': 'inline', 'size': 3}, {'type': 'application/zip', 'disp': 'attachment', 'size': 5000}]}, ['exe'], 1000), ['keep', 'strip', 'strip']), ('size boundaries', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'image/png', 'filename': 'a.png', 'disp': 'attachment', 'size': 5000}, {'type': 'image/png', 'filename': 'b.png', 'disp': 'attachment', 'size': 5001}]}, [], 5000), ['keep', 'keep', 'strip']), ('executable type in signed', ({'type': 'multipart/signed', 'parts': [{'type': 'text/plain'}, {'type': 'application/x-msdownload', 'filename': 'a.bin', 'disp': 'attachment', 'size': 1}]}, [], 50), 'reject'), ('clean message', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/pdf', 'filename': 'r5.pdf', 'disp': 'attachment', 'size': 10}]}, ['exe'], 100), ['keep', 'keep'])]}\nfor _label, _args, _expected in _CASES[N]:\n    check(_label, solve(*_args), _expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"broken":{"sha256":"2eb48249e408cd04ad3402d1c2edd982605c82599f0996a86f611c69eb06a734","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(tree, blocked_ext, max_size):\n    actions = []\n    def walk(n, signed):\n        t = n['type'].lower()\n        if t.startswith('multipart/'):\n            for c in n['parts']:\n                walk(c, t == 'multipart/signed')\n            return\n        name = (n.get('filename') or '').strip().lower()\n        ext = name.rsplit('.', 1)[-1] if '.' in name else ''\n        bad = ext in blocked_ext or t == 'application/x-msdownload' or n.get('size', 0) > max_size\n        if (n.get('disp') or '').lower() != 'attachment' and not name:\n            bad = False\n        if bad and signed:\n            actions.append('reject')\n        else:\n            actions.append('strip' if bad else 'keep')\n    walk(tree, False)\n    return 'reject' if 'reject' in actions else actions\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\n_CASES = {1: [('double extension', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'size': 10}, {'type': 'application/pdf', 'filename': 'invoice1.pdf.exe', 'disp': 'attachment', 'size': 10}]}, ['exe'], 1000), ['keep', 'strip']), ('upper-case padded extension', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/octet-stream', 'filename': 'SETUP1.EXE ', 'disp': 'attachment', 'size': 5}]}, ['exe'], 1000), ['keep', 'strip']), ('blocked part inside signed mixed', ({'type': 'multipart/signed', 'parts': [{'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/zip', 'filename': 'x.js', 'disp': 'attachment', 'size': 1}]}, {'type': 'application/pgp-signature'}]}, ['js'], 1000), 'reject'), ('large body and named inline part', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'size': 5001}, {'type': 'application/octet-stream', 'filename': 'tool.exe', 'disp': 'inline', 'size': 3}, {'type': 'application/zip', 'disp': 'attachment', 'size': 5000}]}, ['exe'], 1000), ['keep', 'strip', 'strip']), ('size boundaries', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'image/png', 'filename': 'a.png', 'disp': 'attachment', 'size': 1000}, {'type': 'image/png', 'filename': 'b.png', 'disp': 'attachment', 'size': 1001}]}, [], 1000), ['keep', 'keep', 'strip']), ('executable type in signed', ({'type': 'multipart/signed', 'parts': [{'type': 'text/plain'}, {'type': 'application/x-msdownload', 'filename': 'a.bin', 'disp': 'attachment', 'size': 1}]}, [], 50), 'reject'), ('clean message', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/pdf', 'filename': 'r1.pdf', 'disp': 'attachment', 'size': 10}]}, ['exe'], 100), ['keep', 'keep'])], 2: [('double extension', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'size': 10}, {'type': 'application/pdf', 'filename': 'invoice2.pdf.exe', 'disp': 'attachment', 'size': 10}]}, ['exe'], 1000), ['keep', 'strip']), ('upper-case padded extension', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/octet-stream', 'filename': 'SETUP2.EXE ', 'disp': 'attachment', 'size': 5}]}, ['exe'], 1000), ['keep', 'strip']), ('blocked part inside signed mixed', ({'type': 'multipart/signed', 'parts': [{'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/zip', 'filename': 'x.js', 'disp': 'attachment', 'size': 2}]}, {'type': 'application/pgp-signature'}]}, ['js'], 1000), 'reject'), ('large body and named inline part', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'size': 5002}, {'type': 'application/octet-stream', 'filename': 'tool.exe', 'disp': 'inline', 'size': 3}, {'type': 'application/zip', 'disp': 'attachment', 'size': 5000}]}, ['exe'], 1000), ['keep', 'strip', 'strip']), ('size boundaries', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'image/png', 'filename': 'a.png', 'disp': 'attachment', 'size': 2000}, {'type': 'image/png', 'filename': 'b.png', 'disp': 'attachment', 'size': 2001}]}, [], 2000), ['keep', 'keep', 'strip']), ('executable type in signed', ({'type': 'multipart/signed', 'parts': [{'type': 'text/plain'}, {'type': 'application/x-msdownload', 'filename': 'a.bin', 'disp': 'attachment', 'size': 1}]}, [], 50), 'reject'), ('clean message', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/pdf', 'filename': 'r2.pdf', 'disp': 'attachment', 'size': 10}]}, ['exe'], 100), ['keep', 'keep'])], 3: [('double extension', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'size': 10}, {'type': 'application/pdf', 'filename': 'invoice3.pdf.exe', 'disp': 'attachment', 'size': 10}]}, ['exe'], 1000), ['keep', 'strip']), ('upper-case padded extension', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/octet-stream', 'filename': 'SETUP3.EXE ', 'disp': 'attachment', 'size': 5}]}, ['exe'], 1000), ['keep', 'strip']), ('blocked part inside signed mixed', ({'type': 'multipart/signed', 'parts': [{'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/zip', 'filename': 'x.js', 'disp': 'attachment', 'size': 3}]}, {'type': 'application/pgp-signature'}]}, ['js'], 1000), 'reject'), ('large body and named inline part', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'size': 5003}, {'type': 'application/octet-stream', 'filename': 'tool.exe', 'disp': 'inline', 'size': 3}, {'type': 'application/zip', 'disp': 'attachment', 'size': 5000}]}, ['exe'], 1000), ['keep', 'strip', 'strip']), ('size boundaries', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'image/png', 'filename': 'a.png', 'disp': 'attachment', 'size': 3000}, {'type': 'image/png', 'filename': 'b.png', 'disp': 'attachment', 'size': 3001}]}, [], 3000), ['keep', 'keep', 'strip']), ('executable type in signed', ({'type': 'multipart/signed', 'parts': [{'type': 'text/plain'}, {'type': 'application/x-msdownload', 'filename': 'a.bin', 'disp': 'attachment', 'size': 1}]}, [], 50), 'reject'), ('clean message', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/pdf', 'filename': 'r3.pdf', 'disp': 'attachment', 'size': 10}]}, ['exe'], 100), ['keep', 'keep'])], 4: [('double extension', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'size': 10}, {'type': 'application/pdf', 'filename': 'invoice4.pdf.exe', 'disp': 'attachment', 'size': 10}]}, ['exe'], 1000), ['keep', 'strip']), ('upper-case padded extension', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/octet-stream', 'filename': 'SETUP4.EXE ', 'disp': 'attachment', 'size': 5}]}, ['exe'], 1000), ['keep', 'strip']), ('blocked part inside signed mixed', ({'type': 'multipart/signed', 'parts': [{'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/zip', 'filename': 'x.js', 'disp': 'attachment', 'size': 4}]}, {'type': 'application/pgp-signature'}]}, ['js'], 1000), 'reject'), ('large body and named inline part', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'size': 5004}, {'type': 'application/octet-stream', 'filename': 'tool.exe', 'disp': 'inline', 'size': 3}, {'type': 'application/zip', 'disp': 'attachment', 'size': 5000}]}, ['exe'], 1000), ['keep', 'strip', 'strip']), ('size boundaries', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'image/png', 'filename': 'a.png', 'disp': 'attachment', 'size': 4000}, {'type': 'image/png', 'filename': 'b.png', 'disp': 'attachment', 'size': 4001}]}, [], 4000), ['keep', 'keep', 'strip']), ('executable type in signed', ({'type': 'multipart/signed', 'parts': [{'type': 'text/plain'}, {'type': 'application/x-msdownload', 'filename': 'a.bin', 'disp': 'attachment', 'size': 1}]}, [], 50), 'reject'), ('clean message', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/pdf', 'filename': 'r4.pdf', 'disp': 'attachment', 'size': 10}]}, ['exe'], 100), ['keep', 'keep'])], 5: [('double extension', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'size': 10}, {'type': 'application/pdf', 'filename': 'invoice5.pdf.exe', 'disp': 'attachment', 'size': 10}]}, ['exe'], 1000), ['keep', 'strip']), ('upper-case padded extension', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/octet-stream', 'filename': 'SETUP5.EXE ', 'disp': 'attachment', 'size': 5}]}, ['exe'], 1000), ['keep', 'strip']), ('blocked part inside signed mixed', ({'type': 'multipart/signed', 'parts': [{'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/zip', 'filename': 'x.js', 'disp': 'attachment', 'size': 5}]}, {'type': 'application/pgp-signature'}]}, ['js'], 1000), 'reject'), ('large body and named inline part', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'size': 5005}, {'type': 'application/octet-stream', 'filename': 'tool.exe', 'disp': 'inline', 'size': 3}, {'type': 'application/zip', 'disp': 'attachment', 'size': 5000}]}, ['exe'], 1000), ['keep', 'strip', 'strip']), ('size boundaries', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'image/png', 'filename': 'a.png', 'disp': 'attachment', 'size': 5000}, {'type': 'image/png', 'filename': 'b.png', 'disp': 'attachment', 'size': 5001}]}, [], 5000), ['keep', 'keep', 'strip']), ('executable type in signed', ({'type': 'multipart/signed', 'parts': [{'type': 'text/plain'}, {'type': 'application/x-msdownload', 'filename': 'a.bin', 'disp': 'attachment', 'size': 1}]}, [], 50), 'reject'), ('clean message', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/pdf', 'filename': 'r5.pdf', 'disp': 'attachment', 'size': 10}]}, ['exe'], 100), ['keep', 'keep'])]}\nfor _label, _args, _expected in _CASES[N]:\n    check(_label, solve(*_args), _expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"fixed":{"sha256":"c75af58699560d6615527b9c35088db3b69d568b971b5a0fb01e61f37640e16a","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(tree, blocked_ext, max_size):\n    actions = []\n    def walk(n, signed):\n        t = n['type'].lower()\n        if t.startswith('multipart/'):\n            for c in n['parts']:\n                walk(c, signed or t == 'multipart/signed')\n            return\n        name = (n.get('filename') or '').strip().lower()\n        ext = name.rsplit('.', 1)[-1] if '.' in name else ''\n        bad = ext in blocked_ext or t == 'application/x-msdownload' or n.get('size', 0) > max_size\n        if (n.get('disp') or '').lower() != 'attachment' and not name:\n            bad = False\n        if bad and signed:\n            actions.append('reject')\n        else:\n            actions.append('strip' if bad else 'keep')\n    walk(tree, False)\n    return 'reject' if 'reject' in actions else actions\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\n_CASES = {1: [('double extension', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'size': 10}, {'type': 'application/pdf', 'filename': 'invoice1.pdf.exe', 'disp': 'attachment', 'size': 10}]}, ['exe'], 1000), ['keep', 'strip']), ('upper-case padded extension', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/octet-stream', 'filename': 'SETUP1.EXE ', 'disp': 'attachment', 'size': 5}]}, ['exe'], 1000), ['keep', 'strip']), ('blocked part inside signed mixed', ({'type': 'multipart/signed', 'parts': [{'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/zip', 'filename': 'x.js', 'disp': 'attachment', 'size': 1}]}, {'type': 'application/pgp-signature'}]}, ['js'], 1000), 'reject'), ('large body and named inline part', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'size': 5001}, {'type': 'application/octet-stream', 'filename': 'tool.exe', 'disp': 'inline', 'size': 3}, {'type': 'application/zip', 'disp': 'attachment', 'size': 5000}]}, ['exe'], 1000), ['keep', 'strip', 'strip']), ('size boundaries', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'image/png', 'filename': 'a.png', 'disp': 'attachment', 'size': 1000}, {'type': 'image/png', 'filename': 'b.png', 'disp': 'attachment', 'size': 1001}]}, [], 1000), ['keep', 'keep', 'strip']), ('executable type in signed', ({'type': 'multipart/signed', 'parts': [{'type': 'text/plain'}, {'type': 'application/x-msdownload', 'filename': 'a.bin', 'disp': 'attachment', 'size': 1}]}, [], 50), 'reject'), ('clean message', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/pdf', 'filename': 'r1.pdf', 'disp': 'attachment', 'size': 10}]}, ['exe'], 100), ['keep', 'keep'])], 2: [('double extension', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'size': 10}, {'type': 'application/pdf', 'filename': 'invoice2.pdf.exe', 'disp': 'attachment', 'size': 10}]}, ['exe'], 1000), ['keep', 'strip']), ('upper-case padded extension', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/octet-stream', 'filename': 'SETUP2.EXE ', 'disp': 'attachment', 'size': 5}]}, ['exe'], 1000), ['keep', 'strip']), ('blocked part inside signed mixed', ({'type': 'multipart/signed', 'parts': [{'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/zip', 'filename': 'x.js', 'disp': 'attachment', 'size': 2}]}, {'type': 'application/pgp-signature'}]}, ['js'], 1000), 'reject'), ('large body and named inline part', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'size': 5002}, {'type': 'application/octet-stream', 'filename': 'tool.exe', 'disp': 'inline', 'size': 3}, {'type': 'application/zip', 'disp': 'attachment', 'size': 5000}]}, ['exe'], 1000), ['keep', 'strip', 'strip']), ('size boundaries', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'image/png', 'filename': 'a.png', 'disp': 'attachment', 'size': 2000}, {'type': 'image/png', 'filename': 'b.png', 'disp': 'attachment', 'size': 2001}]}, [], 2000), ['keep', 'keep', 'strip']), ('executable type in signed', ({'type': 'multipart/signed', 'parts': [{'type': 'text/plain'}, {'type': 'application/x-msdownload', 'filename': 'a.bin', 'disp': 'attachment', 'size': 1}]}, [], 50), 'reject'), ('clean message', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/pdf', 'filename': 'r2.pdf', 'disp': 'attachment', 'size': 10}]}, ['exe'], 100), ['keep', 'keep'])], 3: [('double extension', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'size': 10}, {'type': 'application/pdf', 'filename': 'invoice3.pdf.exe', 'disp': 'attachment', 'size': 10}]}, ['exe'], 1000), ['keep', 'strip']), ('upper-case padded extension', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/octet-stream', 'filename': 'SETUP3.EXE ', 'disp': 'attachment', 'size': 5}]}, ['exe'], 1000), ['keep', 'strip']), ('blocked part inside signed mixed', ({'type': 'multipart/signed', 'parts': [{'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/zip', 'filename': 'x.js', 'disp': 'attachment', 'size': 3}]}, {'type': 'application/pgp-signature'}]}, ['js'], 1000), 'reject'), ('large body and named inline part', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'size': 5003}, {'type': 'application/octet-stream', 'filename': 'tool.exe', 'disp': 'inline', 'size': 3}, {'type': 'application/zip', 'disp': 'attachment', 'size': 5000}]}, ['exe'], 1000), ['keep', 'strip', 'strip']), ('size boundaries', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'image/png', 'filename': 'a.png', 'disp': 'attachment', 'size': 3000}, {'type': 'image/png', 'filename': 'b.png', 'disp': 'attachment', 'size': 3001}]}, [], 3000), ['keep', 'keep', 'strip']), ('executable type in signed', ({'type': 'multipart/signed', 'parts': [{'type': 'text/plain'}, {'type': 'application/x-msdownload', 'filename': 'a.bin', 'disp': 'attachment', 'size': 1}]}, [], 50), 'reject'), ('clean message', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/pdf', 'filename': 'r3.pdf', 'disp': 'attachment', 'size': 10}]}, ['exe'], 100), ['keep', 'keep'])], 4: [('double extension', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'size': 10}, {'type': 'application/pdf', 'filename': 'invoice4.pdf.exe', 'disp': 'attachment', 'size': 10}]}, ['exe'], 1000), ['keep', 'strip']), ('upper-case padded extension', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/octet-stream', 'filename': 'SETUP4.EXE ', 'disp': 'attachment', 'size': 5}]}, ['exe'], 1000), ['keep', 'strip']), ('blocked part inside signed mixed', ({'type': 'multipart/signed', 'parts': [{'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/zip', 'filename': 'x.js', 'disp': 'attachment', 'size': 4}]}, {'type': 'application/pgp-signature'}]}, ['js'], 1000), 'reject'), ('large body and named inline part', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'size': 5004}, {'type': 'application/octet-stream', 'filename': 'tool.exe', 'disp': 'inline', 'size': 3}, {'type': 'application/zip', 'disp': 'attachment', 'size': 5000}]}, ['exe'], 1000), ['keep', 'strip', 'strip']), ('size boundaries', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'image/png', 'filename': 'a.png', 'disp': 'attachment', 'size': 4000}, {'type': 'image/png', 'filename': 'b.png', 'disp': 'attachment', 'size': 4001}]}, [], 4000), ['keep', 'keep', 'strip']), ('executable type in signed', ({'type': 'multipart/signed', 'parts': [{'type': 'text/plain'}, {'type': 'application/x-msdownload', 'filename': 'a.bin', 'disp': 'attachment', 'size': 1}]}, [], 50), 'reject'), ('clean message', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/pdf', 'filename': 'r4.pdf', 'disp': 'attachment', 'size': 10}]}, ['exe'], 100), ['keep', 'keep'])], 5: [('double extension', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'size': 10}, {'type': 'application/pdf', 'filename': 'invoice5.pdf.exe', 'disp': 'attachment', 'size': 10}]}, ['exe'], 1000), ['keep', 'strip']), ('upper-case padded extension', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/octet-stream', 'filename': 'SETUP5.EXE ', 'disp': 'attachment', 'size': 5}]}, ['exe'], 1000), ['keep', 'strip']), ('blocked part inside signed mixed', ({'type': 'multipart/signed', 'parts': [{'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/zip', 'filename': 'x.js', 'disp': 'attachment', 'size': 5}]}, {'type': 'application/pgp-signature'}]}, ['js'], 1000), 'reject'), ('large body and named inline part', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain', 'size': 5005}, {'type': 'application/octet-stream', 'filename': 'tool.exe', 'disp': 'inline', 'size': 3}, {'type': 'application/zip', 'disp': 'attachment', 'size': 5000}]}, ['exe'], 1000), ['keep', 'strip', 'strip']), ('size boundaries', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'image/png', 'filename': 'a.png', 'disp': 'attachment', 'size': 5000}, {'type': 'image/png', 'filename': 'b.png', 'disp': 'attachment', 'size': 5001}]}, [], 5000), ['keep', 'keep', 'strip']), ('executable type in signed', ({'type': 'multipart/signed', 'parts': [{'type': 'text/plain'}, {'type': 'application/x-msdownload', 'filename': 'a.bin', 'disp': 'attachment', 'size': 1}]}, [], 50), 'reject'), ('clean message', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'application/pdf', 'filename': 'r5.pdf', 'disp': 'attachment', 'size': 10}]}, ['exe'], 100), ['keep', 'keep'])]}\nfor _label, _args, _expected in _CASES[N]:\n    check(_label, solve(*_args), _expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"}},"limitations":"Stipulated offline model over pre-parsed MIME dictionaries; not a conforming MIME parser, generator or mail client. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.","method":"Deterministic executable model with adversarial boundary fixtures.","provenance":{"created_by":"Failure Map","dependencies":"Python standard library","family":"w2-email_mime_structure-attachment-stripping-signed-inheritance","generated_at":"2026-09-29T14:49:19.740313+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Mail gateways strip dangerous attachments but must not silently break signed messages.","repair":"Use `signed or t == 'multipart/signed'` for the signed inheritance decision and keep every other rule of the model unchanged.","root_cause":"The signed inheritance decision evaluates `t == 'multipart/signed'` where the contract requires `signed or t == 'multipart/signed'`.","sha256":"100a2525e15a83e81857d3d338c2692ea76b6d89e2c6ecb32457dbbca8281853","title":"Strip blocked attachments under a content policy: signed inheritance · case 01","variant":1,"variant_policy":"N selects a different enumerated fixture set (renamed identifiers, part counts and sizes); boundary fixtures recur across variants.","verification":{"attempt":{"elapsed_ms":39.165,"exit_code":1,"observations":[{"actual":["keep","strip"],"check":"double extension","expected":["keep","strip"],"passed":true},{"actual":["keep","strip"],"check":"upper-case padded extension","expected":["keep","strip"],"passed":true},{"actual":["keep","strip","keep"],"check":"blocked part inside signed mixed","expected":"reject","passed":false},{"actual":["keep","strip","strip"],"check":"large body and named inline part","expected":["keep","strip","strip"],"passed":true},{"actual":["keep","keep","strip"],"check":"size boundaries","expected":["keep","keep","strip"],"passed":true},{"actual":"reject","check":"executable type in signed","expected":"reject","passed":true},{"actual":["keep","keep"],"check":"clean message","expected":["keep","keep"],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"double extension\", \"actual\": [\"keep\", \"strip\"], \"expected\": [\"keep\", \"strip\"], \"passed\": true}, {\"check\": \"upper-case padded extension\", \"actual\": [\"keep\", \"strip\"], \"expected\": [\"keep\", \"strip\"], \"passed\": true}, {\"check\": \"blocked part inside signed mixed\", \"actual\": [\"keep\", \"strip\", \"keep\"], \"expected\": \"reject\", \"passed\": false}, {\"check\": \"large body and named inline part\", \"actual\": [\"keep\", \"strip\", \"strip\"], \"expected\": [\"keep\", \"strip\", \"strip\"], \"passed\": true}, {\"check\": \"size boundaries\", \"actual\": [\"keep\", \"keep\", \"strip\"], \"expected\": [\"keep\", \"keep\", \"strip\"], \"passed\": true}, {\"check\": \"executable type in signed\", \"actual\": \"reject\", \"expected\": \"reject\", \"passed\": true}, {\"check\": \"clean message\", \"actual\": [\"keep\", \"keep\"], \"expected\": [\"keep\", \"keep\"], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":38.177,"exit_code":1,"observations":[{"actual":["keep","strip"],"check":"double extension","expected":["keep","strip"],"passed":true},{"actual":["keep","strip"],"check":"upper-case padded extension","expected":["keep","strip"],"passed":true},{"actual":["keep","strip","keep"],"check":"blocked part inside signed mixed","expected":"reject","passed":false},{"actual":["keep","strip","strip"],"check":"large body and named inline part","expected":["keep","strip","strip"],"passed":true},{"actual":["keep","keep","strip"],"check":"size boundaries","expected":["keep","keep","strip"],"passed":true},{"actual":"reject","check":"executable type in signed","expected":"reject","passed":true},{"actual":["keep","keep"],"check":"clean message","expected":["keep","keep"],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"double extension\", \"actual\": [\"keep\", \"strip\"], \"expected\": [\"keep\", \"strip\"], \"passed\": true}, {\"check\": \"upper-case padded extension\", \"actual\": [\"keep\", \"strip\"], \"expected\": [\"keep\", \"strip\"], \"passed\": true}, {\"check\": \"blocked part inside signed mixed\", \"actual\": [\"keep\", \"strip\", \"keep\"], \"expected\": \"reject\", \"passed\": false}, {\"check\": \"large body and named inline part\", \"actual\": [\"keep\", \"strip\", \"strip\"], \"expected\": [\"keep\", \"strip\", \"strip\"], \"passed\": true}, {\"check\": \"size boundaries\", \"actual\": [\"keep\", \"keep\", \"strip\"], \"expected\": [\"keep\", \"keep\", \"strip\"], \"passed\": true}, {\"check\": \"executable type in signed\", \"actual\": \"reject\", \"expected\": \"reject\", \"passed\": true}, {\"check\": \"clean message\", \"actual\": [\"keep\", \"keep\"], \"expected\": [\"keep\", \"keep\"], \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":42.495,"exit_code":0,"observations":[{"actual":["keep","strip"],"check":"double extension","expected":["keep","strip"],"passed":true},{"actual":["keep","strip"],"check":"upper-case padded extension","expected":["keep","strip"],"passed":true},{"actual":"reject","check":"blocked part inside signed mixed","expected":"reject","passed":true},{"actual":["keep","strip","strip"],"check":"large body and named inline part","expected":["keep","strip","strip"],"passed":true},{"actual":["keep","keep","strip"],"check":"size boundaries","expected":["keep","keep","strip"],"passed":true},{"actual":"reject","check":"executable type in signed","expected":"reject","passed":true},{"actual":["keep","keep"],"check":"clean message","expected":["keep","keep"],"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"double extension\", \"actual\": [\"keep\", \"strip\"], \"expected\": [\"keep\", \"strip\"], \"passed\": true}, {\"check\": \"upper-case padded extension\", \"actual\": [\"keep\", \"strip\"], \"expected\": [\"keep\", \"strip\"], \"passed\": true}, {\"check\": \"blocked part inside signed mixed\", \"actual\": \"reject\", \"expected\": \"reject\", \"passed\": true}, {\"check\": \"large body and named inline part\", \"actual\": [\"keep\", \"strip\", \"strip\"], \"expected\": [\"keep\", \"strip\", \"strip\"], \"passed\": true}, {\"check\": \"size boundaries\", \"actual\": [\"keep\", \"keep\", \"strip\"], \"expected\": [\"keep\", \"keep\", \"strip\"], \"passed\": true}, {\"check\": \"executable type in signed\", \"actual\": \"reject\", \"expected\": \"reject\", \"passed\": true}, {\"check\": \"clean message\", \"actual\": [\"keep\", \"keep\"], \"expected\": [\"keep\", \"keep\"], \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}