Skip to content

fix(chat): allow file-only messages with no text to be sent in chat panel and deployed chat - #1635

Merged
waleedlatif1 merged 1 commit into
stagingfrom
fix/chat
Oct 15, 2025
Merged

fix(chat): allow file-only messages with no text to be sent in chat panel and deployed chat#1635
waleedlatif1 merged 1 commit into
stagingfrom
fix/chat

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

allow file-only messages with no text to be sent in chat panel and deployed chat

Type of Change

  • Bug fix

Testing

Tested manually by sending messages with no text and only images.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercelBot commented Oct 15, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
ProjectDeploymentPreviewCommentsUpdated (UTC)
docsSkippedSkippedOct 15, 2025 3:26am

@waleedlatif1
waleedlatif1 merged commit 7595e54 into stagingOct 15, 2025
4 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/chat branch October 15, 2025 03:27

@greptile-appsgreptile-appsBot 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.

Greptile Overview

Summary

Enables sending messages with file attachments only (no text required) in both chat panel and deployed chat by conditionally rendering the message text bubble.

Key Changes:

  • Conditionally renders message bubble only when text content exists and doesn't start with "Sent"/"Uploaded"
  • Adds enhanced image attachment preview that opens in a new window with custom HTML
  • Adds validation to check dataUrl.startsWith('data:') before rendering images or enabling click handlers
  • Fixes missing useCallback dependencies in chat.tsx (chatFiles, isUploadingFiles, setter functions)

Critical Issues Found:

  • XSS vulnerabilities: attachment.name is directly interpolated into HTML (document.write) without escaping in 4 locations across 2 files. A malicious filename like </title><script>alert('XSS')</script> will execute JavaScript.

Confidence Score: 1/5

  • This PR contains critical XSS vulnerabilities that must be fixed before merging
  • Score reflects 4 XSS vulnerabilities where user-controlled filenames are injected into HTML without escaping. While the dependency array fix is correct, the security issues make this unsafe to merge.
  • Pay close attention to apps/sim/app/chat/components/message/message.tsx and apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/chat/components/chat-message/chat-message.tsx - both contain XSS vulnerabilities

Important Files Changed

File Analysis

FilenameScoreOverview
apps/sim/app/chat/components/message/message.tsx1/5Allows file-only messages by conditionally rendering text bubble; adds image preview in new window with XSS vulnerabilities in attachment.name handling
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/chat/chat.tsx4/5Added missing dependencies (chatFiles, isUploadingFiles, setChatMessage, setChatFiles, setUploadErrors) to handleSendMessage useCallback
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/chat/components/chat-message/chat-message.tsx1/5Allows file-only messages by conditionally rendering text bubble; adds image preview in new window with XSS vulnerabilities in attachment.name handling

Sequence Diagram

sequenceDiagram
participant User
participant ChatInput
participant ChatComponent
participant MessageComponent
participant Browser
User->>ChatInput: Upload file + optional text
ChatInput->>ChatComponent: handleSendMessage()
alt Has text content
ChatComponent->>MessageComponent: Render attachments + text bubble
else File-only (no text)
ChatComponent->>MessageComponent: Render attachments only (skip text bubble)
end
User->>MessageComponent: Click attachment
MessageComponent->>MessageComponent: Check dataUrl.startsWith('data:')
MessageComponent->>Browser: window.open('', '_blank')
MessageComponent->>Browser: document.write(HTML with attachment.name)
Browser->>User: Display attachment in new window
Loading

3 files reviewed, 4 comments

Edit Code Review Agent Settings | Greptile

<!DOCTYPE html>
<html>
<head>
<title>${attachment.name}</title>

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.

logic: XSS vulnerability: ${attachment.name} is not HTML-escaped. If a user uploads a file named &lt;/title&gt;&lt;script&gt;alert('XSS')&lt;/script&gt;, it will execute JavaScript in the new window.

Suggested change
<title>${attachment.name}</title>
<title>${attachment.name.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/"/g,'&quot;').replace(/'/g,'&#39;')}</title>
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/app/chat/components/message/message.tsx
Line: 105:105
Comment:
**logic:** XSS vulnerability: `${attachment.name}` is not HTML-escaped. If a user uploads a file named `&lt;/title&gt;&lt;script&gt;alert('XSS')&lt;/script&gt;`, it will execute JavaScript in the new window.
```suggestion <title>${attachment.name.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#39;')}</title>```
How can I resolve this? If you propose a fix, please make it concise.

</style>
</head>
<body>
<img src="${validDataUrl}" alt="${attachment.name}" />

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.

logic: XSS vulnerability: ${attachment.name} in the alt attribute is not HTML-escaped.

Suggested change
<imgsrc="${validDataUrl}"alt="${attachment.name}"/>
<imgsrc="${validDataUrl}"alt="${attachment.name.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g,'&quot;').replace(/'/g,'&#39;')}" />
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/app/chat/components/message/message.tsx
Line: 112:112
Comment:
**logic:** XSS vulnerability: `${attachment.name}` in the alt attribute is not HTML-escaped.
```suggestion <img src="${validDataUrl}" alt="${attachment.name.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#39;')}" />```
How can I resolve this? If you propose a fix, please make it concise.

<!DOCTYPE html>
<html>
<head>
<title>${attachment.name}</title>

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.

logic: XSS vulnerability: ${attachment.name} is not HTML-escaped.

Suggested change
<title>${attachment.name}</title>
<title>${attachment.name.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/"/g,'&quot;').replace(/'/g,'&#39;')}</title>
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/chat/components/chat-message/chat-message.tsx
Line: 113:113
Comment:
**logic:** XSS vulnerability: `${attachment.name}` is not HTML-escaped.
```suggestion <title>${attachment.name.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#39;')}</title>```
How can I resolve this? If you propose a fix, please make it concise.

</style>
</head>
<body>
<img src="${validDataUrl}" alt="${attachment.name}" />

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.

logic: XSS vulnerability: ${attachment.name} in the alt attribute is not HTML-escaped.

Suggested change
<imgsrc="${validDataUrl}"alt="${attachment.name}"/>
<imgsrc="${validDataUrl}"alt="${attachment.name.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g,'&quot;').replace(/'/g,'&#39;')}" />
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/chat/components/chat-message/chat-message.tsx
Line: 120:120
Comment:
**logic:** XSS vulnerability: `${attachment.name}` in the alt attribute is not HTML-escaped.
```suggestion <img src="${validDataUrl}" alt="${attachment.name.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#39;')}" />```
How can I resolve this? If you propose a fix, please make it concise.

Sign up for freeto 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

@waleedlatif1