{"record":{"id":"db103f8e8d0c19bd","repo":"BigPizzaV3/CodexPlusPlus","slug":"dream-skin-64-mib","errorCode":null,"errorMessage":"Dream Skin 主题包解包后超过 64 MiB 限制","messagePattern":"Dream Skin 主题包解包后超过 64 MiB 限制","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin_package.rs","lineNumber":133,"sourceCode":"        let base_name = name.rsplit('/').next().unwrap_or_default();\n        if base_name == \".DS_Store\" || name.starts_with(\"__MACOSX/\") {\n            entries.push((name, None));\n            continue;\n        }\n        if !ALLOWED_FILES.contains(&base_name) {\n            bail!(\"主题包包含不支持的文件：{name}\");\n        }\n        let limit = file_limit(base_name);\n        let mut content = Vec::new();\n        file.take((limit + 1) as u64)\n            .read_to_end(&mut content)\n            .context(\"读取 Dream Skin ZIP 内容失败\")?;\n        if content.is_empty() || content.len() > limit {\n            bail!(\"主题包文件 {name} 超过大小限制\");\n        }\n        unpacked = unpacked.saturating_add(content.len());\n        if unpacked > UNPACKED_LIMIT {\n            bail!(\"Dream Skin 主题包解包后超过 64 MiB 限制\");\n        }\n        entries.push((name, Some(content)));\n    }\n\n    let mut files = normalize_package_entries(entries)?;\n\n    let manifest_bytes = files\n        .remove(\"manifest.json\")\n        .context(\"主题包缺少 manifest.json\")?;\n    let theme_bytes = files\n        .remove(\"theme.json\")\n        .context(\"主题包缺少 theme.json\")?;\n    let css_bytes = files.remove(\"theme.css\").context(\"主题包缺少 theme.css\")?;\n    let image_name = [\"background.webp\", \"background.jpg\", \"background.png\"]\n        .iter()\n        .find(|name| files.contains_key(**name))\n        .map(|name| (*name).to_string())\n        .context(\"主题包必须包含一个背景图片\")?;","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin_package.rs#L115-L151","documentation":"The running total of decompressed entry sizes is tracked in `unpacked`; if it exceeds UNPACKED_LIMIT (64 MiB), the package is rejected. This is a zip-bomb defense bounding total extracted bytes even if the compressed archive is small.","triggerScenarios":"A package whose entries' combined decompressed sizes exceed 64 MiB — notably a zip bomb (highly compressed large files) — processed by validate_and_read_package.","commonSituations":"Malicious zip bomb submitted to the market; legitimate theme with many large assets that individually pass per-file limits but total over 64 MiB.","solutions":["Reduce total uncompressed asset size below 64 MiB (compress images, remove files)","Treat the error as a possible zip bomb if the compressed package is tiny — reject the source","Audit the package contents (`unzip -l`) to see total uncompressed size before repackaging","Split assets across packages if genuinely needed"],"exampleFix":"// before\nunzip -l theme.zip  # 80 MiB uncompressed\n// after\noptipng background.png && remove extra assets  # < 64 MiB total","handlingStrategy":"validation","validationCode":"let total: usize = entry_sizes.iter().sum();\nconst UNPACKED_LIMIT: usize = 64 * 1024 * 1024;\nif total > UNPACKED_LIMIT {\n    return Err(UnpackedTooLarge(total));\n}","typeGuard":null,"tryCatchPattern":"match validate_and_read_package(&bytes, platform) {\n    Err(e) if e.to_string().contains(\"64 MiB\") => {\n        Err(UserFacingError::SuspiciousOrOversizedPackage)\n    }\n    other => other,\n}","preventionTips":["Run `unzip -l` to check total uncompressed size before shipping","Be suspicious of small ZIPs with huge uncompressed sizes (zip bombs)","Cap individual image sizes so the sum stays well under 64 MiB"],"tags":["security","zip-bomb","size-limit"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}