Skip to content

functions: pre-deploy audit fails again (proxy-addr critical, node-forge high) — upgrade firebase-admin 12→14 and firebase-functions 5→7 #88

Closed

Description

@BurningAXE

npm run audit in functions/ (the pre-deploy check in CLAUDE.md) has failed at --audit-level=high since early October 2026. package-lock.json hasn't changed: the advisories were published after the last passing run on 2026-10-02. Registry signatures still verify (574 packages), so these are ordinary advisories, not malware.

What ships (npm audit --omit=dev: 1 critical, 2 high, 12 moderate)

  • proxy-addr@2.0.7 (critical), GHSA-jqcg-44mw-7w3h: IP spoofing via an IPv4-mapped IPv6 trust subnet. It comes in through firebase-functions@5.1.1 → express@4.22.2, which asks for ~2.0.7. The in-range fix 2.0.8 was published 2026-09-15, so it already clears the 7-day rule, and a lockfile-only bump fixes it.
  • node-forge@1.4.0 (high), GHSA-86w9-cpqp-85rv: RSA PKCS#1 v1.5 signature verification accepts extra nested DigestAlgorithm elements. It comes in through firebase-admin@12.7.0 (^1.3.1). No fixed version exists: 1.4.0 is the latest release. firebase-admin 14 no longer depends on node-forge, so the only way to clear this is the major upgrade.
  • Moderate: qs (needs 6.16, outside express's ~6.15.1), uuid (needs a major), @fastify/busboy (3.2.2 is in range and older than 7 days).

These are dev-only, so --omit=dev doesn't list them: handlebars (2× critical), braces (high) and sprintf-js, all through jest/istanbul.

Already live

All 21 functions run this lockfile. searchVetClinics was redeployed alone on 2026-10-13 with the audit failing. That was a deliberate decision: the deploy neither added nor removed any exposure.

To do

  1. proxy-addr → 2.0.8 in the lockfile only (npm update proxy-addr). Confirm npm ls proxy-addr --omit=dev shows 2.0.8.
  2. firebase-admin 12.7.0 → 14.x, a major upgrade (two majors). Latest is 14.5.0, published 2026-09-23, so it clears the 7-day rule. It requires Node >=22; the runtime is nodejs24.
    • Read the 13 and 14 changelogs. Pay attention to Firestore (FieldValue, Timestamp, GeoPoint), Messaging (sendEach), Auth (getUser, deleteUser) and Storage, which index.ts, moderation.ts, removeSignal.ts and signalOwnership.ts use.
  3. firebase-functions 5.1.1 → 7.x (latest 7.4.0, published 2026-09-15). Its peer range accepts firebase-admin ^14. Check the v2 onCall, onDocument*, onSchedule and defineSecret APIs for breaking changes.
  4. Use npm install --before=$(date -v-7d +%Y-%m-%d) firebase-admin@14 firebase-functions@7, then rm -rf node_modules && npm ci && npm run build && npm test && npm run audit.
  5. Run firestore-tests (npm test) as well. It doesn't use firebase-admin, but rules deploys share the gate.
  6. Do a full functions deploy from merged dev. Every function bundles these deps, so redeploying a subset leaves the rest exposed. Then smoke-test on a device:
    • signal create → push fan-out
    • comment → push
    • feedback email
    • vet clinic search
    • account deletion
    • ownership claim
  7. Consider folding in functions: bump nodemailer 10.0.10 → 10.0.13 once it clears the 7-day quarantine (on/after 2026-10-07) #87 (nodemailer 10.0.10 → 10.0.13, now past its quarantine) so it all lands in one full deploy.

Activity

  1. BurningAXE commented on Oct 13, 2026

    @BurningAXE
    MemberAuthor

    Vetting (2026-10-13)

    The plan above is valid and safe to do from a supply-chain point of view. Two parts of it are understated, though, and as written it would neither compile nor turn npm run audit green.

    Confirmed

    • Both advisories are real, and the dependency paths match npm ls: GHSA-jqcg-44mw-7w3h was published 2026-10-05, and GHSA-86w9-cpqp-85rv on 2026-09-03 with no patched node-forge.
    • All target versions clear the 7-day rule:
      • proxy-addr 2.0.8 (2026-09-15)
      • firebase-admin 14.5.0 (2026-09-23)
      • firebase-functions 7.4.0 (2026-09-15)
    • proxy-addr 2.0.8 is genuine, despite being the first release in five years:
      • It was published via npm trusted publishing (GitHub Actions OIDC) with SLSA provenance from jshttp/proxy-addr@refs/tags/v2.0.8 (a11ad82).
      • The tarball diff against 2.0.7 is the IPv4-mapped canonicalisation fix in index.js, plus README/HISTORY/devDependency churn.
      • It adds no install script and has the same runtime dependencies.
    • A lockfile-only dry run (npm install --package-lock-only --ignore-scripts --before=<7d> firebase-admin@14 firebase-functions@7, which fetches metadata only and runs no package code) leaves npm audit --omit=dev at 0 critical / 0 high / 3 moderate. The moderates are @fastify/busboy and uuid via gaxios@6, and both have in-range fixes.
    • Neither advisory is reachable today, so this is about unblocking the gate, not an active exposure:
      • proxy-addr only matters with Express trust proxy configured. Neither firebase-functions nor our code sets it, and nothing reads req.ip.
      • firebase-admin 12 calls node-forge only from credential-internal.js (privateKeyFromPem for cert() credentials). We use ADC (admin.initializeApp() with no arguments), so the vulnerable signature-verification path is never hit.

    Gaps in the plan

    1. firebase-admin 14 removes the legacy namespace API (change: Remove Deprecated Legacy Namespace Support firebase/firebase-admin-node#3164, Remove Deprecated Legacy Namespace Support).

      • About 50 references across index.ts, moderation.ts, signalOwnership.ts, removeSignal.ts and signalRefs.ts must move to modular imports: admin.firestore(), admin.firestore.FieldValue/Timestamp/GeoPoint/DocumentReference/…, admin.messaging() / admin.messaging.Message, and admin.auth().
      • The replacements are getFirestore(), FieldValue/Timestamp/GeoPoint from firebase-admin/firestore, getMessaging() from firebase-admin/messaging, and getAuth() from firebase-admin/auth. initializeApp is still exported from the root.
      • This is most of the work. tsc flags every site, so nothing fails silently. The modular API already exists on v12, so the migration can land and deploy first, on its own, before any version changes.
    2. npm run audit still fails after the upgrade, because of dev dependencies. The script has no --omit=dev, so these remain:

      • handlebars 4.7.9: critical, via ts-jest. The in-range fix is 4.7.10, published 2026-10-05.
      • braces 3.0.3: high, via jest@29 → micromatch. No fixed braces exists, so this needs jest 30 (30.5.2 was published 2026-09-18) along with matching ts-jest/@types/jest.

      The alternative is to scope the gate to what ships (npm audit --omit=dev --audit-level=high). That needs a decision either way.

    3. Step 1 is subsumed by step 3. firebase-functions 7 depends on express@^5.2.1, which resolves proxy-addr@2.0.8 and qs@6.16.0 by itself. Step 1 is still worth doing on its own if we want a deploy before the majors land.

    4. functions: bump nodemailer 10.0.10 → 10.0.13 once it clears the 7-day quarantine (on/after 2026-10-07) #87 is stale. 10.0.13 has been superseded:

      • 10.0.15 (2026-10-05) is the newest past quarantine.
      • 10.0.16 (2026-10-07) clears it on 2026-10-14.
      • 10.1.0 (2026-10-10) clears it on 2026-10-17.

    Checked, no action needed

    • Express 5 compatibility: signalLink (the only onRequest) uses res.redirect(301, url), res.status(200).send() and req.query, all of which are valid in Express 5.
      • Whether req.query comes from qs or the simple parser, the typeof rawLang === "string" guard and the extraneous-key check still redirect ?lang=a&lang=b and ?lang[x]=y.
    • FCM error codes: the stale-token cleanup (index.ts:254) compares messaging/registration-token-not-registered / messaging/invalid-registration-token, and v14's FirebaseMessagingError still builds code as messaging/${code}.
    • Tests: none of them mock firebase-admin, so the namespace migration won't silently pass a mocked suite. Build and runtime smoke tests are what catch it.

    Suggested order

    1. Commit A (no version changes): migrate to the modular Admin API on firebase-admin 12, then build, run the tests, and do a full deploy.
    2. Commit B: firebase-admin@14 + firebase-functions@7 with --before, plus nodemailer (functions: bump nodemailer 10.0.10 → 10.0.13 once it clears the 7-day quarantine (on/after 2026-10-07) #87).
    3. Commit C: dev tooling (handlebars 4.7.10 + jest 30), or the --omit=dev gate change.
    4. Full functions deploy from merged dev, followed by the device smoke list above.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions