Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🧐[问题] Chat component renders HTML leading to potential XSS attacks #322

Closed
SSK-14 opened this issue Sep 28, 2024 · 2 comments
Closed

Comments

@SSK-14
Copy link

SSK-14 commented Sep 28, 2024

🧐 问题描述

When the chat output/input contains markdown content starting with code fences ``` without specifying a language (e.g., (code fences)html or (code fences)bash), it defaults to txt. If there is HTML code inside it, the HTML gets rendered, making the component prone to XSS attacks. Is there any way to overcome this issue?

💻 示例代码

code fences

<form action="action_page.php" method="post">

  <div class="imgcontainer">
    <img src="img_avatar2.png" alt="Avatar" class="avatar">
  </div>
  
  <div class="container">
    <label for="uname"><b>Username</b></label>
    <input type="text" placeholder="Enter Username" name="uname" required>
    
    <label for="psw"><b>Password</b></label>
    <input type="password" placeholder="Enter Password" name="psw" required>
    
    <label>
      <input type="checkbox" checked="checked" name="remember"> Remember me
    </label>

    <button type="submit">Login</button>
  </div>
  
  <div class="container" style="background-color:#f1f1f1">
    <button type="button" class="cancelbtn">Cancel</button>
    <span class="psw">Forgot <a href="#">password?</a></span>
  </div>
  
</form>

code fences

Screenshot 2024-09-27 at 5 55 21 PM

🚑 其他信息
No additional information at the moment, but the issue is relevant for security and user content sanitization.

@SSK-14 SSK-14 changed the title 🧐[问题] 🧐[问题] Chat component renders HTML leading to potential XSS attacks Sep 29, 2024
@ONLY-yours
Copy link
Collaborator

by design, we not suggest u should render some html dom in Markdown, it can do it, but not suggested

the good way is use ChatItemRenderConfig to render a custom dom

looking about this: https://pro-chat.antdigital.dev/guide/chat-item-render-config

we made a case about this

@ONLY-yours
Copy link
Collaborator

@SSK-14

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

No branches or pull requests

2 participants