Skip to content
Back to snapcart-api report
SecurityCritical

Sensitive Data in Error Responses

src/middleware/error.ts:9

What's going on

Unhandled exceptions bubble up raw stack traces and internal query shapes to the API client, leaking schema details and potentially sensitive values.

Why it matters

Error output is a reconnaissance goldmine for attackers. Once the exposed shape of the system is known, every other vulnerability becomes much easier to exploit.

src/middleware/error.ts:9

Recommended Fix

Replace the inline query with a parameterized statement and validate the id before it ever reaches the database. A regression test is generated alongside the patch.

Before
1export function onError(err: unknown, req: Request, res: Response) {2  console.error(err);3  // raw stack is returned to the client:4  res.status(500).json({ error: String(err) });5}
After
1export function onError(err: unknown, req: Request, res: Response) {2  console.error(err);3  const code = err instanceof AppError ? err.status : 500;4  res.status(code).json({5    error: "internal error",6    requestId: req.id,7  });8}
  1. Uploaddone
  2. Analyzedone
  3. Finddone
  4. Explainactive
  5. Fixupcoming
  6. Testupcoming
  7. Verifyupcoming