T09 · Insecure Skill Coding Practices
- Location
scripts/github_upload.py:145- Finding
Sensitive-file filtering is bypassed during Git staging and upload
- Content
View full analysis
Vulnerability Details
File Location:
scripts/github_upload.py:145-178,scripts/github_upload.py:233-269, andscripts/github_upload.py:282-317
Vulnerability Type: Sensitive information disclosure through ineffective file filtering
Risk Level: HighVulnerable Code
python def _filter_files(self, files: List[Path]) -> List[Path]: """Filter out excluded files""" result = [] for f in files: rel = str(f.relative_to(self.path)) if rel.startswith('.git/'): continue skip = False for pattern in self.EXCLUDE_PATTERNS: if pattern.endswith('/'): if rel.startswith(pattern.rstrip('/')): skip = True break elif pattern.startswith('*'): if f.name.startswith(pattern.lstrip('*')): skip = True break else: if pattern in rel: skip = True break if not skip: result.append(f) return result def _get_files_to_upload(self) -> List[Path]: """Get list of files to upload (filtered)""" if not self.path.exists(): return [] if self.path.is_file(): return [self.path] files = list(self.path.rglob('*')) files = [f for f in files if f.is_file()] return self._filter_files(files)The filtered result is subsequently used only for reporting and an emptiness check. The actual staging operation ignores that result:
python def _ensure_commit(self, message: str) -> bool: """Create commit if there are changes""" if self._preview_only: files = self._get_files_to_upload() print(f"[DRY RUN] Would commit {len(files)} files") return True success, output = self._run_git(['git', 'status', '--porcelain']) if not success: ...[truncated 3228 chars]- Remediation
View remediation
Remediation Suggestions
- Replace
git add .with explicit staging of the validated paths:python files = self._get_files_to_upload() relative_files = [str(path.relative_to(self.path)) for path in files] self._run_git(['git', 'add', '--', *relative_files]) - Use
fnmatch.fnmatch(),Path.match(), or a mature ignore-rule implementation instead of custom wildcard handling. - Treat secret detection as deny-by-default. Abort the upload when a sensitive file is found rather than silently omitting it.
- After staging, inspect the index using
git diff --cached --name-onlyand revalidate every staged path before committing. - Scan staged content for common credential formats, private-key headers, and high-confidence secret patterns.
- Ensure dry-run and real execution use the same resolved staging list.
- Check and propagate the return value of every
git addoperation. - Add tests proving that
.env,id_rsa,server.pem,deploy.key, nested secret files, and already tracked sensitive files cannot enter the commit.
- Replace
