Commit 218cedf
committed
security: Apply critical security fixes from PR TauricResearch#281 review
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.1 parent 3def80c commit 218cedf
3 files changed
+65
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
497 | 497 | | |
498 | 498 | | |
499 | 499 | | |
500 | | - | |
501 | | - | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
502 | 522 | | |
503 | 523 | | |
504 | 524 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
10 | 40 | | |
11 | 41 | | |
12 | 42 | | |
13 | 43 | | |
14 | 44 | | |
15 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
16 | 49 | | |
17 | 50 | | |
18 | 51 | | |
| |||
53 | 86 | | |
54 | 87 | | |
55 | 88 | | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
56 | 92 | | |
57 | 93 | | |
58 | 94 | | |
| |||
129 | 165 | | |
130 | 166 | | |
131 | 167 | | |
| 168 | + | |
| 169 | + | |
132 | 170 | | |
133 | 171 | | |
134 | 172 | | |
| |||
166 | 204 | | |
167 | 205 | | |
168 | 206 | | |
| 207 | + | |
| 208 | + | |
169 | 209 | | |
170 | 210 | | |
171 | 211 | | |
| |||
201 | 241 | | |
202 | 242 | | |
203 | 243 | | |
| 244 | + | |
| 245 | + | |
204 | 246 | | |
205 | 247 | | |
206 | 248 | | |
| |||
0 commit comments