langchain
langchain copied to clipboard
Arbitrary code execution in JiraAPIWrapper
System Info
LangChain version:0.0.171 windows 10
Who can help?
No response
Information
- [X] The official example notebooks/scripts
- [ ] My own modified scripts
Related Components
- [ ] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [X] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async
Reproduction
- Set the environment variables for jira and openai
import os
from langchain.utilities.jira import JiraAPIWrapper
os.environ["JIRA_API_TOKEN"] = "your jira api token"
os.environ["JIRA_USERNAME"] = "your username"
os.environ["JIRA_INSTANCE_URL"] = "your url"
os.environ["OPENAI_API_KEY"] = "your openai key"
- Run jira
jira = JiraAPIWrapper()
output = jira.run('other',"exec(\"import os;print(os.popen('id').read())\")")
- The
id
command will be executed. Commands can be change to others and attackers can execute arbitrary code.
Expected behavior
The code cannot be executed without any check.
@zywilliamli @hwchase17
I think the options here are to either a) check code to a limited number of allowed actions, or b) remove the "other" method from the tool.
It looks like we want the jira tool to:
- Create an issue
- search jira
- get projects
I'm not sure what other functionality we want to extend to with self.other, maybe y'all know how to proceed best
This is another critical bug that is deployment breaking for many: https://nvd.nist.gov/vuln/detail/CVE-2023-34540
See: #4849 #6627
@hwchase17
Hi. I still getting this error in scan: https://nvd.nist.gov/vuln/detail/CVE-2023-34540 Can we reopen?
@aiakubovich for Jira, this should be fixed in most recent version, so updating langchain version should remove the error
Confirming this is fixed in https://github.com/langchain-ai/langchain/pull/6992 and published in v0.0.225. Versions v0.0.225 and newer should not be affected.
You can confirm this by noting:
- the tag for v0.0.225 is shown in the GitHub UI on the merge commit for #6992
- the generated release notes for v0.0.225 show that #6992 was part of that release: https://github.com/langchain-ai/langchain/releases/tag/v0.0.225
@aiakubovich I'm opening a PR to the advisory database to update that CVE as fixed in v0.0.225, which should stop it from being reported on your end once your scanner tool sees the updated database entry.
If you're still seeing this problem ~next week, please give us a ping and we can dig in deeper together.
Thanks for your patience on this! We're working to make this process smoother in the future.
CVE-2023-34540