{"record":{"id":"ce6c1055d02cd949","repo":"BigPizzaV3/CodexPlusPlus","slug":"error-ce6c10","errorCode":null,"errorMessage":"主题市场资源地址越界","messagePattern":"主题市场资源地址越界","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin_market.rs","lineNumber":338,"sourceCode":"    let bytes = serde_json::to_vec_pretty(&records)?;\n    crate::settings::atomic_write(&state_dir.join(MARKET_INSTALLS_FILE), &bytes)\n}\n\nfn market_download_path(state_dir: &Path, id: &str, extension: &str) -> anyhow::Result<PathBuf> {\n    if !valid_theme_id(id) || !matches!(extension, \"png\" | \"jpg\" | \"gif\" | \"bmp\" | \"webp\") {\n        bail!(\"无效的市场主题下载文件名\");\n    }\n    Ok(state_dir\n        .join(\"dream-skin/market/downloads\")\n        .join(format!(\"{id}.{extension}\")))\n}\n\nfn market_asset_url(base_url: &str, relative: &str) -> anyhow::Result<String> {\n    validate_market_path(relative)?;\n    let base = reqwest::Url::parse(base_url).context(\"主题市场基础地址无效\")?;\n    let joined = base.join(relative).context(\"主题市场资源地址无效\")?;\n    if joined.scheme() != base.scheme() || joined.host_str() != base.host_str() {\n        bail!(\"主题市场资源地址越界\");\n    }\n    Ok(joined.to_string())\n}\n\nfn validate_market_path(value: &str) -> anyhow::Result<()> {\n    if value.is_empty()\n        || value.len() > 256\n        || value.starts_with('/')\n        || value.contains('\\\\')\n        || value.contains(['?', '#', '\\0'])\n    {\n        bail!(\"无效的主题市场相对路径\");\n    }\n    for segment in value.split('/') {\n        if segment.is_empty()\n            || matches!(segment, \".\" | \"..\")\n            || !segment\n                .bytes()","sourceCodeStart":320,"sourceCodeEnd":356,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin_market.rs#L320-L356","documentation":"`market_asset_url` joins a manifest-relative asset path onto the market base URL and then verifies the result stayed on the same origin: both scheme and host must match the base. If the join escapes the base (different scheme or host), the library rejects it to prevent a malicious manifest from making the app download from arbitrary third-party servers.","triggerScenarios":"`install_market_theme_from_base`, `enrich_market_manifest`, or `validate_manifest` calls `market_asset_url` with a relative path that resolves to a different origin than the base — e.g. an absolute URL like `https://evil.example/x.png` used as `relative`, or a protocol-relative `//evil.example/x.png`, where `Url::join` adopts the new host/scheme.","commonSituations":"A compromised or malicious market manifest embedding absolute asset URLs pointing off-market; CDN rewrites where assets moved to a different domain than the manifest base; authors pasting full URLs into fields meant to hold relative paths.","solutions":["Fix the manifest so asset paths (`theme`, `image`, `preview`) are truly relative paths on the same host as the market base URL (e.g. `assets/skin-v1.png`).","If assets legitimately moved to a CDN, change the market `base_url` itself to the CDN origin so the join stays same-origin.","Remove any leading `//`, absolute `http(s)://`, or scheme tricks from the relative path fields.","Refresh the cached market manifest after the server-side manifest is corrected."],"exampleFix":"// manifest theme entry (base https://market.example.com/v1/)\n// before\n\"image\": \"https://cdn.other.example/skin.png\"\n// after\n\"image\": \"assets/skin.png\"","handlingStrategy":"validation","validationCode":"fn stays_on_origin(base: &str, rel: &str) -> bool {\n    let (b, j) = match (reqwest::Url::parse(base), reqwest::Url::parse(base).ok()?.join(rel)) {\n        (Ok(b), Ok(j)) => (b, j),\n        _ => return false,\n    };\n    j.scheme() == b.scheme() && j.host_str() == b.host_str()\n}","typeGuard":"fn is_relative_path(p: &str) -> bool {\n    !p.starts_with(\"http://\") && !p.starts_with(\"https://\") && !p.starts_with(\"//\")\n}","tryCatchPattern":"match install_market_theme_from_base(...).await {\n    Err(e) if e.to_string().contains(\"资源地址越界\") => {\n        eprintln!(\"manifest tried to fetch assets off-origin; refusing download\");\n    }\n    other => other?,\n}","preventionTips":["Only use truly relative paths in manifest asset fields (no scheme or leading //)","Keep assets on the same host as the market base URL; if a CDN is required, move the base_url to it","Validate manifests for absolute asset URLs before publishing","Treat off-origin attempts as a compromised-manifest indicator and investigate the market server"],"tags":["security","url","ssrf","manifest","path-traversal"],"backgroundTag":"path-traversal-blocked","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"}