# rmyndharis/openwa — AlpLab Radar Static Code Audit

- Ring: `adopt`
- Category: `dev`
- Overall score: `4.3/5`
- Implementation check: `verified`
- Maturity: `active`
- Audited commit: `24816d8b7465` (read-only; nothing from the repository was executed)
- Reviewed at: 2026-12-02T05:51:29Z
- Repository: https://github.com/rmyndharis/openwa
- Radar entry: https://radar.alplab.co/#repo/rmyndharis/openwa
- License: `MIT`
- CI workflows: `.github/workflows`
- Tags: `whatsapp`, `api-gateway`, `nestjs`, `self-hosted`, `mcp`, `automation`

## Summary

Self-hosted WhatsApp API gateway (NestJS 11 + TypeScript) that drives whatsapp-web.js or Baileys sessions behind a REST/WebSocket API with a bundled React dashboard, SQLite/Postgres persistence, HMAC-signed webhooks, session- and chat-scoped API keys, and an opt-in MCP mount for AI agents.

## Implementation Check

Every core README claim maps to working code: EngineFactory.create/purgeSessionData (src/engine/engine.factory.ts) registers both engines with path-traversal guards, ChatScopeService/api-key-permissions (src/modules/auth/chat-scope.service.ts, src/modules/auth/api-key-permissions.ts) implement session/chat-scoped keys, mountMcpServer (src/modules/mcp/mcp.server.ts) implements the MCP mount with key gating and read-only default, and docker-entrypoint.sh implements the documented root-chown-then-gosu privilege drop.

## When to Use

Use it to self-host WhatsApp automation (bots, notifications, internal tooling, AI agents via MCP) on a dedicated number where you accept the documented ban risk of unofficial clients; do not use it for regulated, revenue-critical, or compliance-sensitive messaging — the README itself directs those to Meta's official Cloud API.

## Sub-scores

| Dimension | Score |
|---|---|
| quality | 5.0/5 |
| usability | 4.5/5 |
| reliability | 3.0/5 |
| security | 4.5/5 |
| integration | 4.5/5 |

## Code Evidence

src/main.ts bootstrap runs validateEnv before NestFactory.create, asserts no default secrets in production (assertNoDefaultSecretsInProduction), and wires graceful shutdown (installStopSignalHandlers, wireBootstrapShutdown); src/configure-app.ts configureApp installs helmet with a per-request CSP nonce, an aggregate in-flight body budget (createInflightBodyBudget) ahead of the parsers, JSON nesting scans, and a trailing-slash DELETE refusal; src/engine/engine.factory.ts EngineFactory.create enforces isSafeSessionName (src/common/utils/path-safety.ts) and make credential dirs owner-only (ensurePrivateDir) for both engines; src/modules/auth/api-key-hash.ts hashApiKey uses HMAC-SHA256 with API_KEY_PEPPER falling back to SHA-256; src/modules/plugins/plugin-installer.ts parsePluginPackage rejects zip-slip, zip-bomb (declared + actual byte caps, zlib maxOutputLength), duplicate and absolute paths; src/modules/mcp/mcp.server.ts createKeyGate/createIpThrottle authenticate and throttle the raw-Express /mcp mount with read-only default via resolveMcpReadOnly; engine implementations are substantial (src/engine/adapters/whatsapp-web-js.adapter.ts ~40KB, src/engine/adapters/baileys.adapter.ts ~44KB, wwebjs-messaging.ts ~88KB, baileys-messaging.ts ~91KB); docker-entrypoint.sh drops to the openwa user via gosu after ownership fixes; .github/workflows/ci.yml runs lint, full-program tsc, unit tests with per-module coverage thresholds, e2e with a Redis service, a postgres:16 migration job, npm-audit gates (scripts/check-audit.mjs), shellcheck on every script, helm/kubeconform/actionlint checks, multi-arch Docker build plus smoke-test-non-root.sh and smoke-test-engine-libs.sh boot smokes; .github/workflows/security-scan.yml adds weekly Trivy image scans and node:22-slim digest-drift detection; package.json pins whatsapp-web.js 1.34.8 and puppeteer 25.19.0 with jest moduleNameMapper mocks for the WA libraries.

## Issues Found

No material security defect found; minor notes: @whiskeysockets/baileys is pinned to a prerelease (7.0.0-rc14) in package.json, and the opt-in docker-socket-proxy profile is honestly documented in README.md as host-root-equivalent if the API container is compromised (a deployment choice, not a code flaw).

## Key Risks

Nothing was executed — tests exist in large volume (hundreds of spec files, e2e suites, CI lanes) but passing was not verified. Core function depends on reverse-engineered WhatsApp clients (whatsapp-web.js 1.34.8, @whiskeysockets/baileys 7.0.0-rc14 — a prerelease) with in-repo patch scripts (scripts/patch-baileys-*, scripts/patch-wwebjs-*), so upstream protocol changes can break sessions; account ban/restriction risk is inherent to the unofficial protocol and clearly documented in the README. whatsapp-web.js sessions cost ~300-500MB RAM (headless Chromium). Development is heavily single-author (top_author_share_90d 0.95), the project is v0.x with no stable release yet, and dashboard behavior was only inspected as source, not rendered. Runtime pairing requires a real WhatsApp scan, which is unverifiable statically.

## Reviewed Files

- `README.md`
- `package.json`
- `src/main.ts`
- `src/configure-app.ts`
- `src/engine/engine.factory.ts`
- `src/common/utils/path-safety.ts`
- `src/modules/auth/api-key-hash.ts`
- `src/modules/plugins/plugin-installer.ts`
- `src/modules/mcp/mcp.server.ts`
- `docker-entrypoint.sh`
- `.github/workflows/ci.yml`
- `.github/workflows/security-scan.yml`
