{"record":{"id":"f64a0b347bab419e","repo":"AlistGo/alist","slug":"errarchiveillegalpath-f64a0b","errorCode":"ErrArchiveIllegalPath","errorMessage":"archive entry has illegal path: %s","messagePattern":"archive entry has illegal path: (.+?)","errorType":"exception","errorClass":"ErrArchiveIllegalPath","httpStatus":null,"severity":"error","filePath":"internal/archive/rardecode/rardecode.go","lineNumber":136,"sourceCode":"\t\t\tif header.IsDir {\n\t\t\t\tname = name + \"/\"\n\t\t\t}\n\t\t\tif name == innerPath {\n\t\t\t\tif header.IsDir {\n\t\t\t\t\tif !createdBaseDir {\n\t\t\t\t\t\tbaseDirPath, err = tool.SecureJoin(outputPath, innerBase)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif err = os.MkdirAll(baseDirPath, 0700); err != nil {\n\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcreatedBaseDir = true\n\t\t\t\t\t}\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif !header.Mode().IsRegular() {\n\t\t\t\t\treturn fmt.Errorf(\"%w: %s\", tool.ErrArchiveIllegalPath, header.Name)\n\t\t\t\t}\n\t\t\t\tdstPath, e := tool.SecureJoin(outputPath, stdpath.Base(innerPath))\n\t\t\t\tif e != nil {\n\t\t\t\t\treturn e\n\t\t\t\t}\n\t\t\t\tif err = os.MkdirAll(filepath.Dir(dstPath), 0700); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\terr = _decompress(reader, header, dstPath, up, limiter)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t} else if strings.HasPrefix(name, innerPath+\"/\") {\n\t\t\t\tif !createdBaseDir {\n\t\t\t\t\tbaseDirPath, err = tool.SecureJoin(outputPath, innerBase)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/internal/archive/rardecode/rardecode.go#L118-L154","documentation":"RAR-specific extraction guard in internal/archive/rardecode/rardecode.go. While iterating RAR entries (including inner-base handling for nested archives), any header whose Mode() is not a regular file — RAR symlink or special entries — is rejected with ErrArchiveIllegalPath before SecureJoin and decompression.","triggerScenarios":"Decompressing a .rar archive (folder extraction path) that contains Unix symlink entries or other non-regular file types stored by the archiver.","commonSituations":"RAR archives created on Linux with symlinks preserved (WinRAR '-ol' style behavior); software distribution rars containing links; maliciously crafted rars.","solutions":["Repack the content as tar.gz/zip with symlinks dereferenced, or extract with unrar/7z which can materialize links safely","If you produced the rar, disable storing symlinks when archiving","Keep the guard intact; it prevents link-based escape during extraction"],"exampleFix":"# before: rar stores symlinks\nrar a -ol data.rar mydir/\n\n# after: dereference links before packing (or use tar)\ncp -rL mydir mydir-flat && rar a data.rar mydir-flat/","handlingStrategy":"validation","validationCode":null,"typeGuard":"func rarHeaderSafe(h *rardecode.FileHeader) bool {\n    return h.IsDir || h.Mode().IsRegular()\n}","tryCatchPattern":"if err := rarTool.Decompress(ss, out, args, up); err != nil {\n    if errors.Is(err, tool.ErrArchiveIllegalPath) {\n        // symlink/device member in the rar: quarantine, do not retry\n    }\n}","preventionTips":["Check rars with 'unrar l -v' for symlink entries before extraction","Create rars without storing links when targeting this extractor","Prefer zip/tar workflows with dereferenced links for distribution"],"tags":["archive","rar","security","symlink","extraction"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}