Skip to content

fix: Port skill resource path and skill name validation fixes to v1 - #6805

Merged
GWeale merged 2 commits into
v1from
backport-v1-pr16
Aug 19, 2026
Merged

fix: Port skill resource path and skill name validation fixes to v1#6805
GWeale merged 2 commits into
v1from
backport-v1-pr16

Conversation

@GWeale

@GWeale GWeale commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

This PR ports two skill-handling fixes to the v1 branch:

  1. Skill resource path validation (2f15c6cb)

    • Resource paths must normalize to a location inside the extraction
      directory; anything else fails the script run with PermissionError.
    • A filename beginning with .., such as ..config, is refused too;
      rename the file.
    • Nested paths such as subdir/notes.md still materialize.
  2. Skill name validation (11101acc)

    • GCPSkillRegistry.get_skill() requires a name matching
      models._SNAKE_OR_KEBAB_NAME_PATTERN, and raises ValueError before the
      resource path is built and before the client is called.
    • Rename any skill using characters outside a-z, 0-9, - and _.

Neither change has an opt-out.

GWeale added 2 commits August 17, 2026 23:04
The wrapper script generated by _SkillScriptCodeExecutor joined each skill
resource path onto the extraction directory as-is, so a resource named
"../../pwned" resolved outside that directory and its content was written
there before the skill script ran.

The generated code now normalizes each relative path, raises PermissionError
when the result starts with ".." or is absolute, and joins the remainder onto
the absolute extraction directory. Nested paths such as "subdir/notes.md"
still materialize. A resource whose filename itself begins with two dots, for
example "..config", is refused as well; this matches the upstream fix.

Ports the extraction hunk of upstream PR #5927. The unrelated
argument-validation refactors in that commit are not included.
…e path (v1)

GCPSkillRegistry.get_skill() interpolated the caller-supplied name straight
into "projects/.../locations/.../skills/{name}" and handed that to the Vertex
SDK, so a name containing a slash or "../" addressed a different resource than
the one asked for. The name comes from a model-issued tool call, so nothing
upstream of this point constrains it.

It now checks the name against the same snake-or-kebab pattern skill names are
already held to, and raises ValueError before any request is made.

Behaviour change: a name outside that character set, such as one with an
uppercase letter, a dot, or a slash, now raises ValueError locally instead of
reaching the registry. The registry would have rejected it anyway, so what
changes is the error type and the fact that no request goes out.

Ports the validation half of the upstream change. The percent-encoding half
does not apply here, because this branch builds an SDK resource name rather
than a URL and every character the pattern accepts is already safe.
@GWeale GWeale changed the title fix: Port skill path traversal and skill name validation fixes to v1 fix: Port skill resource path and skill name validation fixes to v1 Aug 19, 2026
@GWeale
GWeale merged commit 1353e8d into v1 Aug 19, 2026
14 checks passed
@GWeale
GWeale deleted the backport-v1-pr16 branch August 20, 2026 00:04
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.

2 participants