Skip to content

🛡️ Sentinel: [HIGH] Fix regex newline injection in publish flow#112

Open
calionauta wants to merge 1 commit into
mainfrom
fix-publish-regex-injection-7896769534845444974
Open

🛡️ Sentinel: [HIGH] Fix regex newline injection in publish flow#112
calionauta wants to merge 1 commit into
mainfrom
fix-publish-regex-injection-7896769534845444974

Conversation

@calionauta

Copy link
Copy Markdown
Owner

🚨 Severity: HIGH
💡 Vulnerability: Internal _is_valid_skill_name functions in the publish flow were using the vulnerable $ anchor in regex patterns.
🎯 Impact: This allowed skill names with trailing newlines to bypass validation, potentially leading to command or argument injection if these names were used in shell operations.
🔧 Fix: Replaced the $ anchor with \Z in src/agent_sync/publish/local_source.py and src/agent_sync/publish/external_source.py to ensure absolute end-of-string matching.
✅ Verification: Added tests/test_publish_security_remediation.py which specifically tests for newline injection. All 567 project tests passed.


PR created automatically by Jules for task 7896769534845444974 started by @renatocaliari

Replaced '$' with '\Z' in internal '_is_valid_skill_name' validators
within the publish subpackage to prevent trailing newline injection.
Added security regression tests in 'tests/test_publish_security_remediation.py'.

Co-authored-by: renatocaliari <1719651+renatocaliari@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request fixes a security regression by updating the regex pattern in _is_valid_skill_name to use the \Z anchor instead of $ in both local_source.py and external_source.py, preventing newline injection. It also adds corresponding unit tests and documents the regression in .jules/sentinel.md. The reviewer suggests consolidating these duplicate validation functions into a single shared validator in src/agent_sync/validators.py to align with the prevention guidelines documented in the sentinel file.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +90 to +91
# Use \Z instead of $ to prevent newline injection
pattern = r'^[a-z][a-z0-9]*(-[a-z0-9]+)*\Z'

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.

medium

The prevention section in .jules/sentinel.md correctly highlights that duplicating security-critical validation logic is a major source of regressions and recommends consolidating it into a single source of truth. However, this PR still maintains two identical implementations of _is_valid_skill_name in local_source.py and external_source.py.

To prevent future regressions and adhere to the project's own guidelines, please consolidate this validation logic:

  1. Define a new validator (e.g., validate_publish_skill_name(name: str) -> bool) in src/agent_sync/validators.py.
  2. Import and use this central validator in both src/agent_sync/publish/local_source.py and src/agent_sync/publish/external_source.py.

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.

1 participant