Ecosyste.ms: Advisories
An open API service providing security vulnerability metadata for many open source software ecosystems.
Security Advisories: MDE2OlNlY3VyaXR5QWR2aXNvcnlHSFNBLTQ3d3ItNDI2ai1mcjgy
Symbolic links in an unpacking routine may enable attackers to read and/or write to arbitrary locations in dbdeployer
Impact
Users unpacking a tarball through dbdeployer may use a maliciously packaged tarball that contains symlinks to files external to the target. In such scenario, an attacker could induce dbdeployer to write into a system file, thus altering the computer defences.
Mitigating factors
For the attach to succeed, the following factors need to contribute:
- The user is logged in as root. While dbdeployer is usable as root, it was designed to run as unprivileged user.
- The user has taken a tarball from a non secure source, without testing the checksum. When the tarball is retrieved through dbdeployer, the checksum is compared before attempting to unpack.
Analysis
An attacker could inject a symbolic link into the tarball, so that a file could result into fake_file -> /etc/passwd
or some equally important file.
As it is now, dbdeployer would create the symlink as defined, with a local file fake_file
linked to /etc/passwd
. The danger here is that any process with the privileges to write to both fake_file
and /etc/passwd
could overwrite the system file. Even without malicious intent, this could result in the system to become unusable.
As noted above, the user must have write privileges to the target file to do the damage.
Remedies
It has been suggested that the extract procedure use filepath.EvalSymlinks
to determine whether the target is within the extraction directory. Unfortunately, this approach is unavailable in this context, because it would prevent legitimate patterns from being carried out.
A simple case is a file mysql-8.0.22-macos10.15-x86_64/bin/libprotobuf-lite.3.11.4.dylib
with a linkName ../lib/libprotobuf-lite.3.11.4.dylib
, if the linked file has not been created yet, filepath.EvalSymlinks
would fail, as it acts on existing files only.
An alternative method is comparing the depth (how many directories) of the file name with the depth of the link name. If the link name has a higher depth than the local file, we block the operation with an appropriate error:
Unpacking tarball exploit/mysql-8.0.22-macos10.15-x86_64.tar.gz to $HOME/opt/mysql/test8.0.22
......
link '../../../../../../../../../../etc' points outside target directory
exit status 1
As an additional fortifier, we can check whether the link points to an existing file, calculate its absolute name, and compare it with the absolute name of the extraction directory. A link to a full path (such as /etc/passwd
) would fail this test, and trigger an error.
The same check can be applied to a link to a non existing file with absolute path.
Patches
Patched in release 1.58.2
For more information
If you have any questions or comments about this advisory:
- Open an issue in dbdeployer
JSON: https://advisories.ecosyste.ms/api/v1/advisories/MDE2OlNlY3VyaXR5QWR2aXNvcnlHSFNBLTQ3d3ItNDI2ai1mcjgy
Source: GitHub Advisory Database
Origin: Unspecified
Severity: Moderate
Classification: General
Published: about 2 years ago
Updated: about 1 year ago
CVSS Score: 6.1
CVSS vector: CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:N/I:H/A:N
Identifiers: GHSA-47wr-426j-fr82, CVE-2020-26277
References:
- https://github.com/datacharmer/dbdeployer/security/advisories/GHSA-47wr-426j-fr82
- https://nvd.nist.gov/vuln/detail/CVE-2020-26277
- https://github.com/datacharmer/dbdeployer/commit/548e256c1de2f99746e861454e7714ec6bc9bb10
- https://github.com/advisories/GHSA-47wr-426j-fr82
Blast Radius: 1.8
Affected Packages
go:github.com/datacharmer/dbdeployer
Dependent packages: 0Dependent repositories: 2
Downloads:
Affected Version Ranges: < 1.58.2
Fixed in: 1.58.2
All affected versions: 1.16.0, 1.17.0, 1.19.0, 1.21.0, 1.22.0, 1.23.0, 1.24.0, 1.26.0, 1.27.0, 1.28.0, 1.28.1, 1.29.0, 1.30.0, 1.30.1, 1.31.0, 1.32.0, 1.33.0, 1.34.0, 1.35.0, 1.36.0, 1.36.1, 1.38.0, 1.39.0, 1.39.1, 1.40.0, 1.41.0, 1.42.0, 1.43.0, 1.43.1, 1.44.0, 1.45.0, 1.46.0, 1.47.0, 1.49.0, 1.50.0, 1.50.1, 1.50.2, 1.51.0, 1.51.1, 1.51.2, 1.52.0, 1.53.0, 1.53.1, 1.53.2, 1.53.3, 1.54.0, 1.54.1, 1.55.0, 1.56.0, 1.57.0, 1.58.0, 1.58.1
All unaffected versions: 1.58.2, 1.59.0, 1.60.0, 1.61.0, 1.62.0, 1.63.0, 1.63.1, 1.64.0, 1.65.0, 1.65.1, 1.65.2, 1.66.0, 1.67.0, 1.68.0, 1.69.0, 1.69.1, 1.69.2, 1.69.3, 1.70.0, 1.71.0, 1.72.0, 1.73.0