• docs/v322_new.md src/sbbs3/websrvr.cpp

    From Rob Swindell (on Debian Linux)@VERT to Git commit to main/sbbs/master on Fri Jul 31 21:43:31 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/72303693ef1b8dc2c11ff006
    Modified Files:
    docs/v322_new.md src/sbbs3/websrvr.cpp
    Log Message:
    websrvr: enforce download credits for unauthenticated file requests

    An anonymous request through the file-area virtual path
    (FileVPathPrefix) was authorized by user_can_download() alone, with no
    credit check, so every file in a directory with empty ARS downloaded
    free of charge regardless of its cost. The FTP server applies the
    credit gate to anonymous users, and issue #446 was closed with that
    being the intended policy.

    Both authorization paths now share check_file_download(), which applies
    the credit gate before the ARS check. Putting the two callers on one
    predicate is the point of the helper: the bypass existed because the
    anonymous branch and the authenticated one had drifted apart.

    The gate measures cost against user_available_credits() rather than
    user.cdt, so a user's free credits now count toward a download, as they
    already do on the Terminal and FTP servers, and as subtract_cdt()
    already assumed when charging: it spends free credits first.

    A refused anonymous request is logged at LOG_DEBUG. An insufficient
    credit refusal now reports NotEnoughCredits; both this and the existing authenticated failure log previously reported CantDownloadFromDir for
    it, naming the wrong cause.

    Fixes #1192

    Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Rob Swindell (on Debian Linux)@VERT to Git commit to main/sbbs/master on Sat Aug 1 20:33:36 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/4de1032086f038890a75559e
    Modified Files:
    docs/v322_new.md src/sbbs3/websrvr.cpp
    Log Message:
    websrvr: load a file's cost before checking download credits (#1192)

    The credit gate added in 72303693ef (2026-07-31) compared against a
    cost that was always zero. resolve_vpath() loaded the file record at file_detail_index, and smb_getfile() skips smb_getmsghdr() entirely at
    that detail level, while cost is only ever set from the SMB_COST header
    field. Every comparison against it therefore passed: costed files
    downloaded free of charge for authenticated users as well as anonymous
    ones, while user_downloaded_file() still billed the account afterward
    (it reloads the record itself at file_detail_normal), so a user could
    go credit-negative.

    Read the header record when the directory's files can cost something. A
    free directory has none to report, since loadfile() zeroes the cost and download_is_free() short-circuits on the same DIR_FREE flag before any
    credit comparison, so the index record alone still suffices there and loadfile() is not asked to open the base twice.

    Verified against a live file base: an unauthenticated request for a 2,639,434-credit file is refused with 401, a zero-cost file in the same non-free directory returns 200, and a file in a free directory
    transfers in full.

    Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Rob Swindell (on Debian Linux)@VERT to Git commit to main/sbbs/master on Wed Sep 30 19:08:47 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/aadcf82e0660f29d0b7afc10
    Modified Files:
    docs/v322_new.md src/sbbs3/websrvr.cpp
    Log Message:
    Web Server: log script errors, don't send them to the client

    Fixes #1203

    js_ErrorReporter() wrote every uncaught JavaScript error, with the script's absolute path and line number, into the HTTP response body as well as the
    log, and the request still completed with a 200 and the page's content
    type. That disclosed the server's layout to any visitor who could make a
    script throw, and any error message that interpolated request data (a query parameter, header or cookie) was a reflected script-injection vector in the BBS's own origin.

    Log the error only. A reported error (a warning does not count, nor does exit(), which reports nothing) marks the session, and exec_ssjs() then
    fails the request instead of sending what the script produced before
    failing, so the normal 500 error path answers it. An error after the
    script has already sent its headers can only be logged, as before.

    Verified on a scratch web server: a page that throws with a query
    parameter in the message returns 500 with an empty body and the error is
    in the log; a page that ends with exit() still returns 200.

    Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Rob Swindell (on Debian Linux)@VERT to Git commit to main/sbbs/master on Fri Nov 20 15:25:23 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/30e82b9600a154489f0fef85
    Modified Files:
    docs/v322_new.md src/sbbs3/websrvr.cpp
    Log Message:
    websrvr: file-area downloads are sent sandboxed and not sniffed

    A file requested from a file area (FileVPathPrefix) was sent with a Content-Type taken from its extension and nothing else. An uploaded
    .html or .svg file, opened through its link, was a page of whatever
    host name the link used: script in it ran with that site's origin and
    could act as the signed-in visitor there.

    Every file-area download now carries

    X-Content-Type-Options: nosniff
    Content-Security-Policy: sandbox

    The sandbox makes the browser treat the file as a document of its own:
    no script, and no access to the site's cookies, storage or pages. The
    file still displays. PDFs get nosniff only, because a browser's built-in
    PDF viewer does not start inside a sandbox. Listings (the index script),
    the rest of the web root and scripts are unchanged.

    Checked on a scratch web server on loopback with an .html, .svg, .pdf
    and .txt file in a file area: without the change none had either
    header; with it the first, second and fourth have both and the PDF has
    nosniff. In headless Firefox the test page's script did not run and the document's origin was "null". Built with GCC only.

    Fixes #1363

    Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Rob Swindell (on Debian Linux)@VERT to Git commit to main/sbbs/master on Sat Nov 21 19:18:28 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/380c33adbf3f1a62e24ab3b9
    Modified Files:
    docs/v322_new.md src/sbbs3/websrvr.cpp
    Log Message:
    Web Server: refuse HTTP authentication for a deleted or inactive account

    check_ars() looked up the user named in an HTTP Basic or Digest
    Authorization header and checked the password, but never the account's
    status, so the right password logged in a deleted or inactive account.
    An inactive account keeps its name, so it could log in by name; a
    deleted one has its name removed from the name index, but with logins by
    user number allowed (LOGIN_USERNUM) it could still log in by number.
    Every other login path refuses such an account: the terminal server,
    FTP, POP3, SMTP AUTH, and the JavaScript login() of the web server and Services.

    Now such a login is refused like one with an unknown user, logged as
    !DELETED or INACTIVE user, and counted as a failed login attempt against
    the request's client. The password recorded with a failed HTTP
    authentication (the Basic password, or "<digest>") comes from one
    helper.

    Tested on Linux against an isolated test server: HTTP Basic logins with
    the right password for a deleted account and for an inactive one were
    refused (401) and logged, and an active user's login still succeeded.

    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Rob Swindell (on Debian Linux)@VERT to Git commit to main/sbbs/master on Sat Nov 21 23:54:10 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/c2cb2a487863524951f4e2ef
    Modified Files:
    docs/v322_new.md src/sbbs3/websrvr.cpp
    Log Message:
    Web Server: exempt ipfilter_exempt.cfg clients from the connection limiter

    The connection rate limiter (MaxConnectsPerPeriod, SCFG Limit Rate of Connections), applied when a connection is accepted, did not check ipfilter_exempt.cfg, unlike the request rate limiter and the concurrent-connection limit. Behind a reverse proxy that passes the
    client's address in a request header, every connection comes from the
    proxy, so once the proxy exceeded the limit, all visitors were refused
    for the rest of the period, even with the proxy listed as exempt. The
    limiter's auto-filter already skipped an exempt address (filter_ip()
    checks the list), but the connection was still refused.

    Tested on Linux against an isolated Web Server with a limit of 3
    connections per 10 minutes: five connections from the exempt loopback
    proxy were all served; with loopback not exempt, the fourth was refused.

    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Rob Swindell (on Debian Linux)@VERT to Git commit to main/sbbs/master on Tue Dec 1 01:01:49 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/10b6bcb3f93445ceacd45c6c
    Modified Files:
    docs/v322_new.md src/sbbs3/websrvr.cpp
    Log Message:
    Web Server: confine requests to the web root itself, not name-prefix siblings

    check_request() tested that a request stayed inside the web root with strnicmp(path, root_dir, strlen(root_dir)), which also accepts a
    directory beside the root whose name begins with the root's name: with
    a root of .../html, /../html2/file, /%2e%2e/html2/file and /dir/../../html2/file all served files from .../html2 (or html.bak,
    html-old, ...). The root is now checked with path_in_dir() (the path is
    the root or continues with a path separator), as [dir] aliases already
    were, which also makes the test case-sensitive.

    Also:
    - the "never serve webctrl.ini" test is case-insensitive on Windows,
    whose file names are, so /WEBCTRL.INI is refused there too
    - the CGI PATH_TRANSLATED value is built with a bounded SAFEPRINTF2
    instead of sprintf

    Tested with a web server on loopback (root .../root, sibling
    .../root2): the three requests above returned 200 and the sibling's
    file before, 400 ("outside of web root") now; /index.html, files in sub directories, /webctrl.ini (403) and /../unrelated/file (400) are
    unchanged. The Windows-only branch was not compiled.

    Fixes #1355

    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Rob Swindell (on Debian Linux)@VERT to Git commit to main/sbbs/master on Tue Dec 1 23:05:16 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/0ca63e88eb2ca09c16c4a2ed
    Modified Files:
    docs/v322_new.md src/sbbs3/websrvr.cpp
    Log Message:
    Web Server: send complete HTTP responses when refusing a connection

    A client turned away at accept time (too many concurrent connections
    from one IP, or the server at its client limit) was sent the bare
    error_429 / error_503 strings. Those are status reasons, not
    responses: the client received "429 Too Many Requests" with no HTTP
    version, line terminator, or headers, and a 503 status line with no
    HTTP version. Strict clients reject both; http.js's ReadStatus()
    throws "Unable to parse status line", as the PODCAST event logged
    when fetching a URL that resolves back to this server.

    error_503 also carried embedded "Connection"/"Content-Length" headers
    and a blank line. Passed to send_error() on the TLS over-limit path,
    that ended the header block early, so the headers send_headers()
    appended landed in what the client read as the body.

    error_503 is now a bare reason string like the other error_*
    constants, and the accept-time paths send their own complete canned
    responses (accept_429, accept_503) sized with sizeof rather than
    lazily cached strlen() results.

    Fixes #1443

    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Rob Swindell (on Debian Linux)@VERT to Git commit to main/sbbs/master on Tue Dec 1 23:05:16 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/cee3e70a36c267972e53e96a
    Modified Files:
    docs/v322_new.md src/sbbs3/websrvr.cpp
    Log Message:
    Web Server: don't send Content-Length: 0 before a built-in error page

    When send_error() finds no error page file for the status code, it
    sends a built-in HTML page instead. But send_headers() had already
    stat()ed the missing file and, as for any reply with no body, sent "Content-Length: 0" and no Content-Type. Clients that honor the length discarded the page (curl downloaded 0 bytes). The stock error
    directories have no 413 or 503 page, so this hit every 413 reply and
    the TLS over-limit 503 on a stock install.

    send_error() now checks for the page before sending the headers and,
    if it's missing, sets req.manual_length so send_headers() sends no Content-Length. send_error() always clears keep_alive, so the reply
    carries "Connection: Close" and the connection's close delimits the
    body (RFC 9112 section 6.3). send_headers() also sends Content-Type (req.mime_type, text/html) in that case; the existing Content-Type
    block can't be used, because it also sends Last-Modified from the
    file's stat data.

    Tested against a loopback web server: a 404 with no page now arrives
    whole (219 bytes, text/html); HEAD still sends no body; a 404 with a
    page still sends its exact Content-Length; the TLS 503 is one valid
    header block followed by the page. Over TLS the server ends these
    replies with a close_notify, so a strict client (Python ssl with suppress_ragged_eofs=False) reads the close-delimited page as complete.

    Fixes #1445

    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Rob Swindell (on Debian Linux)@VERT to Git commit to main/sbbs/master on Tue Dec 1 23:05:16 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/8ca45d70dd9a9e39e33e4fc3
    Modified Files:
    docs/v322_new.md src/sbbs3/websrvr.cpp
    Log Message:
    Web Server: send a failed script's error page as the static file it is

    When a server-side script or CGI program failed, send_error() sent the
    500 page with req.dynamic still set from the request, so
    send_headers() built the reply as dynamic content:

    - no Content-Type (or Last-Modified), even for the stock 500.html;
    - for CGI, no Content-Length either;
    - any headers queued in req.dynamic_heads were sent with the error.
    A CGI program that sent header lines and then stalled past
    MaxCgiInactivity before ending its header block had those lines
    (Set-Cookie: and its Content-Type: text/plain included) sent with
    the HTML error page.

    send_error() now marks the request static around the send_headers()
    call for the error page, when no headers have been sent yet, and
    restores it afterwards so close_request() still sees the request's
    own type (JS garbage collection, chunked-transfer termination). The
    error reply now gets the same headers as any static file: Content-Type, Last-Modified, an exact Content-Length when the page exists, and the
    built-in page's handling when it doesn't. Allow and Accept-Ranges
    follow, as "GET, HEAD, OPTIONS" and "bytes".

    Tested against a loopback web server, before and after: an SSJS
    script that throws, and CGI programs that stall before any output
    and after sending Set-Cookie and Content-Type, now get text/html and Content-Length: 166 with the stock 500.html (text/html and no length
    with no page), and no Set-Cookie. Successful SSJS and CGI replies,
    static files, and the 404 served by 404.ssjs are unchanged.

    Fixes #1447

    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net