CVE-2026-78254: Apache Ant: Path traversal in ftp and scp tasks allows arbitrary file write
The ftp and scp tasks of Apache Ant can download files from a remote server. A malicious server can provide relative paths that allow it to write outside of the dedicated target directory for the download, making it possible to overwrite files of the attacker's choice using the permissions of the user running Ant in versions prior to Ant 1.10.18.
In order to exploit this vulnerability, the server would either have to be malicious or be subject to a machine-in-the-middle attack. Additionally in the case of scp or the ftp task using ftps the server must pass the server identity checks performed by the tasks.
For ftp tasks not using ftps a malicious server could act as a machine-in-the-middle to provide malicious files.
Starting with Ant 1.10.18 both tasks will prevent writing outside of the destination directory by default. An option is available to disable this behavior in the unlikely case that the old behavior is required by existing build files.
Mitigations:
Users of scp and ftp (when using ftps) in any version of Ant should not bypass server identity checks. Users of ftp not using ftps should switch to ftps where possible.
All users are recommended to upgrade to Apache Ant 1.10.18, which fixes this issue.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
Apache Antto a version that resolves this vulnerability.Fixed in 1.10.18 - Configuration
In Ant 1.10.18, ftp tasks prevent writing outside the destination directory by default. If an option exists to disable this behavior, keep it enabled unless existing build files require the old behavior.
Apache Ant ftp task preventWritingOutsideDestinationDirectory (path traversal mitigation option) = enabled - Configuration
In Ant 1.10.18, scp tasks prevent writing outside the destination directory by default. If an option exists to disable this behavior, keep it enabled unless existing build files require the old behavior.
Apache Ant scp task preventWritingOutsideDestinationDirectory (path traversal mitigation option) = enabled - Configuration
For ftp tasks not using ftps, switch to ftps where possible to reduce the risk from malicious servers or machine-in-the-middle attacks.
Apache Ant ftp task ftps = enabled - Configuration
For scp and ftp tasks using ftps, ensure the tasks perform (and you do not bypass) the server identity checks.
Apache Ant ftp task (ftps) and scp task server identity checks = must not be bypassed
Event History
Frequently Asked Questions
Which deployments are exposed to this issue?
Deployments that use Ant's ftp or scp download tasks are exposed when the remote server is malicious or can be intercepted by a machine-in-the-middle attacker. The impact is limited by the permissions of the user account running Ant.
What additional conditions are required to exploit downloads over SCP or FTPS?
For scp and ftp tasks using FTPS, the malicious or intercepted server must also pass the server identity checks performed by the Ant tasks. Users should not bypass these identity checks.
Are unencrypted FTP downloads at greater risk?
Yes. For ftp tasks not using FTPS, a malicious server can act as a machine-in-the-middle and provide malicious files; switching to FTPS is recommended where possible.
What configuration changes address the issue if upgrading is possible?
Upgrade to Apache Ant 1.10.18. In that version, ftp and scp tasks prevent writes outside the destination directory by default; ensure the option that restores the old behavior has not been enabled.