Skip to content

Job ownership checks are skipped for tokens without a sub claim #2986

Backlog

Description

@johngrimes

The owner of an asynchronous job is the sub claim of the token that started it. The JWT decoder does not require the claim: only issuer and audience validators are installed (server/src/main/java/au/csiro/pathling/security/PathlingJwtDecoderBuilder.java:140-141). When the caller's token has no sub, the ownership checks behave as follows:

  • $result skips the comparison (server/src/main/java/au/csiro/pathling/operations/bulkexport/ExportResultProvider.java:112): if (currentUserId.isPresent() && !ownerId.equals(currentUserId)). The same pattern is in server/src/main/java/au/csiro/pathling/operations/sql/SqlExportSupport.java:130 and server/src/main/java/au/csiro/pathling/operations/bulkimport/ImportPnpProvider.java:137.
  • $job and $job-result compare two empty values as equal (server/src/main/java/au/csiro/pathling/async/JobProvider.java:112, :155; server/src/main/java/au/csiro/pathling/async/JobResultProvider.java:106), so all callers without a sub are treated as one owner.

$jobs handles this correctly and shows nothing to a caller without a subject (server/src/main/java/au/csiro/pathling/async/JobListProvider.java:133).

Reproduced on a build of release/server/3.2.0 (f70763af29) with authorisation enabled. A user with the subject alice had a completed export job:

Token GET /fhir/$result?job=<alice's job>&file=patients.00000.csv
sub of carol, pathling:export 403, "not owned by the current user 'carol'"
No sub, pathling:export 200, with the content of alice's file

This matters where the identity provider issues access tokens without a subject, which some do for the client credentials grant. The caller still needs the job identifier and file name.

Suggested change: treat an absent subject as matching no owner, as JobListProvider does, or reject tokens without sub when they are decoded.

Acceptance: the second request in the table returns 403, covered by tests for each of the providers above.

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