Skip to content

security: remove temp-file fallback for large responses (closes CodeQL #5)#17

Open
willwebster5 wants to merge 1 commit into
masterfrom
security/remove-tempfile-fallback
Open

security: remove temp-file fallback for large responses (closes CodeQL #5)#17
willwebster5 wants to merge 1 commit into
masterfrom
security/remove-tempfile-fallback

Conversation

@willwebster5
Copy link
Copy Markdown
Owner

Summary

  • Closes CodeQL alert py/clear-text-storage-sensitive-data (#5) by removing the legacy temp-file fallback in format_text_response. The fallback wrote oversized tool output to $TMPDIR/crowdstrike-mcp/*.txt, spilling MAC/IP/hostname PII to disk with world-readable umask.
  • Migrated the six tools that could realistically overflow LARGE_RESPONSE_THRESHOLD (20,000 chars) to pass structured_data= into format_text_response, so their payloads are stored in the existing in-memory ResponseStore (process-scoped, ring-buffered, never hits disk) and surfaced via the get_stored_response tool instead of cat/grep on a temp file.
  • Deleted _write_response_file, _cleanup_old_files, MCP_OUTPUT_DIR, set_current_tool, and related tempfile/datetime imports from utils.py. Large responses without structured_data now return a truncated summary with a loud developer warning — no disk I/O under any path.

Scope of migration

Tool File
threatgraph_get_vertices/edges/ran_on/summary modules/threat_graph.py
rtr_check_command_status modules/rtr.py
spotlight_host_vulns / spotlight_vulnerabilities_combined modules/spotlight.py
host_login_history / host_network_history modules/hosts.py
cloud_get_risk_timeline(full=True) modules/cloud_security.py
identity_investigate_entity(include_raw=True) modules/idp.py

Test plan

  • pytest tests/ — 404 passed (+8 new, incl. one per migrated tool and one asserting the fallback machinery is gone)
  • ruff check src/ tests/ clean
  • ruff format --check clean
  • Verify CodeQL alert Windows: python3 command resets console code page, corrupting Claude Code terminal UI #5 auto-closes on the next scan of master
  • Smoke-test one large-output tool against a live tenant (e.g. threatgraph_get_edges with a high-fanout vertex) and confirm the response footer references get_stored_response(ref_id=...) rather than a temp file

🤖 Generated with Claude Code

…sponseStore

Closes CodeQL alert py/clear-text-storage-sensitive-data (#5). The legacy
fallback in format_text_response wrote oversized tool responses to
$TMPDIR/crowdstrike-mcp/*.txt, exposing MAC/IP/hostname PII on disk.

Migrate the six tools that could overflow LARGE_RESPONSE_THRESHOLD to pass
structured_data= (threat_graph list ops, rtr_check_command_status,
spotlight vuln lists, hosts login/network history, cloud_risk_timeline
full mode, identity_investigate_entity raw mode). Delete the fallback
branch and helpers (_write_response_file, _cleanup_old_files,
MCP_OUTPUT_DIR, set_current_tool); oversized responses without
structured_data now return a developer warning instead of spilling bytes
to disk.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant