# GHSA-WP6H-6XXH-G8FP: Summary During a security review of crewAI (v1.15.30), we identified three security boundary bypasses in previously hardened components: --- 1

- Database: GitHub
- Severity: high (stated by ghsa, no CVSS score)
- Published: 2026-11-19
- Modified: 2026-11-19

## Affected versions

- crewai (PyPI): through 1.15.30
- crewai-tools (PyPI): through 1.15.30
- crewai-files (PyPI): through 1.15.43

## Description

## Summary

During a security review of `crewAI` (`v1.15.30`), we identified three security boundary bypasses in previously hardened components:

---

### 1. `CREWAI_DESERIALIZE_CALLBACKS` Guard Bypass & Arbitrary Module Import in `BaseTool` Deserialization (`lib/crewai/src/crewai/tools/base_tool.py:59-78`)

CrewAI introduced the `CREWAI_DESERIALIZE_CALLBACKS` environment variable guard (`_trusted_deserialize()` in `lib/crewai/src/crewai/types/callback.py:25-29, 88-94`) to prevent untrusted checkpoints or serialized payloads from importing arbitrary Python modules and resolving dotted-path callables.

However, `_resolve_tool_dict()` in `lib/crewai/src/crewai/tools/base_tool.py` (lines 59–78) bypasses this guard:
```python
def _resolve_tool_dict(value: dict[str, Any]) -> Any:
    """Validate a dict with ``tool_type`` into the concrete BaseTool subclass."""
    dotted = value.get("tool_type", "")
    tool_cls = _TOOL_TYPE_REGISTRY.get(dotted)
    if tool_cls is None:
        mod_path, cls_name = dotted.rsplit(".", 1)
        tool_cls = getattr(importlib.import_module(mod_path), cls_name)

    # Pre-resolve serialized callback strings so SerializableCallable's
    # BeforeValidator sees a callable and skips the env-var guard.
    data = dict(value)
    for key in ("cache_function",):
        val = data.get(key)
        if isinstance(val, str):
            try:
                data[key] = _resolve_dotted_path(val)
            except (ValueError, ImportError):
                data.pop(key)

    return tool_cls.model_validate(data)  # type: ignore[union-attr]
```
1. **Unconditional `_resolve_dotted_path(val)` on `cache_function`**: Even when `CREWAI_DESERIALIZE_CALLBACKS` is unset/disabled, `_resolve_tool_dict()` resolves any dotted path string in `cache_function` into a live callable before `SerializableCallable`'s `BeforeValidator` runs (which is invoked as `cache_function(args, result)` during tool execution).
2. **Unchecked `importlib.import_module(mod_path)` on `tool_type`**: When `dotted` is not in `_TOOL_TYPE_REGISTRY`, `_resolve_tool_dict()` imports arbitrary modules via `importlib.import_module(mod_path)` without checking `_trusted_deserialize()` or verifying `issubclass(tool_cls, BaseTool)` before calling `tool_cls.model_validate(data)`.

---

### 2. `NL2SQLTool` Read-Only Mode (`allow_dml=False`) SQL Validation Bypasses (`lib/crewai-tools/src/crewai_tools/tools/nl2sql/nl2sql_tool.py:78-202, 325-370`)

`NL2SQLTool` defaults to read-only mode (`allow_dml=False`) and blocks write statements in CTEs (`WITH`) and `EXPLAIN ANALYZE`. Three parser bypasses allow DML/DDL execution when `allow_dml=False`:

1. **`WITH ... AS MATERIALIZED (` / `AS NOT MATERIALIZED (` Fail-Open Bypass (lines 78, 348–370)**:
   - `_AS_PAREN_RE = re.compile(r"\bAS\s*\(", re.IGNORECASE)` only matches `AS` followed immediately by whitespace and `(`.
   - Standard PostgreSQL / SQLite CTE syntax `WITH cte AS MATERIALIZED (SELECT 1) DELETE FROM users` or `WITH d AS NOT MATERIALIZED (DELETE FROM users RETURNING *) SELECT * FROM d` causes `_iter_as_paren_matches(stmt)` to return an empty list. Both `_detect_writable_cte(stmt)` and `_extract_main_query_after_cte(stmt)` return `None`, and `_validate_statement()` reaches `return` at line 370 without raising `ValueError` (failing open).
