Security model, audit findings, and production hardening guidance for rebe.
This document records a code- and dependency-level audit of the framework. Findings are rated Critical / High / Medium / Low / Info and mapped to CWE. Items marked Fixed are already addressed in the codebase; Guidance items are safe defaults that you should review against your threat model before deploying.
| ID | Severity | CWE | Issue | Status |
|---|---|---|---|---|
| F-01 | Medium | CWE-79 | Reflected XSS in error/404 HTML pages | Fixed |
| F-02 | Medium | CWE-942 | CORS wildcard origin combined with credentials | Fixed |
| F-03 | Medium | CWE-440 | common/* utils required a non-existent module (@app/config), crashing Crypt/Hash/Storage/Cache |
Fixed |
| F-04 | Low | CWE-1395 | Transitive uuid bounds-check advisory via sequelize |
Accepted / monitor |
| F-05 | Medium | CWE-434 | File-type enforcement relies on client MIME; active content (SVG/HTML) could be stored XSS | Guidance |
| F-06 | Info | CWE-345 | JWT algorithm confusion | Mitigated by design |
| F-07 | Low | CWE-400 | Large default JSON/body limit (10 MB) | Guidance |
| F-08 | Info | CWE-352 | No CSRF protection | N/A for bearer API |
| F-09 | Low | CWE-798 | Demo credentials in sample code; secrets in local .env |
Guidance |
| F-10 | Info | CWE-770 | Rate limit / trust-proxy defaults | Guidance |
| F-11 | High | CWE-400 | ws / form-data transitive DoS & CRLF advisories (socket.io, axios) |
Fixed (2.0.0) |
| F-12 | Moderate | CWE-1395 | js-yaml DoS in the jest dev-dependency tree |
Accepted (dev-only) |
| F-13 | Low | CWE-400 | No HTTP server timeouts — slow-request / slowloris DoS surface | Fixed (3.0.0) |
| F-14 | Info | CWE-1059 | Error JSON envelope diverged from the documented { status, code, … } shape |
Fixed (3.0.0) |
error.core rendered req.originalUrl and error messages directly into HTML 404/500
responses. A crafted URL could inject markup. The CSP (default-src 'self') blocks
inline script execution, but the values are now HTML-escaped (Common.Str.escapeHtml)
as defense in depth. JSON responses were never affected.
The previous config used origin: ['*'] with credentials: true. Reflecting any
origin with credentials enabled is unsafe, and browsers reject the combination.
cors.config.js now reads CORS_ORIGIN / SOCKET_CORS_ORIGIN as an allowlist and
forces credentials off whenever the origin is *. Set explicit origins in
production to allow credentialed cross-origin requests.
crypt.js, hash.js, storage.js, and cache.js required @app/config, which does
not resolve (@app → the application folder; config lives at @config). Any use of
Common.Crypt, Common.Hash, Common.Storage, or the config-default path of
Common.Cache would throw MODULE_NOT_FOUND. All references now use @config/index.
This is primarily a reliability bug, but a crash in a crypto/hash helper invoked on a
request path is a denial-of-service vector.
npm audit reports a moderate advisory (GHSA-w5hq-g745-h8pq) for uuid pulled in by
sequelize. The only automated fix downgrades sequelize to a 3.x release (a major
breaking change), so it is not applied. Real-world impact here is low: the affected
code path requires an attacker-controlled buf argument, which the framework never
passes, and the database is disabled by default. Re-run npm audit periodically and
bump sequelize once an upstream fix ships.
express.core.upload() filters by file.mimetype, which the client controls, and by
STORAGE_UPLOAD_ALLOWED_TYPES. The default allowlist (image/jpeg,image/png, image/webp,application/pdf) is safe, and /uploads is served with
X-Content-Type-Options: nosniff. If you broaden the allowlist:
- Do not allow
image/svg+xmlortext/htmlfor files served back to browsers — they can carry script (stored XSS). Serve such files withContent-Disposition: attachment, from a separate origin, or convert/sanitize them. - Consider validating magic bytes, not just the MIME header.
jwt.core pins HS256 on both sign and verify, so forged alg: none or RS/HS-swap
tokens are rejected. Keep access-token TTLs short and store only non-sensitive claims
(the payload is signed, not encrypted).
EXPRESS_BODY_LIMIT defaults to 10mb. For pure-JSON APIs, lower it (e.g. 256kb)
to reduce the memory-exhaustion surface; raise it only for endpoints that genuinely
need large payloads.
The sample auth uses Authorization: Bearer tokens, which are not sent automatically
by browsers, so CSRF does not apply. If you switch to cookie-based sessions, add CSRF
protection (e.g. double-submit token) and set cookies HttpOnly, Secure,
SameSite.
auth.controller.js ships an in-memory demo user ([email protected] /
password123) so the sample runs without a database — replace it with a real model
lookup before production. .env is git-ignored; never commit it, and rotate any
secret that was ever committed. The scaffolder (create-rebe) generates fresh
APP_KEY and JWT secrets per project.
A global rate limit is on by default (100 / 15 min / IP). Behind a proxy or load
balancer, set EXPRESS_TRUST_PROXY=1 (or the real hop count) so the limiter and logs
see the true client IP; leaving it at 0 while behind a proxy lets clients share one
bucket. Do not set an overly permissive trust-proxy value when directly exposed —
it would let clients spoof X-Forwarded-For.
npm audit reported four high-severity transitive advisories: memory-exhaustion DoS in
ws (via socket.io → engine.io / socket.io-adapter) and CRLF injection in
form-data (via axios). All were resolved by a non-breaking npm audit fix
(ws 8.20.1 → 8.21.0, engine.io, socket.io-adapter, form-data 4.0.5 → 4.0.6); the
direct socket.io / axios versions are unchanged. Production dependency tree is clean
of high-severity advisories.
The remaining moderate advisories all originate from jest's transitive
@istanbuljs/load-nyc-config → js-yaml chain (quadratic-complexity DoS in YAML merge-key
parsing). jest is already on its latest major and no non-breaking fix is published, so
these are accepted: they are devDependencies only, exercised against trusted local
test-config files, with no production runtime exposure. Re-run npm audit after jest
updates.
express.core created the http.Server without explicit socket timeouts, leaving the
slow-request / slowloris surface to Node defaults (no per-request cap; long header
phase). The server now applies configurable requestTimeout (30s), headersTimeout
(15s), and keepAliveTimeout (5s) — see EXPRESS_*_TIMEOUT_MS in .env.example; set
0 to fall back to the Node default for any of them.
error.core emitted JSON errors as { success, status, message }, diverging from the
documented response envelope { status, code, message, data, meta } used everywhere else
(controllers, the validator core, the rate-limit message). Clients had to special-case
error shapes, and status carried a different type (boolean vs numeric code) than the
rest of the API. 404 and error responses now use the standard envelope (errors still add
stack outside production). This is a response-shape change for error paths in 3.0.0.
helmetwith a restrictive CSP;x-powered-bydisabled.- Only
./publicand/uploadsare served statically — the fullstorage/root is not exposed. Common.Hash.equalsusescrypto.timingSafeEqual;Cryptuses AES-256-GCM (authenticated) with a random IV and salt per message.Common.Storageresolves every path inside the storage root and rejects traversal.- Graceful shutdown drains the queue and closes connections.
-
APP_ENV=production(hides stack traces). - Set explicit
CORS_ORIGIN/SOCKET_CORS_ORIGIN(no*). - Strong, unique
APP_KEY,JWT_SECRET,JWT_REFRESH_SECRET; never committed. -
EXPRESS_TRUST_PROXYmatches your proxy topology. - Review
EXPRESS_BODY_LIMITand the rate-limit window/max. - Replace demo auth with real user storage and password hashing.
- Restrict upload types; treat SVG/HTML as attachments.
- Run behind TLS; enable
MAIL_SECURE/REDIS_TLSwhere applicable. -
npm auditclean (or risks accepted and tracked). - Single PM2 fork instance, or Redis-backed for multi-instance.
Report vulnerabilities privately to the maintainer rather than via public issues. Include a description, affected version, and reproduction steps.