Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/browser-utils/src/metrics/lcp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ export function _sendStandaloneLcpSpan(
entry.element && (attributes['lcp.element'] = htmlTreeAsString(entry.element));
entry.id && (attributes['lcp.id'] = entry.id);

// Trim URL to the first 200 characters.
entry.url && (attributes['lcp.url'] = entry.url.trim().slice(0, 200));
entry.url && (attributes['lcp.url'] = entry.url);
Copy link

Choose a reason for hiding this comment

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

Bug: Data URL Truncation Risk in URL Handling

Removing the truncation of entry.url without handling data URLs could cause issues when the LCP element uses a data URL (e.g., data:image/png;base64,<very long base64 string>). Unlike globalhandlers.ts which has special handling for data URLs (lines 210-215), this code directly assigns the URL without any length protection. Data URLs with embedded base64 images can be extremely long (potentially megabytes), which could cause problems with attribute storage, transmission, or display in the Sentry UI.

Fix in Cursor Fix in Web


// loadTime is the time of LCP that's related to receiving the LCP element response..
entry.loadTime != null && (attributes['lcp.loadTime'] = entry.loadTime);
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/src/integrations/globalhandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,5 +214,5 @@ function getFilenameFromUrl(url: string | undefined): string | undefined {
return `<data:${mimeType}${isBase64 ? ',base64' : ''}>`;
}

return url.slice(0, 1024);
return url; // it's fine to not truncate it as it's not put in a regex (https://codeql.github.com/codeql-query-help/javascript/js-polynomial-redos)
}
Loading