{"record":{"id":"6707cd648e92af03","repo":"BigPizzaV3/CodexPlusPlus","slug":"dreamskin-sha-256","errorCode":null,"errorMessage":"DreamSkin 主题包 SHA-256 与审核元数据不一致","messagePattern":"DreamSkin 主题包 SHA-256 与审核元数据不一致","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/codex-plus-core/src/dream_skin_community.rs","lineNumber":176,"sourceCode":"    }\n    if !metadata.apply_compatible {\n        bail!(\"该主题是旧格式，只支持在线预览或手动下载\");\n    }\n\n    let download_url = format!(\"{COMMUNITY_API_ORIGIN}/v1/themes/{version_id}/download\");\n    let package = download_limited(\n        &client,\n        &download_url,\n        metadata.package_bytes,\n        \"application/zip\",\n    )\n    .await?;\n    if package.len() != metadata.package_bytes {\n        bail!(\"DreamSkin 主题包实际大小与审核元数据不一致\");\n    }\n    let actual_sha = format!(\"{:x}\", Sha256::digest(&package));\n    if !actual_sha.eq_ignore_ascii_case(&metadata.package_sha256) {\n        bail!(\"DreamSkin 主题包 SHA-256 与审核元数据不一致\");\n    }\n    let validated = crate::dream_skin_package::validate_and_read_package(\n        &package,\n        if cfg!(windows) { \"windows\" } else { \"macos\" },\n    )?;\n    if validated.manifest.theme_id != metadata.theme_id\n        || validated.manifest.version != metadata.version\n    {\n        bail!(\"DreamSkin 主题包身份与审核元数据不一致\");\n    }\n    crate::dream_skin_library::save_validated_dream_skin_package(state_dir, &validated)\n}\n\npub fn import_theme_package(\n    state_dir: &Path,\n    archive_path: &Path,\n) -> anyhow::Result<DreamSkinThemeSummary> {\n    let metadata = std::fs::symlink_metadata(archive_path)","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin_community.rs#L158-L194","documentation":"install_community_theme hashes the downloaded ZIP with SHA-256 and compares it to metadata.package_sha256 recorded during review. Any difference — case-insensitively — aborts the install. This guarantees the package bytes are exactly the reviewed artifact, guarding against tampering, corruption, or server-side substitution even when the size happens to match.","triggerScenarios":"Calling install_community_theme where sha256(downloaded zip) != metadata.package_sha256 from GET /v1/themes/{version_id} — the package served differs from the reviewed one despite the declared size (or a size match by coincidence after corruption/replacement).","commonSituations":"MITM or tampered mirror serving a modified package; server-side file replaced without updating review metadata; bit-flip corruption on disk/network; CDN serving a stale or malicious variant of the ZIP.","solutions":["Retry the install to rule out transient corruption.","Verify the official SHA-256 via the community API metadata and, if possible, an out-of-band source from the theme author.","Do NOT bypass or trust the download if mismatches persist — the artifact differs from the reviewed one; report it to community operators.","Try downloading from a different network (rule out local MITM/proxy rewriting responses)."],"exampleFix":"// before: ignoring mismatch\ninstall_community_theme(&state_dir, version_id).await?;\n// after: catch and surface clearly\nmatch install_community_theme(&state_dir, version_id).await {\n    Err(e) if e.to_string().contains(\"SHA-256\") => {\n        eprintln!(\"theme package failed integrity check; refusing install\");\n        Err(e)\n    }\n    other => other,\n}","handlingStrategy":"try-catch","validationCode":"// verify the hash yourself against the review metadata before trusting any theme\nlet meta: DreamSkinCommunityTheme = fetch_metadata(version_id).await?;\n// meta.package_sha256 should be a 64-char hex string; refuse otherwise\nif meta.package_sha256.len() != 64 { return Err(\"missing review checksum\".into()); }","typeGuard":null,"tryCatchPattern":"match install_community_theme(&state_dir, version_id).await {\n    Err(e) if e.to_string().contains(\"SHA-256\") => {\n        // never retry blindly more than once; treat persistent mismatch as tampering and stop\n    }\n    other => other?,\n}","preventionTips":["Never bypass or work around checksum failures — the package is not the reviewed artifact.","Retry at most once; a persistent mismatch means server-side substitution or tampering.","Download from trusted networks to rule out MITM/proxy response rewriting.","Cross-check package_sha256 with the theme author when possible."],"tags":["security","checksum","integrity-check","download","rust"],"backgroundTag":"checksum-mismatch","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"}