Skip to content

Import source allowlist is bypassed by .. segments and sibling paths for non-HTTP sources #2979

Backlog

Description

@johngrimes

pathling.import.allowableSources is matched by plain string prefix for anything other than HTTP(S) (server/src/main/java/au/csiro/pathling/config/UrlAllowlist.java:115-116, return url.startsWith(prefix);). The url of each input is percent-decoded and passed to Spark without normalisation (server/src/main/java/au/csiro/pathling/operations/bulkimport/ImportOperationValidator.java:252-253). Two kinds of URL therefore pass the check while pointing outside the configured location:

  • A sibling path that shares the prefix. The shipped default is file:///usr/share/staging, with no trailing slash, so file:///usr/share/staging-other/... matches.
  • A path containing .. segments, which matches the prefix as a string and is then resolved by the file system. A trailing slash on the prefix does not prevent this.

Reproduced on a build of release/server/3.2.0 (f70763af29) with pathling.import.allowableSources=file:///tmp/audit/staging:

input.url Result
file:///tmp/audit/staging-evil/Patient.ndjson Job completed, resource imported
file:///tmp/audit/staging/../other/Patient.ndjson Job completed, resource imported
file:///tmp/audit/elsewhere/Patient.ndjson 403, "is not an allowed source for import"

The request was:

{
  "inputFormat": "application/fhir+ndjson",
  "saveMode": "merge",
  "input": [{ "type": "Patient", "url": "file:///tmp/audit/staging/../other/Patient.ndjson" }]
}

A caller who can run $import (any client when authorisation is disabled, otherwise one with pathling:import and the relevant write authorities) can import any NDJSON or Parquet file that the server process can read, and then read it back through the API. That includes the tables of another database in the same warehouse and the output directories of other users' export jobs. The same matching is used for s3a:// and hdfs:// prefixes, where .. would give access to the rest of the bucket or file system. Those schemes were not tested.

#320 dealt with the trailing slash for S3 sources in 2021. The documentation recommends a trailing slash, but the default does not have one and it does not address ...

Suggested changes:

  • Parse and normalise the candidate URL, and reject any .. segment.
  • Compare scheme and authority exactly and the path on a segment boundary, as matchesHttp already does for HTTP(S).
  • Change the default to file:///usr/share/staging/.

Acceptance: the first two URLs in the table are rejected with a 403, covered by tests in UrlAllowlistTest.

Activity

  1. added
    security
    server
    on Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    securityserver

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions