CVE-2026-57130: PraisonAI IMAP Command Injection Vulnerability

HIGH
Advisory Identifier: GHSA-c969-5x3p-vq3v
CVSS 8.1
CWE-20 CWE-77
Published
Advisory Summary

CVE-2026-57130 is a HIGH (CVSS 8.1) imap command injection vulnerability (CWE-20: Improper Input Validation) affecting PraisonAI libraries in the PyPI ecosystem. The issue involves imap command injection via unsanitized email search parameters. Remediation is available by upgrading affected packages to version 1.6.59.

CVE-2026-57130 at a Glance

CVE Identifier CVE-2026-57130
GHSA Identifier GHSA-c969-5x3p-vq3v
Severity HIGH
CVSS v3.1 Base Score 8.1
CWE Classification CWE-20: Improper Input Validation
Affected Product PraisonAI
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 8.1

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2026-57130

To remediate this vulnerability, upgrade all affected PraisonAI dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

praisonaiagents fixed: 1.6.59
pip install praisonaiagents>=1.6.59
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show praisonaiagents

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2026-57130, inspect your installed packages using pip:

pip show praisonaiagents

Analyze the terminal output to locate any version of PraisonAI in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.6.59), your application is affected.

Note: The pip show praisonaiagents command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-20: Improper Input Validation, where the product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly. In PraisonAI, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

## Summary The email search tool in `src/praisonai-agents/praisonaiagents/tools/email_tools.py` constructs IMAP SEARCH commands by interpolating LLM-controlled parameters (from_addr, subject, query) directly into IMAP protocol strings using f-string formatting with double-quote delimiters. An attacker who can influence the arguments to the `search_emails` or `reply_email` tool (via crafted agent prompts) can inject arbitrary IMAP commands, potentially exfiltrating email data from other folders, deleting emails, or performing other unauthorized IMAP operations. ## Details **Vulnerable code (lines 493–502):** ```python criteria = [] if from_addr: criteria.append(f'FROM "{from_addr}"') if subject: criteria.append(f'SUBJECT "{subject}"') if query: criteria.append(f'TEXT "{query}"') if not criteria: criteria.append("ALL") search_str = " ".join(criteria) status, data = mail.search(None, search_str) ``` The `from_addr`, `subject`, and `query` parameters originate from LLM tool call arguments (the `search_emails` public function at line 665). These values flow through without any sanitization or escaping. The double-quote (`"`) characters in these parameters allow breaking out of the IMAP SEARCH quoted string context. **Additional injection points:** - Line 416: `mail.search(None, f'HEADER Message-ID "{search_id}"')` - Line 447: Same pattern in `_smtp_reply_email` - Line 542: Same pattern in `_smtp_archive_email` The `search_id` / `message_id` parameter in these functions is also LLM-controlled via the `reply_email` and `archive_email` public tool functions. **Reachability:** The `search_emails`, `reply_email`, and `archive_email` functions are exposed as agent tools. They are reachable when an agent is configured with email tools (EMAIL_ADDRESS + EMAIL_PASSWORD environment variables set). This is a documented deployment scenario for email-capable agents. ## PoC **Setup:** Requires an IMAP server (not run here — this is a static proof). The vulnerability is demonstrated by tracing the data flow. **Positive trigger — IMAP injection via `search_emails`:** An LLM agent processing a crafted prompt calls: ```python search_emails(from_addr='user@example.com" LOGOUT') ``` This produces the IMAP command: ``` SEARCH FROM "user@example.com" LOGOUT" ``` The `LOGOUT` command is injected after the prematurely closed quoted string, causing the IMAP connection to be terminated. **More severe injection — exfiltrate emails from another folder:** ```python search_emails(query='" SEARCH RETURN (MIN) ALL') ``` Produces: `TEXT "" SEARCH RETURN (MIN) ALL"` — injects a secondary SEARCH command. **Negative control — legitimate search:** ```python search_emails(from_addr='user@example.com') ``` Produces: `FROM "user@example.com"` — correct, no injection. **Cleanup:** No persistent changes for read-only injection. For destructive injection (DELETE, EXPUNGE), impact persists. ## Impact An attacker who can craft prompts that cause an LLM agent to call `search_emails` with injection payloads can: - **Terminate IMAP connections** (denial of service) - **Inject arbitrary IMAP commands** — including LIST (enumerate folders), SELECT (switch folders), FETCH (read emails from other mailboxes), STORE (modify flags), COPY/MOVE (move emails), DELETE/EXPUNGE (permanently delete emails) - **Exfiltrate email contents** from folders the user did not intend to expose to the agent - **Permanently delete emails** via injected DELETE + EXPUNGE commands The attack requires the IMAP backend to be configured (EMAIL_ADDRESS + EMAIL_PASSWORD env vars), which is a documented and common deployment for email-capable agents. ## Suggested remediation 1. **Escape double-quote characters** in IMAP parameters. Per RFC 3501, literal strings use `{n}\r\n` format or quoted strings with `\` escaping: ```python def _escape_imap_string(s: str) -> str: """Escape a string for safe use in IMAP quoted strings.""" # Use IMAP literal syntax for safety: {length}\r\n<data> encoded = s.encode('utf-8') return f'{{{len(encoded)}}}\r\n{encoded}' ``` 2. Use IMAP literal syntax (`{n}\r\ndata`) instead of quoted strings for all user-controlled parameters. This prevents any injection regardless of content. 3. Apply the escaping to all IMAP search criteria parameters: `from_addr`, `subject`, `query`, and `search_id`/`message_id`.

