Security (OWASP & 12-Factor)
Security baseline for every service and every tenant. Two reference frames: OWASP ASVS / Top 10 (application security) and 12-Factor (config/operations hygiene).
12-Factor checklist
| Factor | Application here |
|---|---|
| I. Codebase | One repo, many per-tenant deploys (Multi-Tenancy) |
| II. Dependencies | Explicit lockfiles; SCA scanning in CI |
| III. Config | All env/secret config injected; nothing brand-specific hard-coded |
| IV. Backing services | Postgres/Mongo/Redis/S3/Hyperswitch as attached resources via URLs |
| V. Build/release/run | Immutable images; release = image + config; reproducible |
| VI. Processes | Stateless services; state in PG/Mongo/Redis/S3 |
| VII. Port binding | Each service self-contained behind the gateway |
| VIII. Concurrency | Horizontal scale per service; BullMQ workers scale independently |
| IX. Disposability | Fast startup/shutdown; idempotent consumers; graceful drain |
| X. Dev/prod parity | Same images across envs; differences only in config |
| XI. Logs | Structured logs to a central sink (stdout → collector) |
| XII. Admin processes | Migrations/jobs run as one-off tasks in the same image |
OWASP Top 10 — controls
| Risk | Control |
|---|---|
| A01 Broken Access Control | Capability + row-level scope (RBAC); deny-by-default; server-derived scope only |
| A02 Cryptographic Failures | TLS everywhere; secrets in k8s secrets/Vault; encrypt PII at rest; no secrets in DB config doc |
| A03 Injection | Parameterized queries (MikroORM/Mongoose); input validation (class-validator / zod); output encoding |
| A04 Insecure Design | Threat-model per module; signed webhooks; outbox + idempotency; least privilege |
| A05 Misconfiguration | Hardened base images; no default creds; security headers; CSP on storefront |
| A06 Vulnerable Components | SCA + image scanning in CI; pinned/patched deps |
| A07 Auth Failures | Short-lived JWT + refresh rotation; MFA for admin/finance; rate-limit + lockout; secure session in Redis |
| A08 Integrity Failures | Signed images; verify in/out webhook signatures (HMAC); SRI where relevant |
| A09 Logging/Monitoring | Central logs, audit trail on all mutations, alerting on auth anomalies + DLQ |
| A10 SSRF | Allow-list outbound (marketplace/courier/automation endpoints); no user-controlled fetch |
Payments & PCI
- Card data handled by Hyperswitch + gateways; the platform avoids storing PANs.
- Webhooks from Hyperswitch/gateways are signature-verified.
- Reconciliation data (non-card) stored in the Finance Postgres schema. See Payments.
Tenant isolation
- Separate namespace, DBs, buckets, and secrets per tenant → no cross-tenant data path.
- Per-tenant keys for Hyperswitch/courier/marketplace/automation.
Secrets management
- Env/k8s secrets/Vault only. Never in the Mongo
TenantConfigdocument (that holds non-secret branding/behavior only). - Rotation policy for gateway/courier/marketplace/webhook secrets.
Webhooks (in & out)
- Inbound (Hyperswitch, Shiprocket, marketplaces): verify signature, check timestamp/nonce, idempotent processing.
- Outbound (Zapier/Pabbly): HMAC-sign payloads with the tenant secret; document verification for receivers (Automation).
Privacy / compliance
- PII minimization; encryption at rest for personal data.
- Data export/delete pathways (customer rights).
- Audit logs retained per policy.
CI security gates
- SAST + dependency/SCA + container scan must pass.
- No high/critical findings merged without sign-off.
- See Testing Strategy.