Require confirmation for fetch tool (#36881)

Using prompt injection, the agent may be tricked into making a fetch
request that includes unexpected data from the conversation in the URL.

As agent conversations may contain sensitive information (like private
code, or
potentially even API keys), this seems bad.

The easiest way to prevent this is to require the user to look at the
URL
before the model is allowed to fetch it.

Thanks to @ant4g0nist for bringing this to our attention.

Release Notes:

- agent panel: The fetch tool now requires confirmation.
This commit is contained in:
Conrad Irwin 2025-08-25 10:03:07 -06:00 committed by GitHub
parent 2dc4f156b3
commit a102b08743
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 3 deletions

View file

@ -136,12 +136,17 @@ impl AgentTool for FetchTool {
fn run( fn run(
self: Arc<Self>, self: Arc<Self>,
input: Self::Input, input: Self::Input,
_event_stream: ToolCallEventStream, event_stream: ToolCallEventStream,
cx: &mut App, cx: &mut App,
) -> Task<Result<Self::Output>> { ) -> Task<Result<Self::Output>> {
let authorize = event_stream.authorize(input.url.clone(), cx);
let text = cx.background_spawn({ let text = cx.background_spawn({
let http_client = self.http_client.clone(); let http_client = self.http_client.clone();
async move { Self::build_message(http_client, &input.url).await } async move {
authorize.await?;
Self::build_message(http_client, &input.url).await
}
}); });
cx.foreground_executor().spawn(async move { cx.foreground_executor().spawn(async move {

View file

@ -118,7 +118,7 @@ impl Tool for FetchTool {
} }
fn needs_confirmation(&self, _: &serde_json::Value, _: &Entity<Project>, _: &App) -> bool { fn needs_confirmation(&self, _: &serde_json::Value, _: &Entity<Project>, _: &App) -> bool {
false true
} }
fn may_perform_edits(&self) -> bool { fn may_perform_edits(&self) -> bool {