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

[bug] Arbitrary code execution in from_rail_string #950

Open
AlejandroEsquivel opened this issue Jul 19, 2024 · 1 comment
Open

[bug] Arbitrary code execution in from_rail_string #950

AlejandroEsquivel opened this issue Jul 19, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@AlejandroEsquivel
Copy link
Contributor

Describe the bug
It seems certain crafted RAIL specs and using from_rail_string can allow arbitrary code execution.

To Reproduce
Steps to reproduce the behavior:

from guardrails import Guard

railstring = """<rail version="0.1">
<output
type="string"
validators="test:{print('\n\narbitrary code execution\n\n')};"
/>
</rail>"""

Guard.from_rail_string(railstring)

Expected behavior
Prevent arbitrary code execution from RAIL specs

Library version:
0.5.0 And likely others

@AlejandroEsquivel AlejandroEsquivel added the bug Something isn't working label Jul 19, 2024
@CalebCourier
Copy link
Collaborator

CalebCourier commented Jul 24, 2024

Yes, this is a known issue but also a large concern we need to address before we ever offer a managed service. Since this always occurs on the client, it's slightly less serious than a traditional system, but I agree it should still be addressed. The limiting factor here is data. With RAIL we don't know what the arguments are intended to be which makes them more difficult to parse.
See this comment for a couple options for how to try to address this.
https://github.com/guardrails-ai/guardrails/blob/main/guardrails/utils/validator_utils.py#L30-L35

[edit]: update comment link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants