T09 · Insecure Skill Coding Practices
- Location
scripts/server.py:715- Finding
Sensitive path restrictions are bypassable through symbolic links
- Content
View full analysis
tuple[bool, str]: """Check if path is allowed to be read. Returns (allowed, reason)""" path_lower = file_path.lower() # Only allow .md files if not file_path.endswith('.md'): return False, "Only .md files are allowed" # Check blocked absolute paths for blocked in BLOCKED_PATHS: if path_lower.startswith(blocked): return False, f"Access to system directory denied: {blocked}" # Check blocked patterns for pattern in BLOCKED_PATTERNS: if pattern.lower() in path_lower: return False, f"Access to sensitive file denied" return True, "" ``` ```python def _serve_markdown(self, file_path, query): # Security: Check if path is allowed allowed, reason = is_path_allowed(file_path) if not allowed: self._serve_error(f"Access denied: {escape(reason)}", query) return path = Path(file_path).resolve() # Verify it's actually a .md file if path.suffix.lower() != '.md': self._serve_error("Only .md files are allowed", query) return if not path.exists(): self._serve_error(f"File not found: {escape(file_path)}", query) return if not path.is_file(): self._serve_error("Not a file", query) return try: with open(path, 'r', encoding='utf-8') as f: md_content = f.read() ``` ### Technical Analysis The security deny-list is applied to the user-supplied path before `Path.resolve()` canonicalizes the path and follows symbolic links. The resulting canonical path is not submitted to `is_path_allowed()` again. Consequently, a path whose visible name appears harmless ca ...[truncated 1686 chars]- Remediation
View remediation
