fix: vanna CVE-2024-5565 by disable visualize of ask func (#4930)

This commit is contained in:
takatost 2024-06-05 00:46:22 +08:00 committed by GitHub
parent 37f292ea91
commit 09298a32e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -102,7 +102,17 @@ class VannaTool(BuiltinTool):
if memos:
vn.train(documentation=memos)
generate_chart = tool_parameters.get("generate_chart", True)
#########################################################################################
# Due to CVE-2024-5565, we have to disable the chart generation feature
# The Vanna library uses a prompt function to present the user with visualized results,
# it is possible to alter the prompt using prompt injection and run arbitrary Python code
# instead of the intended visualization code.
# Specifically - allowing external input to the librarys “ask” method
# with "visualize" set to True (default behavior) leads to remote code execution.
# Affected versions: <= 0.5.5
#########################################################################################
generate_chart = False
# generate_chart = tool_parameters.get("generate_chart", True)
res = vn.ask(prompt, False, True, generate_chart)
result = []