pro-chat icon indicating copy to clipboard operation
pro-chat copied to clipboard

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

Open SSK-14 opened this issue 1 year ago • 0 comments

🧐 问题描述

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 avatar Sep 28 '24 11:09 SSK-14