Summary
MCP Atlassian's confluence_download_attachment tool allows callers to specify an arbitrary filesystem path for saving Confluence attachments, without enforcing directory boundaries.
If an attacker can invoke this tool and control the attachment content, they can write arbitrary files anywhere the server has permission, which can be leveraged for remote code execution (e.g., by planting cron jobs or overwriting application files).
Affected context
This vulnerability occurs in MCP Atlassian deployments that:
- Expose the
confluence_download_attachmenttool to users, agents, or other services, and - Allow callers to influence the
download_pathparameter, and - Operate with filesystem write permissions to sensitive locations (e.g., application directories, cron configuration paths, or scripts executed by other components).
The risk is highest when the MCP server runs with elevated privileges or shares a filesystem with other sensitive services, such as system schedulers or production applications.
Exploit preconditions
- Attack surface: The MCP server interface that exposes the
confluence_download_attachmenttool. - Required access: Ability to call the tool (directly or indirectly via an agent/integration) and access or upload a Confluence attachment.
- Trigger point: Supplying a
download_pathpointing to a chosen filesystem location while providing an attachment whose content is controlled by the attacker. - Why exploitation is possible:
- The implementation trusts the
download_pathparameter and does not restrict it to a safe directory or validate it against traversal or absolute paths. - The content written to disk is sourced directly from a Confluence attachment that the attacker can control.
- Together, this matches CWE-22 (improper path validation) and CWE-73 (external entity controls file path for critical resource).
Why this happens
The core issue is the lack of path validation and directory confinement when writing downloaded attachments to disk.
The tool accepts a user-influenced download_path and writes attachment data to that path without:
- Normalizing and checking for traversal sequences (e.g.,
../), - Enforcing a fixed base directory or storage root,
- Restricting absolute paths or sensitive system locations.
This reflects CWE-22 (Improper Limitation of a Pathname to a Restricted Directory) combined with CWE-73 (External Control of File Name or Path), where an external party dictates both the file location and, through the uploaded attachment, the file contents. The pattern is an unconstrained file-write API that executes in a privileged or shared environment.
Potential impact
- Attacker-controlled files may be written into system directories (e.g.,
/etc/cron.d/) leading to code execution via scheduled tasks. - Application scripts or configuration files can be overwritten to execute arbitrary code on next load or restart.
- Log or data files can be poisoned, potentially influencing downstream processing jobs or analytics.
- Local privilege boundaries may be weakened if the MCP server runs with higher privileges than other components.
- Integrity of the server's filesystem can be compromised, enabling persistent backdoors or tampering.
General mitigation guidance
Effective mitigation typically focuses on constraining where and how files are written, and reducing the privileges of the writing process:
- Directory confinement: Restrict all attachment downloads to a dedicated, application-controlled directory that is not executable and not shared with system components or schedulers.
- Path validation: Normalize and validate requested paths to ensure they remain within the allowed directory; reject absolute paths and any resolved path that escapes the intended root.
- Non-executable storage: Configure the download directory as non-executable and avoid placing it on paths scanned by schedulers, interpreters, or auto-load mechanisms.
- Least privilege: Run the MCP server under a user account with minimal filesystem permissions, preventing writes to system and application code directories.
- Separation of concerns: Avoid using downloaded file locations for code, configuration, or job discovery mechanisms to break the path from file write to code execution.
How teams detect issues like this
Organizations can detect and monitor this class of vulnerability using both code-centric and operational techniques:
- Static analysis: Flag file-write operations that:
- Accept user- or tool-controlled paths,
- Do not enforce a fixed base directory,
- Fail to normalize and validate the resulting path.
- Code review indicators:
- Functions that take a
pathorfilenameparameter derived from request or tool input. - Direct concatenation of user-provided strings into filesystem paths.
- Absence of checks ensuring the final path resides under a known safe directory.
- Policy enforcement:
- Security checks in CI to prohibit arbitrary path writes without a validation wrapper.
- Enforcement of "safe file storage" helpers or shared libraries for all download and save operations.
- Runtime monitoring:
- File integrity monitoring on sensitive directories (e.g.,
/etc/, application config or script directories). - Logging and anomaly detection for unexpected writes in system or application code paths.

