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

Replace JIRA Arbitrary Code Execution vulnerability with finer grain API wrapper #6992

Merged
merged 4 commits into from
Jul 5, 2023

Conversation

JamalRahman
Copy link
Contributor

This fixes #4833 and the critical vulnerability https://nvd.nist.gov/vuln/detail/CVE-2023-34540

Previously, the JIRA API Wrapper had a mode that simply pipelined user input into an exec() function.
The intended use of the 'other' mode is to cover any of Atlassian's API that don't have an existing interface

Fortunately all of the Atlassian JIRA API methods are subfunctions of their Jira class, so this implementation calls these subfunctions directly.

As well as passing a string representation of the function to call, the implementation flexibly allows for optionally passing args and/or keyword-args. These are given as part of the dictionary input. Example:

    {
        "function": "update_issue_field",   #function to execute
        "args": [                           #list of ordered args similar to other examples in this JiraAPIWrapper
            "key",
            {"summary": "New summary"}
        ],
        "kwargs": {}                        #dict of key value keyword-args pairs
    }

the above is equivalent to self.jira.update_issue_field("key", {"summary": "New summary"})

Alternate query schema designs are welcome to make querying easier without passing and evaluating arbitrary python code. I considered parsing (without evaluating) input python code and extracting the function, args, and kwargs from there and then pipelining them into the callable function via *f(args, **kwargs) - but this seemed more direct.

@vowelparrot @dev2049

@vercel
Copy link

vercel bot commented Jun 30, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
langchain ⬜️ Ignored (Inspect) Jul 1, 2023 0:26am

@dosubot dosubot bot added the 🤖:improvement Medium size change to existing code to handle new use-cases label Jun 30, 2023
Copy link
Contributor

@hwchase17 hwchase17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice - thanks!

@JamalRahman
Copy link
Contributor Author

@hwchase17 @baskaryan

Are you ok to merge as I don't have write access

Thanks 🙂

@hwchase17 hwchase17 merged commit a2f191a into langchain-ai:master Jul 5, 2023
14 checks passed
aerrober pushed a commit to aerrober/langchain-fork that referenced this pull request Jul 24, 2023
…API wrapper (langchain-ai#6992)

This fixes langchain-ai#4833 and the critical vulnerability
https://nvd.nist.gov/vuln/detail/CVE-2023-34540

Previously, the JIRA API Wrapper had a mode that simply pipelined user
input into an `exec()` function.
[The intended use of the 'other' mode is to cover any of Atlassian's API
that don't have an existing
interface](https://github.com/hwchase17/langchain/blob/cc33bde74ff2e050a400e4451e04ff5b32c4a7bd/langchain/tools/jira/prompt.py#L24)

Fortunately all of the [Atlassian JIRA API methods are subfunctions of
their `Jira`
class](https://atlassian-python-api.readthedocs.io/jira.html), so this
implementation calls these subfunctions directly.

As well as passing a string representation of the function to call, the
implementation flexibly allows for optionally passing args and/or
keyword-args. These are given as part of the dictionary input. Example:
```
    {
        "function": "update_issue_field",   #function to execute
        "args": [                           #list of ordered args similar to other examples in this JiraAPIWrapper
            "key",
            {"summary": "New summary"}
        ],
        "kwargs": {}                        #dict of key value keyword-args pairs
    }
```

the above is equivalent to `self.jira.update_issue_field("key",
{"summary": "New summary"})`

Alternate query schema designs are welcome to make querying easier
without passing and evaluating arbitrary python code. I considered
parsing (without evaluating) input python code and extracting the
function, args, and kwargs from there and then pipelining them into the
callable function via `*f(args, **kwargs)` - but this seemed more
direct.

@vowelparrot @dev2049

---------

Co-authored-by: Jamal Rahman <jamal.rahman@builder.ai>
obi1kenobi added a commit to obi1kenobi/advisory-database that referenced this pull request Aug 28, 2023
That advisory corresponds to:
- this issue, which is closed as completed: langchain-ai/langchain#4833
- this PR, which is merged: langchain-ai/langchain#6992
- this fix release, which references the above PR in the release notes: https://github.com/langchain-ai/langchain/releases/tag/v0.0.225
sethmlarson pushed a commit to pypa/advisory-database that referenced this pull request Aug 28, 2023
That advisory corresponds to:
- this issue, which is closed as completed: langchain-ai/langchain#4833
- this PR, which is merged: langchain-ai/langchain#6992
- this fix release, which references the above PR in the release notes: https://github.com/langchain-ai/langchain/releases/tag/v0.0.225
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:improvement Medium size change to existing code to handle new use-cases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Arbitrary code execution in JiraAPIWrapper
2 participants