{"record":{"id":"cf049a432ca3e00a","repo":"siyuan-note/siyuan","slug":"marketplace-package-is-too-large","errorCode":null,"errorMessage":"marketplace package is too large","messagePattern":"marketplace package is too large","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/bazaar/local.go","lineNumber":109,"sourceCode":"\tif err != nil {\n\t\treturn errors.New(\"invalid marketplace package archive\")\n\t}\n\tdefer reader.Close()\n\n\tif len(reader.File) == 0 {\n\t\treturn errors.New(\"marketplace package archive is empty\")\n\t}\n\tif len(reader.File) > maxLocalPackageFileCount {\n\t\treturn errors.New(\"marketplace package contains too many files\")\n\t}\n\n\tvar declaredTotal uint64\n\tfor _, item := range reader.File {\n\t\tif item.UncompressedSize64 > maxLocalPackageFileSize {\n\t\t\treturn errors.New(\"marketplace package contains a file that is too large\")\n\t\t}\n\t\tif ^uint64(0)-declaredTotal < item.UncompressedSize64 {\n\t\t\treturn errors.New(\"marketplace package is too large\")\n\t\t}\n\t\tdeclaredTotal += item.UncompressedSize64\n\t\tif declaredTotal > maxLocalPackageExtractSize {\n\t\t\treturn errors.New(\"marketplace package is too large\")\n\t\t}\n\t}\n\n\tif err = os.MkdirAll(destination, 0755); err != nil {\n\t\treturn err\n\t}\n\tvar extractedTotal uint64\n\tfor _, item := range reader.File {\n\t\tif err = extractLocalPackageItem(item, destination, &extractedTotal); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/bazaar/local.go#L91-L127","documentation":"While summing declared entry sizes, if adding an entry's UncompressedSize64 would overflow uint64 (i.e. the total exceeds the maximum representable value), extractLocalPackageArchive immediately rejects the archive. This catches absurdly large declarations and prevents overflow-based bypasses of the size checks.","triggerScenarios":"Calling ExtractLocalPackage with a zip whose cumulative declared uncompressed sizes overflow uint64 (headers summing past 2^64-1).","commonSituations":"Maliciously crafted zip-bomb headers claiming near-maximum sizes to overflow naive total-size checks; corrupted zip central directory.","solutions":["Do not use the archive; rebuild it with a trusted zip tool","Verify sizes with unzip -l; absurd sizes indicate a forged/corrupt archive","Re-export the package normally; no legitimate package approaches this size"],"exampleFix":"// before: header-crafted zip with entries declaring ~2^63 bytes each\n// after: rebuild with: zip -r plugin.json package files...\n// (repackage with a standard tool so headers are truthful)","handlingStrategy":"validation","validationCode":"// Only occurs with forged/corrupt headers; pre-check with a trusted tool:\nexecSync(`unzip -t ${zipPath}`); // throws if the central directory is inconsistent","typeGuard":null,"tryCatchPattern":"try { await installLocalPackage(zipPath); } catch (e) { if (String(e).includes(\"too large\")) { /* reject source; repackage with a trusted tool */ } }","preventionTips":["Only distribute packages built with standard zip tools","Validate archives before installing untrusted zips","Never hand-craft zip headers"],"tags":["bazaar","zip","overflow","security","zip-bomb"],"backgroundTag":"payload-too-large","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}