You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
API parses request bodies up to 32 MB before auth #3831
Without a login or API key, anyone can make the API parse a 32 MB body before it answers 401. Four such requests took the API from 58 MB to 1,064 MB of memory.
What happened?
api-app.ts runs express.json / text / urlencoded with limit: '32mb' on every route, before any auth check. So /login/password, /register/password and every protected route read and parse the whole body before rejecting the caller.
Each returns 401 after about a second, and the API's memory grows by about 250 MB per request.
Why I don't think it's a P0
It only affects availability. Many deployments sit behind a reverse proxy or ingress that caps bodies at 1 MB by default, so they're safe. The default docker-compose.yml publishes the API port, though, and the app's /api proxy streams bodies through with no limit.
Is the 32 MB limit before auth intentional? and did I miss something with this
Does any unauthenticated route need more than 100 KB?
Should the limits be configurable?
Proposed fix
Parse bodies after the session loads. A session, a valid API key or local mode keeps 32mb; everyone else gets 100kb. The caller check runs only when the body could be over 100 KB. I have a branch with tests and can open the PR.
Activity