{"record":{"id":"4aa8df7c70cf3b3a","repo":"anthropics/skills","slug":"symlink-archive-entry-not-allowed-m-filename-r-4aa8df","errorCode":null,"errorMessage":"symlink archive entry not allowed: {m.filename!r}","messagePattern":"symlink archive entry not allowed: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"skills/pptx/scripts/office/helpers/__init__.py","lineNumber":78,"sourceCode":"    return posixpath.join(owner_dir.as_posix(), rels_file.name[: -len(\".rels\")]).lstrip(\"./\")\n\n\ndef part_text(data: bytes) -> str:\n    return data.decode(\"utf-8\", \"surrogateescape\")\n\n\nXML_SPACE = \" \\t\\r\\n\"\n\n\ndef rendered_text(text: str, preserve: bool) -> str:\n    return text if preserve else text.strip(XML_SPACE)\n\n\ndef safe_extract(zf: zipfile.ZipFile, dest: Path) -> None:\n    dest = dest.resolve()\n    for m in zf.infolist():\n        if stat.S_ISLNK(m.external_attr >> 16):\n            raise ValueError(f\"symlink archive entry not allowed: {m.filename!r}\")\n        target = (dest / m.filename).resolve()\n        if not target.is_relative_to(dest):\n            raise ValueError(f\"unsafe archive entry: {m.filename!r}\")\n        zf.extract(m, dest)\n\n\ndef rezip(src_dir: Path, out_path: Path) -> None:\n    files = sorted(p for p in src_dir.rglob(\"*\") if p.is_file())\n    ct = src_dir / \"[Content_Types].xml\"\n    fd, tmp_name = tempfile.mkstemp(\n        prefix=out_path.name + \".\", suffix=\".tmp\", dir=out_path.parent\n    )\n    tmp_out = Path(tmp_name)\n    try:\n        with os.fdopen(fd, \"wb\") as fh:\n            with zipfile.ZipFile(fh, \"w\", zipfile.ZIP_DEFLATED) as zf:\n                if ct.exists():\n                    zf.write(ct, ct.relative_to(src_dir), compress_type=zipfile.ZIP_STORED)","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/anthropics/skills/blob/f6656c1256d5a8adfa37db9110046ef20bac644c/skills/pptx/scripts/office/helpers/__init__.py#L60-L96","documentation":"pptx copy of the symlink extraction guard (same as error 6): safe_extract() refuses any zip member stored with symlink mode bits before extracting, preventing crafted archives from planting links that redirect subsequent writes outside the destination (zip-slip via symlink). Standard PPTX files never contain symlinks, so hitting this means the input is crafted or non-standard.","triggerScenarios":"Unpacking a pptx/zip with an entry whose external_attr indicates S_IFLNK — e.g. 'ppt/presentation.xml -> /etc/passwd' — during any unpack-based pipeline step.","commonSituations":"Untrusted uploaded decks; archives rebuilt with symlink-preserving tools; security testing payloads.","solutions":["Quarantine the input; the guard correctly flagged a dangerous archive.","If you built the archive, rebuild it from plain files with no symlinks.","Add a pre-scan step rejecting S_ISLNK entries before the pipeline touches the file.","Trace which producer created the symlink entry and fix it."],"exampleFix":"# pre-scan gate\nimport stat, zipfile\ndef has_symlinks(path):\n    with zipfile.ZipFile(path) as zf:\n        return any(stat.S_ISLNK(m.external_attr >> 16) for m in zf.infolist())\nif has_symlinks(upload):\n    quarantine(upload)","handlingStrategy":"validation","validationCode":"import stat, zipfile\n\ndef has_symlink_entries(path: str) -> bool:\n    with zipfile.ZipFile(path) as zf:\n        return any(stat.S_ISLNK(m.external_attr >> 16) for m in zf.infolist())","typeGuard":null,"tryCatchPattern":"from office.helpers import safe_extract\ntry:\n    safe_extract(zf, dest)\nexcept ValueError as e:\n    if \"symlink archive entry\" in str(e):\n        quarantine(path)\n    else:\n        raise","preventionTips":["Pre-scan for symlink members before unpack.","Quarantine decks that trip this guard — they are crafted or non-standard.","Extract into disposable temp directories only."],"tags":["pptx","security","symlink","zip-slip","extraction"],"backgroundTag":null,"analyzedSha":"f6656c1256d5a8adfa37db9110046ef20bac644c","analyzedAt":"2026-08-14T16:09:17.493Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}