Skip to content

🛡️ Sentinel: [HIGH] Fix regex newline injection and broken publish exclusion#108

Open
calionauta wants to merge 1 commit into
mainfrom
sentinel-security-fixes-regex-ignore-11424395249717937625
Open

🛡️ Sentinel: [HIGH] Fix regex newline injection and broken publish exclusion#108
calionauta wants to merge 1 commit into
mainfrom
sentinel-security-fixes-regex-ignore-11424395249717937625

Conversation

@calionauta

Copy link
Copy Markdown
Owner

🚨 Severity: HIGH

💡 Vulnerability:

  1. Regex Newline Injection: Internal skill name validators were using the $ anchor, which allows trailing newlines in Python's re module. This could lead to argument or command injection if these names were used in shell commands.
  2. Broken File Exclusion: The _ignore_func used to filter sensitive files during public publishing had brittle logic that failed to match most default patterns (e.g., sessions, cache, models.json).

🎯 Impact:

  1. Potential for argument/command injection via crafted skill names.
  2. Accidental leakage of sensitive user data (sessions, credentials, cache) to public repositories during the agent-sync share process.

🔧 Fix:

  1. Replaced $ with \Z in all identified internal validators.
  2. Refactored exclusion logic to use the standard fnmatch.fnmatchcase for reliable glob-style matching.

Verification:

  • New test suite tests/test_sentinel_fixes.py specifically verifies both fixes.
  • Existing security tests in tests/test_security.py pass.
  • Verified _ignore_func fix with a reproduction script.

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

…clusion

- Hardened internal skill name validators in `local_source.py` and `external_source.py` by replacing `$` with `\Z` to prevent newline injection.
- Refactored `_ignore_func` in `git_publish.py` to use `fnmatch.fnmatchcase` for robust file exclusion, preventing potential data leaks of sensitive files like `sessions` and `cache` during public publishing.
- Added regression tests in `tests/test_sentinel_fixes.py`.
- Updated `.jules/sentinel.md` with new security learnings.

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 addresses security vulnerabilities by replacing $ with \Z in skill name validation regexes to prevent newline injection, and refactoring the custom ignore logic in git_publish.py to use fnmatch.fnmatchcase. It also adds a test suite to verify these fixes. The review feedback suggests enhancing the ignore logic to be case-insensitive to prevent sensitive files with alternative casing (e.g., .ENV) from bypassing the filter, along with adding corresponding test cases.

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.

if name == pattern or name.startswith(pattern.rstrip('/') + '/'):
ignored.append(name)
break
if fnmatch.fnmatchcase(name, pattern):

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.

security-medium medium

Using fnmatch.fnmatchcase performs a strictly case-sensitive match. If a user or system creates sensitive files or directories with different casing (e.g., .ENV, Models.json, or Cache), they will bypass this ignore filter and potentially be leaked to the public repository.

To prevent accidental leakage, it is safer to perform case-insensitive matching by converting both the name and the pattern to lowercase.

Suggested change
if fnmatch.fnmatchcase(name, pattern):
if fnmatch.fnmatchcase(name.lower(), pattern.lower()):

Comment on lines +24 to +28
assert "sessions" in ignore(None, ["sessions"])
assert "cache" in ignore(None, ["cache"])
assert "models.json" in ignore(None, ["models.json"])
assert ".env" in ignore(None, [".env"])
assert "test.log" in ignore(None, ["test.log"])

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

If case-insensitive matching is adopted in _ignore_func, we should also add test cases to verify that variations in casing (such as .ENV or Models.json) are correctly ignored.

Suggested change
assert "sessions" in ignore(None, ["sessions"])
assert "cache" in ignore(None, ["cache"])
assert "models.json" in ignore(None, ["models.json"])
assert ".env" in ignore(None, [".env"])
assert "test.log" in ignore(None, ["test.log"])
assert "sessions" in ignore(None, ["sessions"])
assert "SESSIONS" in ignore(None, ["SESSIONS"])
assert "cache" in ignore(None, ["cache"])
assert "Cache" in ignore(None, ["Cache"])
assert "models.json" in ignore(None, ["models.json"])
assert "Models.json" in ignore(None, ["Models.json"])
assert ".env" in ignore(None, [".env"])
assert ".ENV" in ignore(None, [".ENV"])
assert "test.log" in ignore(None, ["test.log"])
assert "TEST.LOG" in ignore(None, ["TEST.LOG"])

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