2. **Leading SQL Comment Inside Writable CTE Body (lines 100–115)**:
   - `_detect_writable_cte()` slices `body = stmt[open_idx + 1 : close_idx].strip()` from the raw statement without calling `_strip_sql_comments(body)`. A leading block comment inside the CTE parentheses (`WITH d AS (/*comment*/ DELETE FROM users RETURNING *) SELECT * FROM d`) sets `first_word` to `"/*COMMENT*/"`, bypassing `_CTE_WRITE_INDICATORS`.
3. **`EXPLAIN (ANALYZE true)` Option Parsing Bypass (lines 182–201)**:
   - In `_resolve_explain_command()`, `opt in ("ANALYZE", "ANALYSE")` requires an exact string match on the option token, so valid PostgreSQL syntax `EXPLAIN (ANALYZE true) DELETE FROM users` or `EXPLAIN (ANALYZE on) DELETE FROM users` (`opt == "ANALYZE TRUE"`) evaluates `analyze_found` to `False` and returns `None`, allowing the `DELETE` statement to execute.

---

### 3. Symlink Sibling-Directory Prefix & Parent-Symlink Bypass in `FilePath._validate_file_exists` (`lib/crewai-files/src/crewai_files/core/sources.py:218-236`)

In `lib/crewai-files/src/crewai_files/core/sources.py` (lines 227–231):
```python
if self.path.is_symlink():
    resolved = self.path.resolve()
    cwd = Path.cwd().resolve()
    if not str(resolved).startswith(str(cwd)):
        raise ValueError(f"Symlink escapes allowed directory: {self.path}")
```
1. `not str(resolved).startswith(str(cwd))` is vulnerable to sibling-directory prefix matching (e.g., if `cwd` is `/app/work`, a symlink to `/app/work_secrets/key.pem` passes `startswith("/app/work")`).
2. `self.path.is_symlink()` only checks the final path component; if an intermediate directory is a symlink pointing outside `cwd` (e.g. `linked_dir/secret.txt`), `self.path.is_symlink()` is `False` and containment is never checked.

---

## Suggested Remediation

1. **In `lib/crewai/src/crewai/tools/base_tool.py`**:
   - Only pre-resolve `cache_function` without `_trusted_deserialize()` when it matches the built-in `crewai.tools.base_tool._default_cache_function`, and require `_trusted_deserialize()` (plus `issubclass(tool_cls, BaseTool)`) when importing arbitrary modules via `tool_type`.
2. **In `lib/crewai-tools/src/crewai_tools/tools/nl2sql/nl2sql_tool.py`**:
   - Run `_strip_sql_comments()` before CTE matching, update `_AS_PAREN_RE` to match `\bAS\b(?:\s+(?:NOT\s+)?MATERIALIZED\b)?\s*\(`, raise `ValueError` in read-only mode if `_extract_main_query_after_cte()` returns `None`, and match `opt.split()[0] in ("ANALYZE", "ANALYSE")` in `_resolve_explain_command()`.
3. **In `lib/crewai-files/src/crewai_files/core/sources.py`**:
   - Always check `self.path.resolve().is_relative_to(Path.cwd().resolve())`.


---

## Patches

- Issues 1 and 2 (`crewai`, `crewai-tools`) are fixed in 1.15.31.
- Issue 3 (`crewai-files`) is fixed in 1.15.44: `FilePath` now resolves the path on every validation and checks working-directory containment with `Path.is_relative_to`, closing the parent-directory symlink and sibling-directory prefix bypasses. Plain absolute paths outside the working directory remain allowed; this release addresses symlink containment only.

Upgrade to the patched versions above. There is no workaround other than avoiding untrusted paths and symlinks under the working directory.

## References

- https://github.com/crewAIInc/crewAI/security/advisories/GHSA-wp6h-6xxh-g8fp

Page: https://cve.now/GHSA-WP6H-6XXH-G8FP

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
