Skip to content

Adding safeguards for LLM and bumping litellm version for safety#457

Merged
Edwardvaneechoud merged 7 commits into
mainfrom
feature/LLM-security-patches
May 11, 2026
Merged

Adding safeguards for LLM and bumping litellm version for safety#457
Edwardvaneechoud merged 7 commits into
mainfrom
feature/LLM-security-patches

Conversation

@Edwardvaneechoud
Copy link
Copy Markdown
Owner

This pull request introduces several important security and safety enhancements to the AI agent and tool execution framework, along with some documentation and code quality improvements. The main focus is on stricter validation and auditing of potentially dangerous operations such as SQL queries and Python script execution, as well as improved sanitization of user-provided data. Additionally, the documentation has been updated for clarity and to reflect recent changes.

Security and Validation Enhancements:

  • Added AST-based validation for python_script nodes to block dangerous patterns (e.g., __import__, importlib, eval, etc.), mirroring the polars_code validation logic. This prevents unsafe code from being executed by the agent. (flowfile_core/flowfile_core/ai/tools/executor/handlers/add.py, flowfile_core/flowfile_core/ai/tools/executor/handlers/update.py) [1] [2] [3]
  • Expanded SQL query validation to block additional dangerous statements (e.g., COPY, MERGE, INTO OUTFILE, LOAD DATA, PRAGMA, ATTACH, DETACH) in validate_sql_query, further securing database interactions. (flowfile_core/flowfile_core/flowfile/sources/external_sources/sql_source/sql_source.py) [1] [2]
  • Improved audit logging and risk annotation: changes to database_reader queries by the AI agent are now flagged as high-risk and annotated in the audit log for better traceability. (flowfile_core/flowfile_core/ai/tools/executor/handlers/update.py) [1] [2]
  • Added new refusal reasons for better categorization and handling of blocked operations, including sql_query_validation, db_query_change, and python_script_validation. (flowfile_core/flowfile_core/ai/safety.py)

Data Sanitization and Limits:

  • Introduced a column name sanitization routine for LLM prompts, stripping control characters, replacing unsafe characters, and flagging modified names to prevent prompt injection or confusion. (flowfile_core/flowfile_core/ai/context/builder.py)
  • Increased the maximum allowed size for audit event arguments to 32 KiB to accommodate more complex events. (flowfile_core/flowfile_core/ai/audit.py)

Documentation Updates:

  • Updated docs/ai/providers.md to clarify environment variable fallback, rate limits, and credential storage, and removed outdated or redundant sections. [1] [2] [3] [4]

Other Improvements:

  • Added a per-session limit for database_reader add/update operations to prevent runaway query execution by the agent. (flowfile_core/flowfile_core/ai/agents/planner/_internal.py)
  • Minor code cleanups and formatting improvements across several files for readability and maintainability. [1] [2] [3] [4] [5] [6] [7] [8]

These changes collectively strengthen the security posture of the AI agent, improve the reliability of audit trails, and enhance the safety of user-facing operations.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 11, 2026

Deploy Preview for flowfile-wasm canceled.

Name Link
🔨 Latest commit 2e3f936
🔍 Latest deploy log https://app.netlify.com/projects/flowfile-wasm/deploys/6a022739c2d8050008abdb52

@Edwardvaneechoud Edwardvaneechoud marked this pull request as ready for review May 11, 2026 16:31
@Edwardvaneechoud Edwardvaneechoud merged commit f55aa92 into main May 11, 2026
24 checks passed
@Edwardvaneechoud Edwardvaneechoud deleted the feature/LLM-security-patches branch May 11, 2026 19:01
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