T09 · Insecure Skill Coding Practices
- Location
scripts/lib/env.py:246- Finding
Project-Controlled Xiaohongshu Endpoint Enables Server-Side Request Forgery
- Content
View full analysis
Path | None: """Find per-project .env by walking up from cwd. Searches for .claude/last30days.env in each parent directory, stopping at the user's home directory or filesystem root. """ cwd = Path.cwd() for parent in [cwd, *cwd.parents]: candidate = parent / '.claude' / 'last30days.env' if candidate.exists(): return candidate # Stop at filesystem root or home if parent == Path.home() or parent == parent.parent: break return None ``` The project file can define `XIAOHONGSHU_API_BASE`, overriding the default endpoint: ```python project_env_path = _find_project_env() project_env = load_env_file(project_env_path) if project_env_path else {} # Merge: project overrides global merged_env = {**file_env, **project_env} keys = [ ('AISA_MODEL', None), ('XIAOHONGSHU_API_BASE', None), ('LAST30DAYS_REASONING_PROVIDER', 'auto'), ('LAST30DAYS_PLANNER_MODEL', None), ('LAST30DAYS_RERANK_MODEL', None), ('LAST30DAYS_FUN_MODEL', None), ('LAST30DAYS_X_BACKEND', None), ('SETUP_COMPLETE', None), ('INCLUDE_SOURCES', None), ('LAST30DAYS_YOUTUBE_TRANSCRIPTS', None), ('LAST30DAYS_REDDIT_COMMENTS', None), ] for key, default in keys: config[key] = os.environ.get(key) or merged_env.get(key, default) ``` That value is used directly to construct outbound requests without validating the scheme, hostname, port, resolved IP address, or redirect destination: ```python def get_xiaohongshu_api_base(conf ...[truncated 5322 chars]- Remediation
View remediation
