{"record":{"id":"fe5ba718b90f0d8c","repo":"langchain-ai/deepagents","slug":"info-filename-zip-entry-expanded-beyond-declare","errorCode":null,"errorMessage":"{info.filename}: zip entry expanded beyond declared size","messagePattern":"(.+?): zip entry expanded beyond declared size","errorType":"error_code","errorClass":"FleetImportError","httpStatus":null,"severity":"error","filePath":"libs/talon/deepagents_talon/fleet_import.py","lineNumber":298,"sourceCode":"            _validate_agent_name(subagent, name)\n            _copy_zip_file(archive, info, staging / \"agents\" / subagent / \"AGENTS.md\")\n        elif name in {\"config.json\", \"tools.json\"}:\n            _copy_zip_file(archive, info, staging / name)\n        elif _is_subagent_tools_path(name):\n            subagent = PurePosixPath(name).parts[1]\n            _validate_agent_name(subagent, name)\n            _copy_zip_file(archive, info, staging / \"agents\" / subagent / \"tools.json\")\n\n\ndef _copy_zip_file(archive: zipfile.ZipFile, info: zipfile.ZipInfo, target: Path) -> None:\n    target.parent.mkdir(mode=0o700, parents=True, exist_ok=True)\n    copied = 0\n    with archive.open(info) as src, target.open(\"wb\") as dst:\n        while chunk := src.read(_COPY_CHUNK_SIZE):\n            copied += len(chunk)\n            if copied > info.file_size or copied > _MAX_ZIP_UNCOMPRESSED_BYTES:\n                msg = f\"{info.filename}: zip entry expanded beyond declared size\"\n                raise FleetImportError(msg)\n            dst.write(chunk)\n    target.chmod(0o600)\n\n\ndef _validate_agent_name(name: str, path: str) -> None:\n    if not _AGENT_ID_PATTERN.fullmatch(name) or name in {\".\", \"..\"}:\n        msg = f\"{path}: unsafe subagent name {name!r}\"\n        raise FleetImportError(msg)\n\n\ndef _is_subagent_prompt_path(name: str) -> bool:\n    parts = PurePosixPath(name).parts\n    return (\n        len(parts) == _SUBAGENT_FILE_PARTS and parts[0] == \"subagents\" and parts[2] == \"AGENTS.md\"\n    )\n\n\ndef _is_subagent_tools_path(name: str) -> bool:","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/talon/deepagents_talon/fleet_import.py#L280-L316","documentation":"While copying an entry to the staging directory, the number of bytes actually read exceeds either the entry's declared `file_size` or the global 256 MiB cap. This runtime check catches archives whose declared metadata lies (or whose decompressor produces more data than declared) — a defense-in-depth layer against zip bombs that pass static validation.","triggerScenarios":"`import_fleet_zip` → `_materialize_staging` → `_copy_zip_file` reads chunks from `archive.open(info)` and the accumulated `copied` counter surpasses `info.file_size` or `_MAX_ZIP_UNCOMPRESSED_BYTES`.","commonSituations":"Deliberately crafted archives with lying headers (declared small, decompressed large), corrupted zips whose central directory disagrees with the local header, or decompression backend bugs.","solutions":["Verify the archive (`zipfile.ZipFile(p).testzip()`); if corrupt, re-obtain the export from the source","Reject the archive as untrusted — the on-disk data does not match declared metadata; request a clean re-export","Inspect entry headers (local vs central) with `zipfile.ZipFile(p).getinfo(name)` for size mismatches and rebuild the zip"],"exampleFix":"# before: tampered zip where local header size != central directory\n// after: recreate the archive from trusted files\nzip -r fleet.zip AGENTS.md skills subagents  # then verify testzip()","handlingStrategy":"try-catch","validationCode":"import zipfile\n\nzip_path.expanduser().verify_archive = None  # no-op placeholder\nwith zipfile.ZipFile(zip_path.expanduser()) as z:\n    if z.testzip() is not None:\n        raise ValueError(\"archive corrupt: verify before import\")","typeGuard":null,"tryCatchPattern":"try:\n    import_fleet_zip(zip_path, target_dir=target)\nexcept FleetImportError as exc:\n    if \"expanded beyond declared size\" in str(exc):\n        print(\"Archive metadata is inconsistent with content; treat as untrusted and re-export\")\n    raise","preventionTips":["Verify archive integrity (testzip) before import","Re-download rather than repairing suspect archives","Reject zips whose declared sizes disagree across headers"],"tags":["security","zip","zip-bomb","integrity"],"backgroundTag":"zip-bomb-detected","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}