{"record":{"id":"5aebeb80f5f0d24e","repo":"invoke-ai/InvokeAI","slug":"error-scanning-model-at-checkpoint-for-malware","errorCode":null,"errorMessage":"Error scanning model at {checkpoint} for malware. Aborting load.","messagePattern":"Error scanning model at (.+?) for malware\\. Aborting load\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"invokeai/app/services/model_load/model_load_default.py","lineNumber":135,"sourceCode":"\n        def torch_load_file(checkpoint: Path) -> AnyModel:\n            scan_result = scan_file_path(checkpoint)\n            if scan_result.infected_files != 0:\n                if self._app_config.unsafe_disable_picklescan:\n                    self._logger.warning(\n                        f\"Model at {checkpoint} is potentially infected by malware, but picklescan is disabled. \"\n                        \"Proceeding with caution.\"\n                    )\n                else:\n                    raise Exception(f\"The model at {checkpoint} is potentially infected by malware. Aborting load.\")\n            if scan_result.scan_err:\n                if self._app_config.unsafe_disable_picklescan:\n                    self._logger.warning(\n                        f\"Error scanning model at {checkpoint} for malware, but picklescan is disabled. \"\n                        \"Proceeding with caution.\"\n                    )\n                else:\n                    raise Exception(f\"Error scanning model at {checkpoint} for malware. Aborting load.\")\n\n            result = torch_load(checkpoint, map_location=\"cpu\")\n            return result\n\n        def diffusers_load_directory(directory: Path) -> AnyModel:\n            load_class = GenericDiffusersLoader(\n                app_config=self._app_config,\n                logger=self._logger,\n                ram_cache=ram_cache,\n                convert_cache=self.convert_cache,\n            ).get_hf_load_class(directory)\n            return load_class.from_pretrained(model_path, torch_dtype=TorchDevice.choose_torch_dtype())\n\n        loader = loader or (\n            diffusers_load_directory\n            if model_path.is_dir()\n            else torch_load_file\n            if model_path.suffix.endswith((\".ckpt\", \".pt\", \".pth\", \".bin\"))","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/services/model_load/model_load_default.py#L117-L153","documentation":"torch_load_file aborts loading when the picklescan tool itself errors while scanning the checkpoint (scan_result.scan_err true), e.g. the scanner cannot parse the pickle stream. If unsafe_disable_picklescan is false this becomes a hard Exception rather than a warning.","triggerScenarios":"Passing a malformed, truncated, encrypted, or non-standard pickle/zip archive (corrupt .pt/.ckpt, partially downloaded file) to torch_load_file, or a file using pickle features picklescan cannot parse.","commonSituations":"Interrupted downloads yielding partial files; exotic checkpoint formats saved by non-PyTorch tools; picklescan version incompatibilities with new pickle opcodes; archived/zipped checkpoints with unusual structures.","solutions":["Re-download the model file and verify checksum/size.","Open/convert the checkpoint in PyTorch directly (torch.load) in a sandbox, then re-save as safetensors.","Update picklescan (pip install -U picklescan) and InvokeAI.","As a last resort for trusted files, set unsafe_disable_picklescan=true."],"exampleFix":"// before\n# corrupt partial download triggers scan error\nload({ path: 'partial_download.ckpt' });\n// after\n# verify integrity first, then load\n// sha256sum model.ckpt  # compare to published hash\nload({ path: 'model.ckpt' });","handlingStrategy":"try-catch","validationCode":"def is_loadable_checkpoint(path) -> bool:\n    if not path.is_file() or path.stat().st_size == 0:\n        return False\n    try:\n        from picklescan import scan_file_path\n        return scan_file_path(path).scan_err is False\n    except Exception:\n        return False","typeGuard":null,"tryCatchPattern":"try:\n    model = loader.load_model(path)\nexcept Exception as e:\n    if 'Error scanning model' in str(e):\n        log.error('picklescan failed on %s; re-download or convert to safetensors', path)\n        raise\n    raise","preventionTips":["Verify file checksums after downloading","Re-download truncated/corrupt files","Convert trusted checkpoints to safetensors","Keep picklescan and InvokeAI up to date"],"tags":["picklescan","malware-scan","corrupt-file","model-load"],"backgroundTag":"malware-scan-failed","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}