-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Turns-off upload *.* files, addresses conflicts in previous PR #282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Turns-off upload *.* files, addresses conflicts in previous PR #282
Conversation
Add organized security documentation addressing Gemini code review findings: **Critical Fixes (PR281_CRITICAL_FIXES.md)** - ChromaDB reset flag hardening (2 min fix) - Path traversal prevention via input validation (10 min) - CLI input validation at entry point (5 min) Total time: 15-20 minutes **Future Hardening Roadmap (FUTURE_HARDENING.md)** - 20 security enhancements organized by priority (P0/P1/P2) - 3-6 month phased implementation timeline - Production readiness guidelines - Compliance and enterprise considerations **Key Findings** - Gemini Issue TauricResearch#1 (Jupyter token): False positive - placeholder syntax - Gemini Issue TauricResearch#2 (File uploads): Confirmed - wildcard accept with no validation - Additional 15 architectural security issues documented for future work **Organization** - Clean docs/security/ structure (no root clutter) - Quick reference tables and scannable formatting - Actionable code snippets with before/after examples - Risk matrix and effort estimates Suitable for upstream contribution and production planning.
…view Implement the top 3 critical security fixes identified in Gemini code review: **Fix 1: ChromaDB Reset Protection** - Changed `allow_reset=True` to `False` in memory.py - Prevents catastrophic database deletion in production - File: tradingagents/agents/utils/memory.py:13 **Fix 2: Path Traversal Prevention** - Added `validate_ticker_symbol()` function with comprehensive validation - Applied validation to 5 functions using ticker in file paths: - get_YFin_data_window() - get_YFin_data() - get_data_in_range() - get_finnhub_company_insider_sentiment() - get_finnhub_company_insider_transactions() - Blocks: path traversal (../, \\), invalid chars, length > 10 - File: tradingagents/dataflows/local.py **Fix 3: CLI Input Validation** - Added validation loop to get_ticker() with user-friendly error messages - Prevents malicious input at entry point - Validates format, blocks traversal, limits length - File: cli/main.py:499-521 **Testing:** - Validation logic verified with attack vectors: - ../../etc/passwd (blocked ✓) - Long tickers (blocked ✓) - Special characters (blocked ✓) - Valid tickers: AAPL, BRK.B (pass ✓) **Changes:** - 3 files changed, 65 insertions(+), 3 deletions(-) - Implementation time: ~20 minutes - Zero breaking changes to existing functionality **References:** - Security analysis: docs/security/PR281_CRITICAL_FIXES.md - Future roadmap: docs/security/FUTURE_HARDENING.md Addresses critical path traversal (CWE-22) and data loss vulnerabilities.
Export security review and patterns cheatsheet for wiki publication: - TradingAgents-Security-Review.md (11KB) - Comprehensive review - Security-Patterns-Cheatsheet.md (13KB) - Reusable code patterns Ready for upload to https://github.com/jackspace/redditmonger/wiki
Summary of ChangesHello @jackspace, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly bolsters the application's security posture by integrating critical fixes and establishing a foundational security documentation framework. It directly addresses potential path traversal vulnerabilities and data loss risks through enhanced input validation and secure database configuration. Furthermore, it provides a detailed roadmap for ongoing security hardening, reflecting a proactive approach to system integrity. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
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 introduces important security fixes, primarily by adding input validation for ticker symbols to prevent path traversal vulnerabilities. It also disables a potentially dangerous database reset feature in ChromaDB. The changes are well-documented with new markdown files explaining the security issues and future hardening plans.
My review focuses on improving code maintainability and correctness. Specifically:
- In
cli/main.py, I suggest simplifying the error handling. - In
tradingagents/dataflows/local.py, I've pointed out a small redundancy in the validation logic.
Overall, these are great improvements to the security posture of the application.
| try: | ||
| # Validate ticker format | ||
| if not ticker or len(ticker) > 10: | ||
| console.print("[red]Error: Ticker must be 1-10 characters[/red]") | ||
| continue | ||
|
|
||
| # Check for path traversal attempts | ||
| if '..' in ticker or '/' in ticker or '\\' in ticker: | ||
| console.print("[red]Error: Invalid characters in ticker symbol[/red]") | ||
| continue | ||
|
|
||
| # Validate characters (alphanumeric, dots, hyphens only) | ||
| if not all(c.isalnum() or c in '.-' for c in ticker): | ||
| console.print("[red]Error: Ticker can only contain letters, numbers, dots, and hyphens[/red]") | ||
| continue | ||
|
|
||
| return ticker.upper() # Return normalized uppercase ticker | ||
| except Exception as e: | ||
| console.print(f"[red]Error validating ticker: {e}[/red]") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The try...except Exception block is too broad and can hide important errors. For instance, if the user presses Ctrl+C, typer.prompt raises a typer.Abort exception, which would be caught here, printing an error and continuing the loop instead of exiting the program as expected. The validation logic itself is unlikely to raise exceptions. It's better to remove the try...except block and let exceptions like Abort propagate naturally.
# Validate ticker format
if not ticker or len(ticker) > 10:
console.print("[red]Error: Ticker must be 1-10 characters[/red]")
continue
# Check for path traversal attempts
if '..' in ticker or '/' in ticker or '\' in ticker:
console.print("[red]Error: Invalid characters in ticker symbol[/red]")
continue
# Validate characters (alphanumeric, dots, hyphens only)
if not all(c.isalnum() or c in '.-' for c in ticker):
console.print("[red]Error: Ticker can only contain letters, numbers, dots, and hyphens[/red]")
continue
return ticker.upper() # Return normalized uppercase ticker| raise ValueError(f"Invalid ticker symbol: {symbol}") | ||
|
|
||
| # Prevent path traversal patterns | ||
| if '..' in symbol or '/' in symbol or '\\' in symbol: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The checks for / and \ are redundant because the regular expression r'^[A-Za-z0-9.\-]+$' on line 27 already ensures the symbol does not contain these characters. You can simplify this check to only look for ...
| if '..' in symbol or '/' in symbol or '\\' in symbol: | |
| if '..' in symbol: |
No description provided.