VYPR
Low severityNVD Advisory· Published Oct 6, 2020· Updated Aug 4, 2024

Directory Traversal in xmpp-http-upload

CVE-2020-15239

Description

In xmpp-http-upload before version 0.4.0, when the GET method is attacked, attackers can read files which have a .data suffix and which are accompanied by a JSON file with the .meta suffix. This can lead to Information Disclosure and in some shared-hosting scenarios also to circumvention of authentication or other limitations on the outbound (GET) traffic. For example, in a scenario where a single server has multiple instances of the application running (with separate DATA_ROOT settings), an attacker who has knowledge about the directory structure is able to read files from any other instance to which the process has read access. If instances have individual authentication (for example, HTTP authentication via a reverse proxy, source IP based filtering) or other restrictions (such as quotas), attackers may circumvent those limits in such a scenario by using the Directory Traversal to retrieve data from the other instances. If the associated XMPP server (or anyone knowing the SECRET_KEY) is malicious, they can write files outside the DATA_ROOT. The files which are written are constrained to have the .meta and the .data suffixes; the .meta file will contain the JSON with the Content-Type of the original request and the .data file will contain the payload. The issue is patched in version 0.4.0.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
xmpp-http-uploadPyPI
< 0.4.00.4.0

Affected products

1

Patches

1
82056540191e

Simplify path handling, use safe_join

https://github.com/horazont/xmpp-http-uploadChristian TackeOct 5, 2020via ghsa
1 file changed · +15 34
  • xhu.py+15 34 modified
    @@ -29,6 +29,7 @@
     import typing
     
     import flask
    +import werkzeug.exceptions
     
     app = flask.Flask("xmpp-http-upload")
     app.config.from_envvar("XMPP_HTTP_UPLOAD_CONFIG")
    @@ -39,16 +40,11 @@
         CORS(app)
     
     
    -def sanitized_join(path: str, root: pathlib.Path) -> pathlib.Path:
    -    result = (root / path).absolute()
    -    if not str(result).startswith(str(root) + "/"):
    -        raise ValueError("resulting path is outside root")
    -    return result
    -
    -
    -def get_paths(base_path: pathlib.Path):
    -    data_file = pathlib.Path(str(base_path) + ".data")
    -    metadata_file = pathlib.Path(str(base_path) + ".meta")
    +def get_paths(root: str, sub_path: str) \
    +        -> typing.Tuple[pathlib.Path, pathlib.Path]:
    +    base_path = flask.safe_join(root, sub_path)
    +    data_file = pathlib.Path(base_path + ".data")
    +    metadata_file = pathlib.Path(base_path + ".meta")
     
         return data_file, metadata_file
     
    @@ -58,15 +54,10 @@ def load_metadata(metadata_file):
             return json.load(f)
     
     
    -def get_info(path: str, root: pathlib.Path) -> typing.Tuple[
    +def get_info(path: str) -> typing.Tuple[
             pathlib.Path,
             dict]:
    -    dest_path = sanitized_join(
    -        path,
    -        pathlib.Path(app.config["DATA_ROOT"]),
    -    )
    -
    -    data_file, metadata_file = get_paths(dest_path)
    +    data_file, metadata_file = get_paths(app.config["DATA_ROOT"], path)
     
         return data_file, load_metadata(metadata_file)
     
    @@ -104,11 +95,8 @@ def stream_file(src, dest, nbytes):
     @app.route("/<path:path>", methods=["PUT"])
     def put_file(path):
         try:
    -        dest_path = sanitized_join(
    -            path,
    -            pathlib.Path(app.config["DATA_ROOT"]),
    -        )
    -    except ValueError:
    +        data_file, metadata_file = get_paths(app.config["DATA_ROOT"], path)
    +    except werkzeug.exceptions.NotFound:
             return flask.Response(
                 "Not Found",
                 404,
    @@ -134,8 +122,7 @@ def put_file(path):
             "application/octet-stream",
         )
     
    -    dest_path.parent.mkdir(parents=True, exist_ok=True, mode=0o770)
    -    data_file, metadata_file = get_paths(dest_path)
    +    data_file.parent.mkdir(parents=True, exist_ok=True, mode=0o770)
     
         try:
             with write_file(data_file) as fout:
    @@ -189,13 +176,10 @@ def generate_headers(response_headers, metadata_headers):
     @app.route("/<path:path>", methods=["HEAD"])
     def head_file(path):
         try:
    -        data_file, metadata = get_info(
    -            path,
    -            pathlib.Path(app.config["DATA_ROOT"])
    -        )
    +        data_file, metadata = get_info(path)
     
             stat = data_file.stat()
    -    except (OSError, ValueError):
    +    except (OSError, werkzeug.exceptions.NotFound):
             return flask.Response(
                 "Not Found",
                 404,
    @@ -214,11 +198,8 @@ def head_file(path):
     @app.route("/<path:path>", methods=["GET"])
     def get_file(path):
         try:
    -        data_file, metadata = get_info(
    -            path,
    -            pathlib.Path(app.config["DATA_ROOT"])
    -        )
    -    except (OSError, ValueError):
    +        data_file, metadata = get_info(path)
    +    except (OSError, werkzeug.exceptions.NotFound):
             return flask.Response(
                 "Not Found",
                 404,
    

Vulnerability mechanics

Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

7

News mentions

0

No linked articles in our index yet.