• Web server serves a sibling of the web root whose name begins with the

    From Rob Swindell@1:103/705 to GitLab issue in main/sbbs on Wed Nov 18 15:20:23 2026
    open https://gitlab.synchro.net/main/sbbs/-/work_items/1355

    The web server's test that a request stays inside the web root is a
    prefix comparison with no path-separator check, so a directory beside
    the root whose name begins with the root's name is served.

    **Reproduced** on Linux (current master, scratch server on loopback):
    with `RootDirectory` = `<dir>/root` and a sibling `<dir>/root2`
    containing `sib.txt`, each of these returns 200 and the file:

    ```
    GET /../root2/sib.txt
    GET /%2e%2e/root2/sib.txt
    GET /plain/../../root2/sib.txt
    ```

    A request for a directory outside the root with an unrelated name (`/../apps/secret.txt`) is correctly refused with 400 and logged as
    "outside of web root".

    So the exposure needs a sibling such as `html2`, `html.bak` or
    `html-old` next to a root named `html`. Nothing else was reachable: `webctrl.ini` access rules still applied to every path tried, and
    `webctrl.ini` itself was not served.

    **Cause** (`src/sbbs3/websrvr.cpp`): the containment test is
    `strnicmp(path, root_dir, strlen(root_dir))`. It should also require
    that the path ends there or continues with a path separator. The coming
    `[dir]` section of `web_alias.ini` has a helper that does this for its directories.

    **Related hardening, not reproduced:**

    1. `is_legal_path()` refuses nothing on non-Windows builds, so `..` is
    accepted in request paths there and the root test above is the only
    containment.
    2. The root test is case-insensitive on every platform; on a
    case-sensitive file system a sibling differing only in case would
    pass.
    3. The "never serve webctrl.ini" test is a case-sensitive `strcmp`.
    On Linux a differently-cased name is simply another file; on
    Windows `/WEBCTRL.INI` may be served. Not tested on Windows.
    4. The CGI `PATH_TRANSLATED` value is built with an unbounded
    `sprintf` (CGI is disabled by default with `NO_CGI`). From reading
    the source only.

    -- *Authored by Claude (Claude Code), on behalf of @rswindell*
    --- SBBSecho 3.38-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)