Skip to content

fix(sitemap): cross-host index children collapse onto one host and siblings are dropped as a cycle #398

Closed

Description

@Goldziher

A sitemap index that lists children on other hosts silently returns none of their URLs, and logs the loss as a cycle.

rewrite_url_host (crates/crawlberg/src/normalize.rs) discards the child's host, port and userinfo whenever it differs from the base, keeping only path and query:

if let Ok(parsed) = Url::parse(url_str)
    && parsed.host_str() != base.host_str()
{
    let mut resolved = base.clone();
    resolved.set_path(parsed.path());
    resolved.set_query(parsed.query());
    return resolved.to_string();
}

resolve_child_sitemap_url (sitemap.rs) routes every absolute child through it, so with base https://example.com/sitemap-index.xml:

https://blog.example.com/sitemap.xml  ->  https://example.com/sitemap.xml
https://shop.example.com/sitemap.xml  ->  https://example.com/sitemap.xml
https://docs.example.com/sitemap.xml  ->  https://example.com/sitemap.xml

All three collapse to one key. The first is fetched; the others hit if !visited.insert(resolved.clone()) (sitemap.rs:467) and are dropped with skipping sitemap index tier: cycle detected (already visited) (:470).

Result: every URL those sibling sitemaps carried is never returned and never crawled, map() comes back empty or near-empty, and the log says "cycle detected" — which reads as correct behaviour. Nothing reports a problem.

This is pre-existing, not introduced by the open sitemap stack, but three things make it urgent now:

Decide the semantics rather than ratifying them by test. Either cross-host child sitemaps are allowed, in which case drop rewrite_url_host from resolve_child_sitemap_url and let the SSRF check gate the fetch; or they are not, in which case return None and log the refusal. Rewriting onto another host is the one option that both loses the siblings and issues a request the site never advertised.

Activity

  1. added theissue type on Sep 27, 2026
  2. added
    P1Operator-facing: wrong output on a common path, or a secret reaching logs or errors
    bugSomething isn't working
    correctnessProduces wrong output or wrong behaviour
    on Sep 27, 2026
  3. added
    operatorAn operator would hit this in normal use; ranks above dev, test and edge cases
    P2Wrong behaviour in an edge case
    and removed
    P1Operator-facing: wrong output on a common path, or a secret reaching logs or errors
    on Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2Wrong behaviour in an edge casebugSomething isn't workingcorrectnessProduces wrong output or wrong behaviouroperatorAn operator would hit this in normal use; ranks above dev, test and edge cases

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions