-
Notifications
You must be signed in to change notification settings - Fork 286
Reduce default fs_read trust permission to current working directory only #2824
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually have a separate PR for this change: #2817
But I guess since that PR isn't merged, this change is also showing here
None if is_in_allowlist => PermissionEvalResult::Allow, | ||
_ => PermissionEvalResult::Ask, | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that I am also changing the behavior for the case that "fs_read" is not explicitly defined in agent.tools_settings to re-use the big chunk of code above as if the fs_read is an empty json (no allowed path, no denied path, etc)
f0b1bb3
to
f08ccb6
Compare
…only Previously by default fs_read is trusted to read any file on user's file system. This PR reduces the fs_read permission to CWD only. This means user can still access any file under CWD without prompt. But if user needs to access file outside CWD, she will be prompted for explicit approval. User can still explicitly add fs_read to trusted tools in chat / agent definition so fs_read can read any file without prompt. This change essentially adds a layer of defense against prompt injection by following the least-privilege principle.
f08ccb6
to
bb81560
Compare
Thanks for contributing this! I have a few questions:
|
Hi @evanliu048
|
After reading about the recent security incident in nx, I started to worry about the risks of prompt injection. Personally, I’ve configured my agent prompt not to read files outside the CWD directory. From a security perspective, I think this PR could be helpful. On the other hand, it might also be a good idea to add an additional option in fs_read’s toolSettings to “trust files under the current CWD.” |
@@ -114,23 +114,31 @@ impl FsRead { | |||
} | |||
|
|||
fn default_allow_read_only() -> bool { | |||
true | |||
false | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we don’t need an extra method here — if we want the default to be false
, that’s already the default for bool.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed in latest rev @evanliu048
Description of changes:
Testing