Skip to content

Security & Bundle Integrity

Security in PAM has three layers. The runtime ships hardened defaults for everything it controls: client addresses, error output, request limits, metrics, WebSocket origins and the control plane. The installer and self-updater verify every PAM release before it replaces the binary you run. And the build tools (pam build, pam package, pam release) produce bundles with a SHA-256 manifest and checksums you can verify anywhere.

A bundle proves the integrity of the files it records. It does not replace a trusted release channel, secret management or operating-system isolation; you still need those.

These defaults are part of PAM’s security contract. Changing one is a behaviour change listed in the changelog:

  • X-Forwarded-For is honoured only from trustedProxies / PAM_TRUSTED_PROXIES, and the client is the rightmost untrusted entry.
  • The worker /metrics path answers loopback peers only, unless metricsToken or metricsPublic is set.
  • WebSocket upgrades from another site’s page get 403 unless the origin is in websocketOrigins (or corsOrigins).
  • Request bodies held by PHP are bounded per worker (maxInflightBodyBytes).
  • Errors never expose messages or traces unless exposeErrors is enabled; in server mode display_errors is off and log_errors on.
  • The control plane refuses a non-loopback address without PAM_ADMIN_TOKEN or PAM_ADMIN_TOKEN_FILE, and compares tokens in constant time.
  • Runtime directories, hand-off sockets, environment files, dashboards and signing keys must be private to the current user; PAM refuses group- or world-readable ones.

The full table, with the options that change each default, is in Production.

The official installer downloads the release archive and its .sha256 file, requires exactly one lowercase SHA-256 entry for the exact archive name, and compares it with the downloaded bytes before extracting. Extraction refuses symlinks, hard links, devices and any entry that is not a regular file or directory. The new binary must report exactly the requested version before it is activated with an atomic rename.

To pin an archive digest you obtained through an independent channel:

Terminal window
PAM_VERSION=v2.2.27 PAM_EXPECTED_ARCHIVE_SHA256=<sha256> sh install.sh

pam self-update goes further. Official binaries embed the identity of the release-signing key; before running the installer, the updater verifies an Ed25519-signed manifest for the target platform and the authorized archive digest. It never downgrades silently:

Terminal window
pam self-update --check # verify and report a newer authorized release
pam self-update v2.2.27 # install a specific version
pam self-update v2.2.20 --allow-downgrade # an explicit, intentional downgrade

Local builds compiled without a signing identity refuse to self-update.

pam build creates a relocatable directory with your application, its Composer dependencies, the PAM binary and the exact private libphp it was built against:

Terminal window
pam build --entry index.php --output dist
● PRODUCTION BUNDLE READY
────────────────────────────────────────────────────────────
Output /srv/acme/dist
Launch /srv/acme/dist/bin/pam-run
dist/
├── app/ your project files
├── bin/pam the PAM binary
├── bin/pam-run launcher: sets LD_LIBRARY_PATH and runs app/<entry>
├── lib/libphp.so the private PHP runtime
└── manifest.json PAM version, target, entry and a SHA-256 for every file

The manifest lists every file, sorted by path, with its size and digest:

dist/manifest.json
{
"pamVersion": "2.2.27",
"target": "x86_64-linux",
"entry": "index.php",
"phpLibrary": "lib/libphp.so",
"files": [
{
"path": "app/index.php",
"bytes": 372,
"sha256": "ec6f0b93404b8b40d373b5ddc5330f3e15a56222fbf0454c67db1..."
}
]
}

--entry defaults to index.php and --output to dist.

pam build copies the project directory except .git, .pam, .env, node_modules and target. Symlinks that resolve inside the project are followed; symlinks pointing outside it fail the build.

The launcher does not re-hash the bundle on every start, so verify it in your pipeline, after copying and before switching traffic. With jq and sha256sum:

Terminal window
cd dist
jq -r '.files[] | "\(.sha256) \(.path)"' manifest.json | sha256sum --check --quiet && echo "bundle OK"

Any modified file is reported (app/index.php: FAILED) and the command exits non-zero. Then run pam doctor inside the final artifact or image.

pam package builds the bundle and archives it as a versioned, platform-specific tar.gz with a neighbouring .sha256 file:

Terminal window
pam package --output artifacts
Packaged /srv/acme/artifacts/acme-api-1.0.0-linux-x86_64.tar.gz
Checksum /srv/acme/artifacts/acme-api-1.0.0-linux-x86_64.tar.gz.sha256

The archive name comes from the name and version in pam.json. pam package refuses to overwrite an existing archive. Verify it on the receiving host:

Terminal window
sha256sum --check acme-api-1.0.0-linux-x86_64.tar.gz.sha256

Publish checksums through a channel independent of the archive: a checksum downloaded from the same compromised location proves nothing. Native and Desktop projects delegate pam package to their own platform packagers.

pam release runs every local gate in order and stops at the first failure:

Terminal window
pam release --check # gates only, nothing is packaged
pam release # gates, then pam package
Step Command
1 pam doctor --ci
2 pam lint
3 pam test
4 (PAM Native projects) pam sign
5 (without --check) pam package

In a Product workspace, the gate runs doctor, lint and test for the server, native and desktop apps plus the shared contract tests, and a full release also runs pam release:verify on the generated dist/product-release.json.

Run Composer’s advisory audit through PAM’s embedded Composer:

Terminal window
pam composer audit --locked

pam outdated lists direct dependency updates (--all includes transitive ones).

For claims that an exact package installs, upgrades and rolls back on a clean host, PAM uses signed evidence manifests that can be verified offline:

Terminal window
umask 077
openssl rand -base64 32 > evidence.key
pam distribution:sign evidence/draft.json --key evidence.key --output evidence/distribution.json
pam distribution:verify evidence/distribution.json
pam distribution:verify evidence/distribution.json --json
  • The key is a padded base64 32-byte Ed25519 seed in a file with no group or other permissions; symlinked keys are rejected.
  • distribution:sign validates the draft (codes, timing, referenced file sizes and hashes) before signing, never overwrites its output, and writes only the public key and its identity into the manifest.
  • distribution:verify re-reads every referenced file and checks the signature without network access.

Earlier 0.1.x releases had experimental pam sandbox, pam record, pam replay, signed bootstrap snapshots and WASI/RPC commands. They do not exist in PAM 1.0 and later; do not copy those examples into automation. Use container or host sandboxing (the hardened packaging/pam.service unit, a non-root container), pam composer audit, and application-owned incident capture where you need those controls.

Every pull request to the PAM repository runs cargo deny, composer audit, six fuzz targets (HTTP request path, multipart, C header reader, dispatch envelope, page cache policy, shared table) and integration tests under AddressSanitizer and UndefinedBehaviorSanitizer, plus CodeQL for C/C++, Rust and workflows. A nightly job runs an RSS soak and Valgrind. A green run reduces known risks; it does not prove the absence of leaks in extensions or Composer packages your application loads.

Do not open a public issue for a vulnerability. Follow the Security Policy to report it privately.