Files
Kelx/INDEPENDENT-AUDIT-PRELOGIN.md
T
2026-11-30 16:32:37 +00:00

95 lines
10 KiB
Markdown

# Independent Audit Prompt
Independently review the ADPanel anonymous-response changes described below. Read `AGENTS.md` and review the task-only diff line by line. Trace the actual Express middleware order, login and asset handlers, health consumers, node requests, and both generated Nginx layouts, including HTTP, HTTPS, and forced HTTPS. Check installer ownership, rollback, and ACME issuance and renewal wiring. Review the assertions as well as the code: do not treat the implementation report as evidence by itself.
Work read-only in the repository. Use only disposable, loopback-only fixtures with synthetic state. Do not fix anything, deploy, run the full installer, start or reload host services, read live configuration or credentials, or test public hosts or search services. The acceptance script extracts the generator only; it does not invoke full setup, Certbot, or a host service manager.
Report genuine bugs, regressions, or security issues first, in severity order, with `file:line` evidence, impact, and the conditions needed to reproduce them locally. Do not force findings. If no findings are supported, say **No issues found**. List unverified checks and residual risks separately from findings. Do not edit the implementation.
## Diff Baseline
Starting HEAD: `78193254adece7d1fbfe1c6bcf539c33b9f6b8d7`. The worktree was already dirty. Use the exact pre-edit blobs below, not a diff against HEAD, to separate this task from existing changes. The blobs are stored in this workspace's local Git object database. If one is unavailable, report the missing baseline rather than assuming HEAD matches it.
| Changed file | Pre-edit Git blob |
| --- | --- |
| `index.js` | `8932851e62e657af5e83554cbe2c84529b4856bb` |
| `utils/stealth.js` | `e9f96062270eb702f0b546dbb9ab9a289cd9b117` |
| `views/login.ejs` | `78dbcba258fd8baac392c6c0db3cdfd64a6b583e` |
| `views/maintenance.ejs` | `7bc8a751ceb223684fda31b8a452e657ad4e5fef` |
| `initialize.sh` | `098913f705f676776328b5a1c39a13420a031d81` |
| `.env.example` | `ebe3907115ed09b4b98aa3a93cdffca0e7fd0329` |
| `tests/login-preauth-wiring.test.js` | `3183665462362cda64faf680c3db354f055be6c5` |
| `tests/maintenance-page-stealth.test.js` | `4bf056673298bfa8f770bc5e80a2280e52242ed0` |
| `tests/stealth-favicon-decoy.test.js` | `ea13275e69f60e71dd95c132d2bc52c117ec14d6` |
| `tests/stealth-mint-cap.test.js` | `d86f93b1e2525796a82840eca7aada80b9d3d31d` |
| `README.md` | `661f39a9209ce4bd2a62464ffc04cbbae4127bdf` |
| `scripts/verify-prelogin.js` | New file |
| `INDEPENDENT-AUDIT-PRELOGIN.md` | New review handoff |
For each blob, compare `git cat-file blob "$before" | diff -u --label "before/$file" --label "after/$file" - "$file"`; `diff` status 1 is expected for changes. For new files, use `git diff --no-index -- /dev/null "$file"`. Neither command writes to the repository.
## Policy And Defaults
- New app installs default the legacy stealth gate off. An explicit `STEALTH_MODE` value still controls it, and when unset the app honors saved `enabled` state. Older installers wrote `STEALTH_MODE=true`, so inherited and deliberate opt-ins cannot be distinguished safely. Do not change sign-in URL, permissions, MFA, recovery, session cookies, CAPTCHA configuration, or existing abuse controls. No new challenge, scanner list, artificial response floor, or dependency is required for direct sign-in.
- The existing implicit favicon returns empty no-store `204` with the gate off; explicit branding assets still serve. Existing gate-on behavior remains. Health keeps HTTP status, `ok`, `ts`, and no-store, without the product name. Closed registration shares the terminal plain-text no-store `404`. Login and maintenance titles are neutral and use a crawler indexing hint; the maintenance message, reason, and recovery poll remain.
- Generated vhosts keep upstream responses and the existing gate paths, hide upstream software headers, turn off proxy caching, and replace selected Nginx-generated error bodies without changing their status. Static fast paths allow asset types instead of serving arbitrary documents. HTTP ACME files remain reachable with forced HTTPS, and fresh proxy-backed certificate issuance uses Certbot webroot with an Nginx reload deploy hook.
- The generator installs new vhosts or replaces only unchanged checksum-marked vhosts. It does not rewrite unmarked or edited ADPanel vhosts, unrelated/default sites, or global Nginx config. The app updater gets the origin changes but cannot regenerate the proxy; the Agent service upgrade does not update proxy configuration either. Old proxy files and external proxies keep their own response policy.
## Exact Checks
Run static checks and the acceptance script from the repository root:
```bash
bash -n initialize.sh
node --check index.js
node --check scripts/verify-prelogin.js
NGINX_BIN=/tmp/adpanel-prelogin-tools.EXCoKT/usr/sbin/nginx node scripts/verify-prelogin.js
```
The acceptance command used Node 20.19.2 and Nginx 1.26.3. If that cached binary is absent, use a locally installed Nginx with auth_request, SSL, and HTTP/2 support by pointing `NGINX_BIN` at it. The fixture requires Linux user/network namespaces with IPv6 loopback, Bubblewrap, GNU coreutils and awk, `flock`, Bash, OpenSSL, MariaDB server and `mariadb-install-db`, Redis server, and installed `node_modules`. It creates private `/tmp`, `/etc`, `/run`, a TLS certificate, MariaDB schema, Redis sessions, an account, and a node. Fixture shims report service status, inject reload and restore failures, and capture Certbot arguments without invoking Certbot. The test starts and stops its own processes without using host service sockets.
For the required `npm test` and `go test .` gates, use a non-root source copy with synthetic data, not the live workspace runtime files. This recipe uses the local cached Go 1.26.9 toolchain/modules and performs no downloads:
```bash
(
set -eo pipefail
repo=$PWD
scratch=$(mktemp -d /tmp/adpanel-prelogin-audit.XXXXXX)
trap 'rm -rf -- "$scratch"' EXIT
mkdir -p "$scratch/panel/data"
git ls-files -z -c -o --exclude-standard --deduplicate -- \
index.js db.js nodes.js package.json package-lock.json mysql-schema.sql \
go.mod go.sum '*.go' initialize.sh install.sh install.cmd install-daemon.sh \
start.sh ecosystem.config.template.js README.md AGENTS.md .env.example \
adpanel-sudoers templates.json versions.json public views routes services \
utils tests middleware scripts AgentWorker privileged dev-templates \
':!**/.env' ':!**/*credentials.json' ':!**/node_modules/**' |
while IFS= read -r -d '' name; do
if [[ -f "$name" && ! -L "$name" ]]; then cp --parents --preserve=mode -- "$name" "$scratch/panel"; fi
done
printf '%s\n' '{"appName":"ADPanel","logoUrl":null,"loginBackgroundExternalUrl":null,"localLoginBackgroundPath":"shadow-lines.avif"}' > "$scratch/panel/data/branding.json"
printf '%s\n' '{"requirePinned":false,"panel":{},"node":{}}' > "$scratch/panel/data/update-checksums.json"
sandbox=(bwrap --unshare-all --die-with-parent --uid "$(id -u)" --gid "$(id -g)"
--ro-bind /usr /usr --symlink usr/bin /bin --symlink usr/sbin /sbin
--symlink usr/lib /lib --symlink usr/lib64 /lib64 --proc /proc --dev /dev
--tmpfs /tmp --tmpfs /run --dir /etc/alternatives --symlink /usr/bin/gawk /etc/alternatives/awk
--bind "$scratch/panel" /fixture --chdir /fixture --clearenv --setenv HOME /tmp)
"${sandbox[@]}" --ro-bind "$repo/node_modules" /fixture/node_modules \
--setenv PATH /usr/bin:/usr/sbin:/bin:/sbin --setenv npm_config_offline true npm test
"${sandbox[@]}" --ro-bind /tmp/adpanel-reinstall-review/go /go \
--ro-bind "$HOME/go/pkg/mod" /mod --setenv PATH /go/bin:/usr/bin:/usr/sbin:/bin:/sbin \
--setenv GOTOOLCHAIN local --setenv GOPROXY off --setenv GOSUMDB off \
--setenv GOMODCACHE /mod go test .
)
```
## Measured Results And Limits
- The real Express origin, generated HTTP proxy, and generated HTTPS proxy all returned `200` on bare `/login` and `303` on a native form POST with the existing CSRF and session data, without executing JavaScript or minting a gate cookie. Autocomplete attributes, HTTPS Secure cookie, branded icon/background, and recovery page remained. `/healthz` and `/healtz` returned `200` with only `ok` and `ts`. Implicit favicon GET/HEAD returned `204` with no body, redirect, or cookie. `/register` returned plain `404`.
- The signed synthetic heartbeat returned `200` and unsigned requests returned `401` on all three paths. The fixture also verified a neutral maintenance `503`, Nginx local `404` and upstream-down `502` with no-store, HSTS, refusal to serve a source map, challenge-file `200` during HTTP-to-HTTPS redirects, and legacy gate behavior. Both proxy layouts validated; the negative cases confirmed operator-file and symlink preservation and rollback after an invalid generated config.
- Required suites: `npm test` passed 4,493 tests, with 9 skipped and no failures. `go test .` passed (`ok adpanel-node`). Nginx's deprecation warning for the pre-existing `listen ... http2` syntax is not a failed check. The invalid-upstream test intentionally prints one failed `nginx -t` before restoring the original.
- Not verified against public DNS, indexing, ACME servers, host package/service managers, a graphical password manager, or a live rollout. The fixture substitutes local certificate/challenge files and does not run a Certbot renewal cycle. External monitors that validate the removed `service` field need to use `ok` or HTTP status instead. The public branded page, linked assets, existing cookie names, proxy banner, DNS/TLS metadata, and past index entries still allow identification. An indexer can ignore crawler directives or make the same requests a browser makes; this is not an access control.
## Post-Audit Coverage
The acceptance fixture checks IPv6 HTTP-only challenge bootstrap and both address families after forced HTTPS, with the Debian default site left in place. It also checks generator lock contention, edits during HTTP and HTTPS staging, reload failures in both layouts, and retention of the backup after an injected restore-copy failure. Synthetic Certbot calls cover refusal when the active listener serves the wrong vhost, fresh webroot issuance, migration and renewal of one named single-domain certificate, and refusal to proceed after a migration failure. Real issuance, renewal, and service-manager behavior remain unverified.