Repository navigation
@stagepass/cli 2.4.1
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 --phpship a web-root.htaccessthat denies hidden path segments (HTML5 Boilerplatefile_access, with visible files under/.well-known/left reachable).stagepass buildcopies that file intodist/when"php": trueand the project has one. It still does not copy.env,.php/.env, or.php/rate-limit/. An existing project.htaccessis not replaced. Adist/.htaccessstays when the project has none. A symlink.htaccessis not copied. Published CLI 2.4.0 does not include this file. - nginx does not read
.htaccess. In the server block, beforelocation ~ \.php$:
location ~* /\.(?!well-known\/) {
deny all;
}If this location comes later, /.php/config.php can be passed to php-fpm.
stagepass upgradewrites that same.htaccesswhenstagepass.jsonhas"php": trueand the project root has no.htaccess. The bytes matchstagepass new --php. An existing.htaccessis never overwritten. If the file has noRewriteRule "(^|/)\." - [F]line, upgrade prints a hint (https://stagepass.one/docs/php/ andapi/README.md) and still exits 0. A symlink or directory named.htaccessis left in place. Projects without"php": trueare unchanged.--dry-runwrites 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 containsapi/(the project root locally,dist/afterstagepass build).load_config()reads.envin that folder and.php/.env. It does not read a file namedapi/.env. - OPTIONS preflight on a 2.4.1
api/action.phpremovesX-Powered-Bybefore the 204 response.header_removepreviously ran only inrespond(), which that path does not call. The new lines, after the origin check and beforehttp_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.phpfrom 2.4.0.stagepass upgradedoes not replace PHP sources. An allowed OPTIONS preflight is still HTTP 204 and still sendsX-Powered-By: PHP/8.2.35(measured on the upgrade fixture). GETpingalready omits the header, becauserespond()callsheader_remove. - Remedy, verified 13 November 2026 on php:8.2-apache (
AllowOverride All,a2enmod rewrite), Originhttps://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.pingstays 200. - Or set
expose_php = Offin php.ini (or a file in the PHP scan directory).expose_phpisPHP_INI_SYSTEM(access bitmask 4). OPTIONS and GET then omitX-Powered-By, including a PHP file that never callsheader_remove. php_flag expose_php offin.htaccessdoes not change it. In the same file,php_flag display_errors offdoes apply (display_errorsisPHP_INI_ALL).ini_set('expose_php', '0')returns false and leaves the value On. OPTIONS still sendsX-Powered-By.
- 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
- Rate limiting is unchanged and is documented only.
rate_limit_allows()is meant to be fail-open (a failedflockor 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 onlyREMOTE_ADDR.X-Forwarded-Foris 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.1Then, in each PHP project ("php": true in stagepass.json):
stagepass upgradeThat 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/HEADHTTP 403 with no secret leak;/api/action.php?action=pingHTTP 200,{"status":"success","data":{"pong":true},"message":null};/.well-known/test.txtHTTP 200, bodywell-known-ok; OPTIONS/api/action.phpHTTP 204 with noX-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 = Offboth clear the header;.htaccessphp_flagandini_setdo not. -
macOS smoke test, 13 November 2026, 01:07 to 01:11 Europe/Berlin:
new --php,build,dev,watchwith the local.spAPI (ping 200, preflight 204 withoutX-Powered-By),upgradeof a 2.4.0 PHP project, anddoctorall passed. -
After publish, 13 November 2026, 09:21 to 09:22 Europe/Berlin: clean Docker Node 22
npm i -g @stagepass/cli@latestinstalled 2.4.1 andstagepass --versionprinted 2.4.1.stagepass newis refused in Linux Docker ("Stagepass CLI supports macOS only"). Isolated native install on Cerebro:stagepass new testht --php --no-link --yes --no-install --no-gitwrote the web-root.htaccess; afternpm installandstagepass build,dist/.htaccesswas byte-identical (sha256ccddae64b7cd82b82c6f74f8f7750a6aa07929ad251c2e6dd39794526ff278dc). The registry tarball sha256 matches freeze r2.