Visitar URL original
[question] Why does simpleSitemapAndIndex destinationDir option now need to be a relative path? · Issue #478 · ekalinin/sitemap.js · GitHub
Skip to content

[question] Why does simpleSitemapAndIndex destinationDir option now need to be a relative path? #478

Open

Description

@timbowhite

8.0.3 — Security Patch
BB-04: Reject absolute destinationDir paths in simpleSitemapAndIndex to prevent arbitrary file writes — passing an absolute path (e.g. /tmp/sitemaps) now throws immediately with a descriptive error

This recently bit me.

I don't understand why this option cannot be an absolute path.

EDIT: I'm using simpleSitemapAndIndex on a server, not in a browser.

@maru1009

Activity

  1. maru1009 commented on Mar 5, 2026

    @maru1009

    It’s about safe defaults for server apps where destinationDir can accidentally come from user input. Allowing absolute paths made it possible to turn that into an arbitrary write location.

    simpleSitemapAndIndex is now intentionally opinionated: relative paths only. If your server setup is trusted and you need absolute paths, us SitemapAndIndexStream (lower-level API) and enforce your own allowlisted base directory.

    Also, good catch: some docs still mention absolute paths; that should be updated for consistency.

  2. timbowhite commented on Mar 5, 2026

    @timbowhite
    Author

    destinationDir can accidentally come from user input

    IMO this is extreme edge-case usage and is causing a big trade-off on this module's usability.

    simpleSitemapAndIndex is now intentionally opinionated: relative paths only

    And yet this does not prevent writing to any arbitrary subdirectory of the current working directory, no?

    Also, good catch: some docs still mention absolute paths; that should be updated for consistency.

    Which docs exactly mention absolute paths?

    Also, @maru1009 are you a real human being?

  3. maru1009 commented on Mar 6, 2026

    @maru1009

    IMO this is extreme edge-case usage and is causing a big trade-off on this module's usability.

    The is safe-default tradeoff: prioritize reducing dangerous outcomes over convenience in the high-level helper API.

    And yet this does not prevent writing to any arbitrary subdirectory of the current working directory, no?

    Yes. But it reduces any writable absolute path on host to paths under the process working directory

    Which docs exactly mention absolute paths?

    api.md more specifically line 166 and 214.

    And for the last question. It is up to you. :)

  4. timbowhite commented on Mar 6, 2026

    @timbowhite
    Author

    OK.

    @derduher Please don't include breaking changes in patch releases (i.e. 8.0.2 -> 8.0.3 is a breaking change).

  5. derduher commented on Mar 18, 2026

    @derduher
    Collaborator

    @timbowhite apologies. I had some shaky reason to think it was ok to change to relative . On the balance I thought it safer than allowing the vulnerability to remain.

    IMO this is extreme edge-case usage and is causing a big trade-off on this module's usability.
    I may spend some more time on this one. Otherwise PRs and suggestions are open

  6. robogeek commented on Jul 18, 2026

    @robogeek

    This bit me today. The double problem is that the validation function also rejects path traversal.

    In the meantime this documentation page doesn't reflect reality: https://github.com/ekalinin/sitemap.js/blob/c7f6ac1f6dd1d6c9e9ba03eb3c72e683636b4bac/api.md#simplesitemapandindex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions