🛡️ Sentinel: [HIGH] Fix sensitive data leakage and regex injection in publish flow#120
Conversation
… publish flow - Hardened `_ignore_func` in `git_publish.py` using `fnmatch.filter` to correctly exclude sensitive directories and files. - Replaced vulnerable `$` anchor with `\Z` in `_is_valid_skill_name` regex across `local_source.py` and `external_source.py` to prevent newline injection. - Added comprehensive security regression tests in `tests/test_publish_security_sentinel.py`. - Updated sentinel journal with findings. Co-authored-by: calionauta <1719651+calionauta@users.noreply.github.com>
|
👋 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
Code Review
This pull request addresses security vulnerabilities by updating skill name validation regexes to use \Z instead of $ to prevent trailing newline bypasses, and refactoring the file exclusion logic in git_publish.py to use fnmatch.filter instead of manual string matching. It also adds a comprehensive test suite for these security measures. The review feedback correctly highlights that fnmatch.filter is case-sensitive on Unix-like filesystems, which could allow uppercase or mixed-case sensitive files (like .ENV or personal.PEM) to bypass the exclusion filter. To resolve this, the reviewer suggested implementing case-insensitive matching in the ignore function and adding corresponding test cases and assertions.
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.
| ignored = set() | ||
| for pattern in patterns: | ||
| ignored.update(fnmatch.filter(names, pattern)) | ||
| return list(ignored) |
There was a problem hiding this comment.
On case-sensitive filesystems (such as Linux, which is commonly used in production and CI/CD environments), fnmatch.filter performs case-sensitive matching. This means sensitive files with mixed-case or uppercase names/extensions (e.g., .ENV, personal.PEM, models.JSON) will bypass the exclusion filter and potentially be leaked to public repositories.\n\nTo ensure robust, case-insensitive exclusion across all platforms, we can map the lowercase names back to their original casing when filtering.
ignored = set()\n lower_to_orig = {name.lower(): name for name in names}\n for pattern in patterns:\n matched_lowers = fnmatch.filter(lower_to_orig.keys(), pattern.lower())\n ignored.update(lower_to_orig[m] for m in matched_lowers)\n return list(ignored)| # Sensitive files | ||
| (src / ".env").write_text("API_KEY=123") | ||
| (src / "models.json").write_text("{}") | ||
| (src / "personal.pem").write_text("key") |
There was a problem hiding this comment.
To ensure the exclusion logic is robust against case-sensitivity issues on Unix-like filesystems, we should add test cases with mixed-case and uppercase sensitive filenames (e.g., .ENV, models.JSON, personal.PEM). This will verify that the case-insensitive matching works correctly.
| # Sensitive files | |
| (src / ".env").write_text("API_KEY=123") | |
| (src / "models.json").write_text("{}") | |
| (src / "personal.pem").write_text("key") | |
| # Sensitive files (including mixed/uppercase to test case-insensitivity)\n (src / ".env").write_text("API_KEY=123")\n (src / ".ENV").write_text("API_KEY=123")\n (src / "models.json").write_text("{}")\n (src / "models.JSON").write_text("{}")\n (src / "personal.pem").write_text("key")\n (src / "personal.PEM").write_text("key") |
| assert not (dest / ".env").exists() | ||
| assert not (dest / "models.json").exists() | ||
| assert not (dest / "personal.pem").exists() |
There was a problem hiding this comment.
Add assertions for the mixed-case and uppercase sensitive files to verify they are also successfully excluded.
assert not (dest / ".env").exists()\n assert not (dest / ".ENV").exists()\n assert not (dest / "models.json").exists()\n assert not (dest / "models.JSON").exists()\n assert not (dest / "personal.pem").exists()\n assert not (dest / "personal.PEM").exists()
🚨 Severity: HIGH
💡 Vulnerability:
git_publish.pywas brittle and failed to match many sensitive patterns (likesessions/,cache/,.env), potentially leaking personal data to public repositories.$anchor, which in Python allows a trailing newline to pass. This could be exploited if these names are used in shell commands.🎯 Impact:
🔧 Fix:
fnmatch.filterfor robust pattern matching ingit_publish.py.$to\Zin regex patterns for absolute end-of-string matching.✅ Verification:
tests/test_publish_security_sentinel.pycovering both vulnerabilities.PR created automatically by Jules for task 14325187048638486411 started by @calionauta