Skip to content

chore(ci): harden Gemini issue triage against prompt injection - #992

Open
kikoso wants to merge 1 commit into
mainfrom
chore/harden-issue-triage
Open

chore(ci): harden Gemini issue triage against prompt injection#992
kikoso wants to merge 1 commit into
mainfrom
chore/harden-issue-triage

Conversation

@kikoso

@kikoso kikoso commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open a GitHub issue as a bug/feature request before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Description

We received an external security report noting that issue titles and bodies flow untrusted into the Gemini prompts used by the issue triage workflow, so a crafted issue can steer the model output that drives label application (prompt injection). The practical impact is limited (the workflow already only applies one priority:* label to the triggering issue), but this PR tightens the trust boundary:

  • Validate model output in triage_issue.py against an exact allowlist of the five priority labels. Non-strings are dropped, whitespace and newlines are collapsed before comparison, and anything outside the set is discarded.
  • Strip newlines from the script output before writing to GITHUB_OUTPUT, so untrusted output cannot inject additional output keys.
  • Wrap the untrusted issue content in <issue_content> delimiters in both triage_issue.py and answer_issue.py and instruct the model to treat it as data only, ignoring any instructions inside it.
  • Add a per-issue concurrency group with cancel-in-progress: true, so rapid edit loops on a single issue cancel the in-flight run instead of stacking Gemini API calls (quota abuse).

No library code is touched, so no breaking changes and no release is needed (hence the chore(ci) prefix). This addresses a privately reported security concern, so there is no public tracking issue. A matching fix for android-maps-utils is in googlemaps/android-maps-utils#1772.

https://claude.ai/code/session_01DMAbzVdHqDdyoCKpub2bTC

Issue titles and bodies are untrusted input that flows into the Gemini
prompts used for triage labeling and auto-answering, so a crafted issue
can steer the model output that drives label application. This change
limits the blast radius:

- Validate model output against an exact allowlist of the five
  priority labels; drop anything else, including non-strings and
  labels containing newlines or extra whitespace.
- Strip newlines before writing to GITHUB_OUTPUT so script output
  cannot inject additional output keys.
- Wrap the untrusted issue content in delimiters in both triage and
  answer prompts and instruct the model to treat it as data only.
- Add a per-issue concurrency group with cancel-in-progress so rapid
  edit loops cannot stack Gemini API calls.

Claude-Session: https://claude.ai/code/session_01DMAbzVdHqDdyoCKpub2bTC
@kikoso
kikoso requested a review from a team as a code owner September 4, 2026 23:08
@googlemaps-bot

Copy link
Copy Markdown
Contributor

Code Coverage

Overall Project 24.59%

There is no coverage information present for the Files changed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants