Skip to content

-sandbox rejects files nested more than one directory deep #230

Backlog

Description

@hakarrr

simplehttpserver version:

main branch (8b81921)

Current Behavior:

With -sandbox, any file more than one directory below the served root is rejected with "invalid file". In pkg/httpserver/sandboxfs.go the containment check matches the absolute path against a glob built from the root, and * does not cross path separators, so root/a/b.txt fails while root/b.txt works.

Expected Behavior:

Files anywhere under the sandbox root are served. Paths outside the root stay rejected.

Steps To Reproduce:

  1. mkdir -p root/a/b && echo hi > root/a/b/f.txt
  2. simplehttpserver -path root -sandbox
  3. curl localhost:8000/a/b/f.txt returns "invalid file" instead of the content

Anything else:

A fail-first test in pkg/httpserver/sandboxfs_test.go covers nested files and outside-root rejection. Checking containment with filepath.Rel fixes it. I have a patch ready.

Activity

  1. added
    Type: Bug
    on Dec 1, 2026
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

    Type: Bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions