fix(gmail): include draft id in update_draft tool schema#5925
fix(gmail): include draft id in update_draft tool schema#5925tsubasakong wants to merge 3 commits intoFlowiseAI:mainfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the Gmail Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request correctly addresses an issue where the update_draft tool in Gmail was missing the draft id in its schema. While the UpdateDraftSchema now includes the required id field, this field lacks validation, which could lead to a path traversal vulnerability by allowing an attacker to manipulate the API endpoint. It is recommended to add regex validation to the id field in the schema to mitigate this risk.
| }) | ||
|
|
||
| const UpdateDraftSchema = CreateDraftSchema.extend({ | ||
| id: z.string().describe('ID of the draft to update') |
There was a problem hiding this comment.
The id field in UpdateDraftSchema is defined as a plain string without any validation or sanitization. This value is used in UpdateDraftTool._call to construct the Gmail API request URL via string concatenation: https://gmail.googleapis.com/gmail/v1/users/me/drafts/${draftId}.
An attacker (e.g., via prompt injection) could provide a malicious id containing path traversal characters like ../ to manipulate the API endpoint. For example, an id of ../../labels/LABEL_ID would cause the tool to send a PUT request to the labels endpoint instead of the drafts endpoint. While the impact is limited to the authenticated user's scope (/me/), it allows for unauthorized actions on other Gmail resources not intended for this tool.
To remediate this, add validation to the id field using a regular expression to ensure it only contains valid Gmail resource ID characters and prevent path traversal.
| id: z.string().describe('ID of the draft to update') | |
| id: z.string().regex(/^[a-zA-Z0-9_-]+$/).describe('ID of the draft to update') |
|
are you able to test if this is now working correctly? |
Summary
UpdateDraftSchemafor the Gmailupdate_drafttoolidin that schema so agents can pass the draft identifier when updatingUpdateDraftToolto useUpdateDraftSchemainstead ofCreateDraftSchemaWhy
The current
update_draftschema does not expose draft id input, so agent calls can fail with "Draft ID is required" even when issue context includes it.Fixes #5916