Skip to content

@stagepass/cli 2.4.1

Choose a tag to compare

@arobertherz arobertherz released this 13 Nov 08:23
· 101 commits to master since this release
23d0814

CLI security patch

Published on npm as @stagepass/cli@2.4.1 on 13 November 2026 at 09:19 Europe/Berlin. Source tag cli-v2.4.1 → 23d081481ff8eb17cfcb0387dc262a97f64df66d. npm package shasum 283e2a96972958a692adbf3eca701490b3c56dc4, integrity sha512-bMFgvimkApM5JmApheLc/1TTkptflyntAsJqdcQc/jKB1Bdy7LnV5SW7lmEomaDmMiUUxWGiXWYN3KnNRFIeMg==, tarball sha256 ab7462d0235a7ede563fe1150430b4fa3a49e1eb62b433a1349d3e7889231153 (matches the accepted freeze r2). npm dist-tag latest is 2.4.1. next remains 2.3.0-beta.1.

Install or update with npm install -g @stagepass/cli@2.4.1. In a PHP project, run stagepass upgrade. nginx hosts add the snippet below. Projects created with published CLI 2.4.0 also apply the api/action.php remedy below. Loader (2.5.0) and Modules (2.2.2) are separate packages and not part of this release.

Highlights

Security patch on top of 2.4.0. Merged on master as 23d0814 (PR #88) after eb72e0c (PR #87).

  • PHP projects from stagepass new --php ship a web-root .htaccess that denies hidden path segments (HTML5 Boilerplate file_access, with visible files under /.well-known/ left reachable). stagepass build copies that file into dist/ when "php": true and the project has one. It still does not copy .env, .php/.env, or .php/rate-limit/. An existing project .htaccess is not replaced. A dist/.htaccess stays when the project has none. A symlink .htaccess is not copied. Published CLI 2.4.0 does not include this file.
  • nginx does not read .htaccess. In the server block, before location ~ \.php$:
location ~* /\.(?!well-known\/) {
    deny all;
}

If this location comes later, /.php/config.php can be passed to php-fpm.

  • stagepass upgrade writes that same .htaccess when stagepass.json has "php": true and the project root has no .htaccess. The bytes match stagepass new --php. An existing .htaccess is never overwritten. If the file has no RewriteRule "(^|/)\." - [F] line, upgrade prints a hint (https://stagepass.one/docs/php/ and api/README.md) and still exits 0. A symlink or directory named .htaccess is left in place. Projects without "php": true are unchanged. --dry-run writes nothing. Published CLI 2.4.0 does not write this file.
  • PHP comments and the starter README no longer say .php/ sits outside the public root. The document root is the folder that contains api/ (the project root locally, dist/ after stagepass build). load_config() reads .env in that folder and .php/.env. It does not read a file named api/.env.
  • OPTIONS preflight on a 2.4.1 api/action.php removes X-Powered-By before the 204 response. header_remove previously ran only in respond(), which that path does not call. The new lines, after the origin check and before http_response_code(204), are:
    if (!headers_sent()) {
        header_remove('X-Powered-By');
    }

Notes for upgraders

  • Projects created with published CLI 2.4.0 keep api/action.php from 2.4.0. stagepass upgrade does not replace PHP sources. An allowed OPTIONS preflight is still HTTP 204 and still sends X-Powered-By: PHP/8.2.35 (measured on the upgrade fixture). GET ping already omits the header, because respond() calls header_remove.
  • Remedy, verified 13 November 2026 on php:8.2-apache (AllowOverride All, a2enmod rewrite), Origin https://your-project.sp:
    • Insert the three lines above into the 2.4.0 OPTIONS branch (same lines, same place, as the 2.4.1 template, lines 43-45). OPTIONS is then 204 without X-Powered-By. ping stays 200.
    • Or set expose_php = Off in php.ini (or a file in the PHP scan directory). expose_php is PHP_INI_SYSTEM (access bitmask 4). OPTIONS and GET then omit X-Powered-By, including a PHP file that never calls header_remove.
    • php_flag expose_php off in .htaccess does not change it. In the same file, php_flag display_errors off does apply (display_errors is PHP_INI_ALL). ini_set('expose_php', '0') returns false and leaves the value On. OPTIONS still sends X-Powered-By.
  • Rate limiting is unchanged and is documented only. rate_limit_allows() is meant to be fail-open (a failed flock or a thrown limiter error lets the request through). A rate-limit directory or file that cannot be written can instead end in HTTP 500, because the PHP warning is turned into an exception before that handling (measured with a read-only mount). client_ip() uses only REMOTE_ADDR. X-Forwarded-For is not trusted without a proxy allowlist. Behind a reverse proxy every visitor can share one counter. A fix is planned for a later patch. Still open: sgt7wKlT.

Full list: CHANGELOG.md section [2.4.1].

Upgrade

npm install -g @stagepass/cli@2.4.1

Then, in each PHP project ("php": true in stagepass.json):

stagepass upgrade

That writes a missing web-root .htaccess and can replace an unmodified scripts/build.mjs. It does not replace api/action.php. Apply the OPTIONS remedy above on projects created with 2.4.0. nginx administrators add the snippet before location ~ \.php$. Rebuild with stagepass build so dist/ receives the .htaccess. .env, .php/.env, and .php/rate-limit/ are still not copied.

Verification

  • Docker Node 22 and Node 24 on the release tree: CLI 747 passed (1 skipped), loader 198, modules 54, packed smoke passed.

  • Docker deny tests, 13 November 2026, 01:02 Europe/Berlin, php:8.2-apache and nginx 1.27 with php:8.2-fpm. Fresh 2.4.1 scaffold: /.env, /.php/.env, /.php/config.php, /.htaccess, /api/.env.example, /.git/HEAD HTTP 403 with no secret leak; /api/action.php?action=ping HTTP 200, {"status":"success","data":{"pong":true},"message":null}; /.well-known/test.txt HTTP 200, body well-known-ok; OPTIONS /api/action.php HTTP 204 with no X-Powered-By. Same path results on nginx.

  • The same deny run on a project created with published CLI 2.4.0 and then upgraded with 2.4.1: path probes passed, and OPTIONS stayed HTTP 204 with X-Powered-By: PHP/8.2.35. That is the remainder above.

  • Remedy retest, 13 November 2026, 03:31 Europe/Berlin: header lines and expose_php = Off both clear the header; .htaccess php_flag and ini_set do not.

  • macOS smoke test, 13 November 2026, 01:07 to 01:11 Europe/Berlin: new --php, build, dev, watch with the local .sp API (ping 200, preflight 204 without X-Powered-By), upgrade of a 2.4.0 PHP project, and doctor all passed.

  • After publish, 13 November 2026, 09:21 to 09:22 Europe/Berlin: clean Docker Node 22 npm i -g @stagepass/cli@latest installed 2.4.1 and stagepass --version printed 2.4.1. stagepass new is refused in Linux Docker ("Stagepass CLI supports macOS only"). Isolated native install on Cerebro: stagepass new testht --php --no-link --yes --no-install --no-git wrote the web-root .htaccess; after npm install and stagepass build, dist/.htaccess was byte-identical (sha256 ccddae64b7cd82b82c6f74f8f7750a6aa07929ad251c2e6dd39794526ff278dc). The registry tarball sha256 matches freeze r2.