Skip to content

fix(ci): update Gemini model and harden update-skill against prompt injection - #991

Merged
dkhawk merged 1 commit into
mainfrom
fix/update-skill-gemini-model
Nov 24, 2026
Merged

dkhawk merged 1 commit into
mainfrom
fix/update-skill-gemini-model

Conversation

@dkhawk

@dkhawk dkhawk commented Sep 4, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Updates the Gemini model in .github/scripts/update_skill.py to default to gemini-3.8-flash and implements comprehensive hardening across .github/scripts/update_skill.py and .github/workflows/update-skill.yml to protect against indirect prompt injection and supply-chain tampering (referencing GHSA-8f2g-33j4-ghwg).

Background & Vulnerability

External pull requests or commit messages in release diffs can contain adversarial prompt directives. If ingested unescaped, an attacker could manipulate update_skill.py into injecting malicious instructions or compromised dependencies into .gemini/skills/android-maps-compose/SKILL.md.

Hardening Measures Applied

  1. API Role Separation (system_instruction):
    • Uses Gemini API's top-level system_instruction parameter to isolate operational rules and security boundaries from untrusted diff content.
  2. Input Fencing & Sanitization:
    • Encloses inputs inside <current_skill_file> and <untrusted_release_diff> XML blocks and sanitizes potential delimiter escape sequences.
    • Caps diff input length at 60k characters to prevent context exhaustion attacks.
  3. Diff Scope Filtering:
    • Scopes git diff to code and build files only, explicitly excluding documentation (*.md, *.txt), images, and workflow files (.github/) where natural language injections typically hide.
  4. Deterministic Pre-Commit Guardrails (validate_skill_content):
    • Verifies YAML frontmatter integrity.
    • Verifies preservation of critical version anchors (// x-release-please-version).
    • Rejects suspicious content drift (length ratio < 0.5 or > 2.0).
    • Scans for known prompt injection phrases and shell execution patterns before writing to disk.
  5. Workflow & CI/CD Protections:
    • Removed the automerge label so AI-generated skill updates always require maintainer approval.
    • Configured peter-evans/create-pull-request to create draft PRs with required reviewers (LoyalAbbas, kikoso).
    • Updated bot author/committer emails to use googlemaps-bot@users.noreply.github.com.
    • Added Python cache (__pycache__/, *.py[cod]) to .gitignore.

@dkhawk
dkhawk requested review from LoyalAbbas and kikoso September 4, 2026 18:09
@dkhawk
dkhawk marked this pull request as ready for review September 4, 2026 18:23
@dkhawk
dkhawk requested a review from a team as a code owner September 4, 2026 18:23
@googlemaps-bot

googlemaps-bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Code Coverage

Overall Project 24.66% ❌

There is no coverage information present for the Files changed

@dkhawk
dkhawk force-pushed the fix/update-skill-gemini-model branch from 27727a6 to 273cebc Compare September 4, 2026 19:54
@dkhawk dkhawk changed the title fix(ci): update Gemini model in update_skill script to gemini-3.5-flash fix(ci): update Gemini model in update_skill script to gemini-3.8-flash Sep 4, 2026
@dkhawk
dkhawk marked this pull request as draft September 4, 2026 19:58
@dkhawk dkhawk changed the title fix(ci): update Gemini model in update_skill script to gemini-3.8-flash fix(ci): update Gemini model and harden update-skill against prompt injection Sep 8, 2026
@dkhawk
dkhawk marked this pull request as ready for review September 8, 2026 17:07
@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

Coverage (unit tests)

Compared against b418c7b on main (#1094).

Module Line % Change Branch % Change
maps-compose 45.82% no change 15.23% no change
maps-compose-utils 26.29% no change 12.70% no change
maps-compose-widgets 3.87% no change 0.00% no change
TOTAL 38.93% no change 14.22% no change

Line and branch coverage from unit test reports. History is recorded on the coverage-history branch after each merge to main.

@kikoso
kikoso force-pushed the fix/update-skill-gemini-model branch from eb97ddf to 3883f24 Compare September 21, 2026 04:29

@kikoso kikoso left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@googlemaps-bot

Copy link
Copy Markdown
Contributor

Coverage (instrumentation tests)

Overall Project 45.89% 🍏

There is no coverage information present for the Files changed

@LoyalAbbas LoyalAbbas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

PREVIOUS_TAG=$(git describe --tags --abbrev=0 ${GITHUB_REF_NAME}^ 2>/dev/null || echo "")

# Scope diff to code and build changes, excluding docs and workflows to reduce injection surface
DIFF_OPTS="-- . ':(exclude)*.md' ':(exclude).github' ':(exclude)*.txt' ':(exclude)*.png' ':(exclude)*.jpg'"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to understand it: do we need eval here? A bash array would keep the pathspecs quoted without re-parsing the whole line, something like DIFF_OPTS=(-- . ':(exclude)*.md' ':(exclude).github' ...) and then git diff "$PREVIOUS_TAG..$GITHUB_REF_NAME" "${DIFF_OPTS[@]}".

raise ValueError("Validation failed: Output is missing valid YAML frontmatter delimiters (---)")

# 2. Release-please anchor check: must preserve version anchor comments
if "// x-release-please-version" in original and "// x-release-please-version" not in updated:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this passes as long as one anchor survives. Should we compare the counts instead, so dropping only some of the // x-release-please-version comments is also caught?

Suggested change
if "// x-release-please-version" in original and "// x-release-please-version" not in updated:
if updated.count("// x-release-please-version") < original.count("// x-release-please-version"):

@kikoso kikoso left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a rebase, @dkhawk , it conflicts with main now. Minor comments, but looks good!

@dkhawk
dkhawk force-pushed the fix/update-skill-gemini-model branch from 85f6b72 to 673b0a1 Compare November 24, 2026 19:05
@dkhawk
dkhawk enabled auto-merge (squash) November 24, 2026 19:06
@dkhawk
dkhawk merged commit 14f18d0 into main Nov 24, 2026
13 of 14 checks passed
@dkhawk
dkhawk deleted the fix/update-skill-gemini-model branch November 24, 2026 19:19
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.

4 participants