Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(compose): re-add KILL to the quick-start stack
Yudhi Armyndharis50af6373b139
diff --git a/docker-compose.dev.yml b/docker-compose.dev.ymlindex c87ea90e8..0c0ecf3b1 100644--- a/docker-compose.dev.yml+++ b/docker-compose.dev.yml@@ -24,6 +24,7 @@ services:- CHOWN- DAC_OVERRIDE- FOWNER+ - KILL # dumb-init: forward signals to the openwa process after gosu drops uid- SETGID- SETUIDread_only: truediff --git a/docs/13-horizontal-scaling.md b/docs/13-horizontal-scaling.mdindex c9d6e69c7..34ea538b3 100644--- a/docs/13-horizontal-scaling.md+++ b/docs/13-horizontal-scaling.md@@ -467,8 +467,8 @@ spec:allowPrivilegeEscalation: falsecapabilities:drop: ['ALL']- # Only for the root entrypoint's chown and the gosu privilege drop.- add: ['CHOWN', 'DAC_OVERRIDE', 'FOWNER', 'SETGID', 'SETUID']+ # The root entrypoint's chown, the gosu privilege drop, and init forwarding signals after it.+ add: ['CHOWN', 'DAC_OVERRIDE', 'FOWNER', 'KILL', 'SETGID', 'SETUID']resources:requests:memory: '512Mi'diff --git a/docs/30-plugin-sandboxing.md b/docs/30-plugin-sandboxing.mdindex 16184ad22..47f0adbc8 100644--- a/docs/30-plugin-sandboxing.md+++ b/docs/30-plugin-sandboxing.md@@ -84,8 +84,8 @@ process can do to the host; it does not confine a plugin away from anything thatfirst instruction, with no capabilities added (the chart's `podSecurityContext`). The rest of theconfinement comes from the bundled `docker-compose.yml`, not from the image: `read_only: true`rootfs with a tmpfs `/tmp`, `no-new-privileges`, and `cap_drop: ALL` with a minimal re-add- (`CHOWN`/`DAC_OVERRIDE`/`FOWNER`/`SETGID`/`SETUID`) that only the root entrypoint uses — once `gosu`- setuids, the Node process keeps no effective capabilities. A plain `docker run` of the image gets+ (`CHOWN`/`DAC_OVERRIDE`/`FOWNER`/`KILL`/`SETGID`/`SETUID`) that only the root entrypoint and init use —+ once `gosu` setuids, the Node process keeps no effective capabilities. A plain `docker run` of the image getsnone of the compose-level settings, so replicate them yourself if you deploy that way.- **What a loaded plugin can still reach.** Everything the OpenWA process can, including:- the process environment through `/proc/self/environ` on Linux, with every secret the deploymentdiff --git a/src/common/services/shutdown-budget.spec.ts b/src/common/services/shutdown-budget.spec.tsindex 1c27f6bee..c338686fc 100644--- a/src/common/services/shutdown-budget.spec.ts+++ b/src/common/services/shutdown-budget.spec.ts@@ -1,5 +1,6 @@import { readFileSync } from 'fs';import { join } from 'path';+import * as yaml from 'js-yaml';import { CACHE_QUIT_TIMEOUT_MS } from '../cache/cache.service';import { THROTTLER_REDIS_QUIT_TIMEOUT_MS } from '../throttler/redis-throttler.storage';import configuration from '../../config/configuration';@@ -103,6 +104,26 @@ describe('shutdown time budget', () => {expect(Number(/^terminationGracePeriodSeconds: (\d+)$/m.exec(values)?.[1]) * 1000).toBe(SHUTDOWN_KILL_DEADLINE_MS);});+ // dumb-init is PID 1 as root and gosu then runs node as uid 997. A root process without CAP_KILL can only+ // signal its own uid, so a cap_drop ALL stack that does not re-add KILL never delivers SIGTERM to node:+ // every stop waits out the whole kill deadline and ends in SIGKILL with no teardown at all.+ it.each(['docker-compose.yml', 'docker-compose.dev.yml'])('%s re-adds KILL so dumb-init can signal node', file => {+ const compose = yaml.load(readFileSync(join(root, file), 'utf8')) as {+ services: Record<string, { container_name?: string; cap_drop?: string[]; cap_add?: string[] }>;+ };+ const api = Object.values(compose.services).find(service => service.container_name === 'openwa-api');+ expect(api?.cap_drop).toContain('ALL');+ expect(api?.cap_add).toContain('KILL');+ });++ it('re-adds KILL in the Helm chart and in the Kubernetes example of the scaling guide', () => {+ const values = yaml.load(readFileSync(join(root, 'charts/openwa/values.yaml'), 'utf8')) as {+ containerSecurityContext: { capabilities: { add: string[] } };+ };+ expect(values.containerSecurityContext.capabilities.add).toContain('KILL');+ expect(readFileSync(join(root, 'docs/13-horizontal-scaling.md'), 'utf8')).toMatch(/add: \[[^\]]*'KILL'[^\]]*\]/);+ });+it('destroys open sockets at the HTTP close, which the table counts as 0 s', () => {expect(readFileSync(join(root, 'src/main.ts'), 'utf8')).toMatch(/^\s+forceCloseConnections: true,/m);});