Skip to content

🔒 Sanitize internal system errors in API responses#89

Merged
mbayue merged 1 commit into
masterfrom
jules-3638637770407784940-edf85745
Jul 5, 2026
Merged

🔒 Sanitize internal system errors in API responses#89
mbayue merged 1 commit into
masterfrom
jules-3638637770407784940-edf85745

Conversation

@mbayue

@mbayue mbayue commented Jul 4, 2026

Copy link
Copy Markdown
Owner

🎯 What: Modified toErrorPayload in server/utils/errors.ts to sanitize messages for 500-level HTTP errors.
⚠️ Risk: When system errors occur (e.g. database disconnects, file IO errors), their raw .message string could contain sensitive details such as file paths, connection strings, IPs, or passwords. Exposing this information directly in API responses results in an Information Disclosure vulnerability.
🛡️ Solution: Implemented logic to check if err.status >= 500. If so, the raw error message is suppressed and replaced with a generic 'Internal Server Error' string in the response payload. 400-level status codes retain their specific messages as they are generally safe validation/client errors.


PR created automatically by Jules for task 3638637770407784940 started by @mbayue


Summary by cubic

Sanitizes 500-level API error messages by returning "Internal Server Error" instead of the raw message to prevent sensitive info leaks. Leaves 4xx messages unchanged and adds tests to cover both paths.

Written for commit fe9c036. Summary will update on new commits.

Review in cubic

Co-authored-by: mbayue <70324722+mbayue@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.
Architecture diagram
sequenceDiagram
    participant Client
    participant API as API Route
    participant ErrorUtil as toErrorPayload
    participant System as Internal System (DB/IO)

    Client->>API: HTTP request
    API->>System: Internal operation (e.g., db.query)
    System-->>API: Error (status=500, message with sensitive info)

    alt status >= 500 (NEW: Sanitized)
        API->>ErrorUtil: toErrorPayload(error)
        Note over ErrorUtil: Replaces raw message with<br/>'Internal Server Error'
        ErrorUtil-->>API: { error: 'Internal Server Error', code, status, ... }
    else status < 500 (Unchanged: preserved message)
        API->>ErrorUtil: toErrorPayload(error)
        Note over ErrorUtil: Keeps original error.message
        ErrorUtil-->>API: { error: err.message, ... }
    end

    API-->>Client: HTTP response with sanitized payload
Loading

Re-trigger cubic

@mbayue mbayue merged commit 4dc03d6 into master Jul 5, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant