Skip to content

Commit b288a7b

Browse files
committed
fix(gui): escape bot_name and bot_description to prevent XSS
bot_name and bot_description are interpolated directly into HTML without escaping, allowing a malicious user to inject JavaScript via a crafted bot configuration (e.g. <img src=x onerror=alert(...)>). Add html.escape() to both fields in format_cover_html(). Fixes #810
1 parent 31a4d36 commit b288a7b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

qwen_agent/gui/gradio_utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414

1515
import base64
16+
import html
1617

1718

1819
def covert_image_to_base64(image_path):
@@ -74,7 +75,7 @@ def format_cover_html(bot_name, bot_description, bot_avatar):
7475
<div class="bot_avatar">
7576
<img src="{image_src}" />
7677
</div>
77-
<div class="bot_name">{bot_name}</div>
78-
<div class="bot_desp">{bot_description}</div>
78+
<div class="bot_name">{html.escape(bot_name)}</div>
79+
<div class="bot_desp">{html.escape(bot_description)}</div>
7980
</div>
8081
"""

0 commit comments

Comments
 (0)