boxlang-express 0.2.29
Released .
boxExpressRateLimit( { handler } )(models/middleware/RateLimit.bx):handler: ( req, res, next, info ) => ...answers a limited request in place of the JSONmessage, as inexpress-rate-limit— so a route that serves HTML can render a page instead of handing a reader a JSON blob. The status and, withstandardHeaderson,Retry-Afterare set before it runs, sores.render( ... )goes out as a 429.infois{ limit, remaining, resetSeconds, key };resetSecondsis the value sent inRetry-After. It works the same with the in-memory store,cacheand a customstore. Withouthandlerthe response is unchanged. Ahandlerthat isn't a function throws when the middleware is created.- The session cookie is
Secureover HTTPS by default (models/middleware/Session.bx):boxExpressSession()'ssecureoption now defaults to"auto"instead offalse— the cookie gets theSecureflag wheneverreq.secureis true, so a site behind a TLS-terminating proxy (with"trust proxy"set) no longer sends its session id back over plain HTTP unless told to. Plain-HTTP requests are unchanged, andsecure: true/secure: falsestill force it either way; anything else throwsBoxExpress.InvalidOption. An app that is deliberately served over both HTTP and HTTPS and shares one session between them needssecure: false. - Changed default:
res.cookie()sendsSameSite=Lax(models/Response.bx). Until now a cookie got noSameSiteattribute unlesssameSitewas passed, leaving it to each browser's default. A cookie that must be sent on cross-site requests — an embedded widget, a login flow that posts back from another origin — now needs{ sameSite: "None", secure: true }.sameSite: falserestores the old behaviour (no attribute) andtruemeans"Strict".res.clearCookie()follows the same default. The session cookie was alreadyLax. - Changed default: at most 1000 parameters in a query string or
urlencoded body (
models/QueryString.bx). The byte limits alone allowed tens of thousands of keys per request. A query string over the limit is answered400before any middleware runs; set it withapp.set( "parameterLimit", n ). A urlencoded body over it is answered413; set it withboxExpressUrlencoded( { parameterLimit: n } ).0turns either off. A repeated key counts once per appearance, and the request is refused, not truncated. - Changed default:
boxExpressUpload()takes at most 100 files and 1000 fields (models/middleware/Multipart.bx), with newmaxFilesandmaxFieldsoptions; over either is a413and nothing is written todest.0turns a limit off. boxExpressRateLimit( { maxKeys } )(models/middleware/RateLimit.bx): the in-memory store counts at mostmaxKeyskeys (default100000) separately. Past that, a key not already being counted goes into one shared bucket until others expire, so a flood of distinct keys can neither grow memory without limit nor get through uncounted. A warning is logged at most once a minute while it's full.0removes the cap;cacheandstoreare unaffected.SECURITY.md: how to report a vulnerability privately, which versions get fixes, and what's in scope.models/middleware/Csrf.bx's header comment said the token comparison wasn't constant-time; it has been since 0.2.20. Comment only.