fix(security): role-gate WhatsApp account routes (decrypted-token exposure) - #4
Merged
Merged
Conversation
…osure) whatsappAccounts.js shipped a stub adminOnly that only checked req.user (a stale 'roles were removed' assumption). The system does have roles (admin/bda_sales/viewer, permissions.js + migration 031), so any logged-in non-admin could read a live, DECRYPTED Meta access token via GET /api/whatsapp-accounts/:id?reveal=1, and create/update/delete accounts. Use the role-gated adminOnly from middleware/access.js for :id (reveal), POST, PUT, DELETE. The list and by-phone picker routes stay open to all authenticated users since they return masked metadata only (no token). Audit ref: REVIEW.md P0 #1 (lane 02 CRITICAL + HIGHs). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: KingArthur000 <sathyaprakashelango@gmail.com>
sathyaprakash000
added a commit
that referenced
this pull request
May 25, 2026
… deploy docs (#5) Batch D — 5 audit Criticals + related: - auth.js/crypto.js: production guards now reject the .env.example placeholder secrets and any value < 32 chars (not just the empty/dev-default), so a self-hoster copying .env.example unchanged can't run prod with public keys. - .env.example: add POSTGRES_PASSWORD (+ matching DATABASE_URL) and META_APP_SECRET; document the >=32-char / no-placeholder requirement + openssl generation. - Caddyfile: replace the real domain forgechat.akilsadik.live with forgechat.example.com + an explicit 'replace with your domain' note. - DEPLOY.md: fix wrong env var names (FORGECRM_JWT_SECRET -> JWT_SECRET, FORGECRM_META_WEBHOOK_VERIFY_TOKEN -> META_WEBHOOK_VERIFY_TOKEN), drop the unused COOKIE_PARENT_DOMAINS, add POSTGRES_PASSWORD/META_APP_SECRET. - admin seed: write the generated one-time password to a 0600 file instead of stdout (avoids credential persistence in log aggregators). - health check: backend route is /health (not /api/health); add an nginx location so it's reachable externally, and fix both deploy guides' smoke test. Audit refs: REVIEW.md P0 #4,#5,#6,#7,#8 (lanes 04,24,25). Signed-off-by: KingArthur000 <sathyaprakashelango@gmail.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
P0 #1 from the security audit (lane 02, CRITICAL).
whatsappAccounts.jsused a stubadminOnlythat only checkedreq.user(a stale 'roles were removed' note), so any authenticated non-admin could:GET /api/whatsapp-accounts/:id?reveal=1Fix: use the role-gated
adminOnlyfrommiddleware/access.json:id(reveal)/POST/PUT/DELETE. Thelistandby-phonepicker routes stay open to all authenticated users — they return masked metadata only, no token.