processing / processing/p5.js-web-editor

Raw error objects leaked in 500 responses across several controllers

Open
#3,898 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Help Wanted
Dominant language
JavaScript
Stars
1.7k
Forks
1.7k
Avg merge
3d 4h
Merged PRs (30d)
8

Description

p5.js version

No response

What is your operating system?

None

Web browser and version

No response

Actual Behavior

Multiple catch blocks in server controllers send the raw err object
straight into res.json(). This means stack traces, mongoose internals,
and whatever else lives on the error can end up in the response body.

Affected spots:

  • server/controllers/user.controller/signup.ts L79, L161 → res.status(500).json({ error: err })
  • server/controllers/user.controller/userPreferences.ts L36, L64 → same
  • server/controllers/user.controller/authManagement.ts L204 → same
  • server/controllers/user.controller/helpers.ts L70 → res.status(500).json({ error }) (shared saveUser helper, so this one fans out)
  • server/controllers/project.controller.js L349 → res.status(500).json(error) — the error is the response body, no wrapping at all

Why the global error handler doesn't help here:

The fallback at server.js L199 sends a safe generic string, but it
only fires for errors passed through next(). All the spots above call
res.json() directly and never hit next(),..so the middleware is
completely bypassed.

Expected Behavior

500s should return something like { error: "Internal Server Error" }
and the real error should just be console.error'd

Steps to reproduce

Trigger any DB error in the affected routes (e.g., kill mongo mid-request, send malformed data to /preferences, etc). Check the network tab, you'll see the full error object with stack trace in the response body instead of a sanitized message

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the listed catch blocks in server/controllers/user.controller/signup.ts, userPreferences.ts, authManagement.ts, helpers.ts, and server/controllers/project.controller.js, then compare them with the fallback in server.js. Trigger a database failure and confirm affected 500 responses contain only a generic error while the real error is logged rather than serialized.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
api, backend, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.