Skip to content

🐞[Bug]: CSP Report Endpoint Logs Unsanitized Payload Instead of Sanitized Report #1337

@Krishnx21

Description

@Krishnx21

Related Area

Frontend

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

The CSP reporting endpoint in web/src/app/api/csp-report/route.ts creates a sanitized version of the incoming CSP report (cspReport) by processing fields such as:

document-uri
referrer
blocked-uri

However, the endpoint later logs the original report object instead of the sanitized cspReport object.

As a result, the sanitization logic is not consistently applied to logged data, and any sensitive information present elsewhere in the CSP payload may still appear in application logs.

This creates an inconsistency between the intended sanitized output and the actual data being logged.

Expected behavior

The endpoint should consistently use the sanitized CSP report object whenever report data is written to logs, ensuring that the sanitization process is effective.

Actual behavior

The original unsanitized report payload is logged, which bypasses the sanitization logic already implemented in the handler.

Steps to Reproduce:-

Submit a CSP violation report containing URLs with query parameters or additional metadata.
Trigger the /api/csp-report endpoint.
Check the server logs.
Observe that the original report object is logged instead of the sanitized report.

Add ScreenShots

No response

What browsers are you seeing the problem on?

chrome

Record

  • I have read the Contributing Guidelines
  • I'm a GSSOC'24 contributor
  • I'm a GSSOC'26 contributor
  • I'm a IEEE IGDTUW contributor
  • I want to work on this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions