BigPizzaV3/CodexPlusPlus · error
主题市场资源地址越界
Error message
主题市场资源地址越界
What it means
`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.
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.
Example fix
// manifest theme entry (base https://market.example.com/v1/) // before "image": "https://cdn.other.example/skin.png" // after "image": "assets/skin.png"
Defensive patterns
Strategy: validation
Validate before calling
fn stays_on_origin(base: &str, rel: &str) -> bool {
let (b, j) = match (reqwest::Url::parse(base), reqwest::Url::parse(base).ok()?.join(rel)) {
(Ok(b), Ok(j)) => (b, j),
_ => return false,
};
j.scheme() == b.scheme() && j.host_str() == b.host_str()
} Type guard
fn is_relative_path(p: &str) -> bool {
!p.starts_with("http://") && !p.starts_with("https://") && !p.starts_with("//")
} Try / catch
match install_market_theme_from_base(...).await {
Err(e) if e.to_string().contains("资源地址越界") => {
eprintln!("manifest tried to fetch assets off-origin; refusing download");
}
other => other?,
} Prevention
- 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
When it happens
Trigger: `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.
Common situations: 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.
Understand the failure class
Background: Path traversal blocked: "path escapes the workspace" and "outside site root" errors when a path will not stay inside its allowed directory — this error's family across 26 libraries.
Related errors
- Base URL 不得指向本机或私有网络
- API 地址须使用 HTTPS,且不含账号、密码、查询参数或片段
- API 地址须使用 HTTPS,且不含账号、密码、查询参数或片段
- Base URL 不得包含用户名或密码
- 仅支持 Codex++ 分享站点链接
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/ce6c1055d02cd949.
Report an issue: GitHub.
Appendix: source
Thrown at crates/codex-plus-core/src/dream_skin_market.rs:338
let bytes = serde_json::to_vec_pretty(&records)?;
crate::settings::atomic_write(&state_dir.join(MARKET_INSTALLS_FILE), &bytes)
}
fn market_download_path(state_dir: &Path, id: &str, extension: &str) -> anyhow::Result<PathBuf> {
if !valid_theme_id(id) || !matches!(extension, "png" | "jpg" | "gif" | "bmp" | "webp") {
bail!("无效的市场主题下载文件名");
}
Ok(state_dir
.join("dream-skin/market/downloads")
.join(format!("{id}.{extension}")))
}
fn market_asset_url(base_url: &str, relative: &str) -> anyhow::Result<String> {
validate_market_path(relative)?;
let base = reqwest::Url::parse(base_url).context("主题市场基础地址无效")?;
let joined = base.join(relative).context("主题市场资源地址无效")?;
if joined.scheme() != base.scheme() || joined.host_str() != base.host_str() {
bail!("主题市场资源地址越界");
}
Ok(joined.to_string())
}
fn validate_market_path(value: &str) -> anyhow::Result<()> {
if value.is_empty()
|| value.len() > 256
|| value.starts_with('/')
|| value.contains('\\')
|| value.contains(['?', '#', '\0'])
{
bail!("无效的主题市场相对路径");
}
for segment in value.split('/') {
if segment.is_empty()
|| matches!(segment, "." | "..")
|| !segment
.bytes()View on GitHub (pinned to b1ed92e5e4)