CVE-2026-57130 Affected PraisonAI Versions

1 component(s)
Fixed Versions:
1.6.59
Product / Package Ecosystem Affected Versions Fixed Version
praisonaiagents
PyPI
< 1.6.59
1.6.59

References

Frequently Asked Questions

What is CVE-2026-57130?
CVE-2026-57130 is a security vulnerability in PraisonAI involving IMAP Command Injection via Unsanitized Email Search Parameters under CWE-20: Improper Input Validation.
Which PraisonAI versions are affected?
Affected versions include releases prior to 1.6.59 across affected packages: praisonaiagents.
What version fixes CVE-2026-57130?
Upgrading to 1.6.59 (or the latest patched release for your respective branch) resolves the vulnerability.
Is praisonaiagents affected?
Yes, praisonaiagents is affected in releases prior to 1.6.59. Upgrade your dependency to 1.6.59 or later.
What is the CVSS score of CVE-2026-57130?
CVE-2026-57130 has a CVSS v3.1 base score of 8.1 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N.
What CWE is associated with CVE-2026-57130?
CVE-2026-57130 is classified under CWE-20: Improper Input Validation (The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.).
How can I check PyPI dependencies for CVE-2026-57130?
Run the dependency tree command: 'pip show praisonaiagents'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-c969-5x3p-vq3v",
  "modified" : "2026-07-20T21:26:50Z",
  "published" : "2026-06-18T14:25:03Z",
  "aliases" : [ "CVE-2026-57130" ],
  "summary" : "PraisonAI: IMAP Command Injection via Unsanitized Email Search Parameters",
  "details" : "## Summary\n\nThe email search tool in `src/praisonai-agents/praisonaiagents/tools/email_tools.py` constructs IMAP SEARCH commands by interpolating LLM-controlled parameters (from_addr, subject, query) directly into IMAP protocol strings using f-string formatting with double-quote delimiters. An attacker who can influence the arguments to the `search_emails` or `reply_email` tool (via crafted agent prompts) can inject arbitrary IMAP commands, potentially exfiltrating email data from other folders, deleting emails, or performing other unauthorized IMAP operations.\n## Details\n\n**Vulnerable code (lines 493–502):**\n```python\ncriteria = []\nif from_addr:\n    criteria.append(f'FROM \"{from_addr}\"')\nif subject:\n    criteria.append(f'SUBJECT \"{subject}\"')\nif query:\n    criteria.append(f'TEXT \"{query}\"')\nif not criteria:\n    criteria.append(\"ALL\")\nsearch_str = \" \".join(criteria)\nstatus, data = mail.search(None, search_str)\n```\n\nThe `from_addr`, `subject`, and `query` parameters originate from LLM tool call arguments (the `search_emails` public function at line 665). These values flow through without any sanitization or escaping. The double-quote (`\"`) characters in these parameters allow breaking out of the IMAP SEARCH quoted string context.\n\n**Additional injection points:**\n- Line 416: `mail.search(None, f'HEADER Message-ID \"{search_id}\"')`\n- Line 447: Same pattern in `_smtp_reply_email`\n- Line 542: Same pattern in `_smtp_archive_email`\n\nThe `search_id` / `message_id` parameter in these functions is also LLM-controlled via the `reply_email` and `archive_email` public tool functions.\n\n**Reachability:** The `search_emails`, `reply_email`, and `archive_email` functions are exposed as agent tools. They are reachable when an agent is configured with email tools (EMAIL_ADDRESS + EMAIL_PASSWORD environment variables set). This is a documented deployment scenario for email-capable agents.\n\n## PoC\n\n**Setup:** Requires an IMAP server (not run here — this is a static proof). The vulnerability is demonstrated by tracing the data flow.\n\n**Positive trigger — IMAP injection via `search_emails`:**\nAn LLM agent processing a crafted prompt calls:\n```python\nsearch_emails(from_addr='user@example.com\" LOGOUT')\n```\nThis produces the IMAP command:\n```\nSEARCH FROM \"user@example.com\" LOGOUT\"\n```\nThe `LOGOUT` command is injected after the prematurely closed quoted string, causing the IMAP connection to be terminated.\n\n**More severe injection — exfiltrate emails from another folder:**\n```python\nsearch_emails(query='\" SEARCH RETURN (MIN) ALL')\n```\nProduces: `TEXT \"\" SEARCH RETURN (MIN) ALL\"` — injects a secondary SEARCH command.\n\n**Negative control — legitimate search:**\n```python\nsearch_emails(from_addr='user@example.com')\n```\nProduces: `FROM \"user@example.com\"` — correct, no injection.\n\n**Cleanup:** No persistent changes for read-only injection. For destructive injection (DELETE, EXPUNGE), impact persists.\n\n## Impact\n\nAn attacker who can craft prompts that cause an LLM agent to call `search_emails` with injection payloads can:\n\n- **Terminate IMAP connections** (denial of service)\n- **Inject arbitrary IMAP commands** — including LIST (enumerate folders), SELECT (switch folders), FETCH (read emails from other mailboxes), STORE (modify flags), COPY/MOVE (move emails), DELETE/EXPUNGE (permanently delete emails)\n- **Exfiltrate email contents** from folders the user did not intend to expose to the agent\n- **Permanently delete emails** via injected DELETE + EXPUNGE commands\n\nThe attack requires the IMAP backend to be configured (EMAIL_ADDRESS + EMAIL_PASSWORD env vars), which is a documented and common deployment for email-capable agents.\n\n## Suggested remediation\n\n1. **Escape double-quote characters** in IMAP parameters. Per RFC 3501, literal strings use `{n}\\r\\n` format or quoted strings with `\\` escaping:\n```python\ndef _escape_imap_string(s: str) -> str:\n    \"\"\"Escape a string for safe use in IMAP quoted strings.\"\"\"\n    # Use IMAP literal syntax for safety: {length}\\r\\n<data>\n    encoded = s.encode('utf-8')\n    return f'{{{len(encoded)}}}\\r\\n{encoded}'\n```\n\n2. Use IMAP literal syntax (`{n}\\r\\ndata`) instead of quoted strings for all user-controlled parameters. This prevents any injection regardless of content.\n\n3. Apply the escaping to all IMAP search criteria parameters: `from_addr`, `subject`, `query`, and `search_id`/`message_id`.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "praisonaiagents"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.6.59"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 1.6.48"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/MervinPraison/PraisonAI/security/advisories/GHSA-c969-5x3p-vq3v"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/MervinPraison/PraisonAI"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-20", "CWE-77" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-06-18T14:25:03Z",
    "nvd_published_at" : null
  }
}