aglinxinyuan opened a new pull request, #7605:
URL: https://github.com/apache/texera/pull/7605

   ### What changes were proposed in this PR?
   
   `cloneWorkflow` fetched the source workflow by `wid` and copied its content 
into a workflow owned by the caller, with no access check on the way in. Any 
authenticated REGULAR user could `POST /workflow/clone/<wid>` for a wid they 
hold no privilege on and receive a full copy of a private workflow's content — 
operator configurations, file paths and all.
   
   **Root cause.** Every sibling on this path guards; this one endpoint did not.
   
   | Endpoint | Guard |
   |---|---|
   | `retrieveWorkflow` | `hasReadAccess` directly |
   | `duplicateWorkflow` | `hasReadAccess` directly |
   | `cloneVersion` (`/version/clone/{vid}`) | inherits it via 
`retrieveWorkflowVersion` |
   | **`cloneWorkflow`** | **none** |
   
   That reads as an oversight rather than a decision. SECURITY.md states that 
REGULAR users "cannot access other users' private resources without granted 
permissions", so the endpoint contradicted the project's own declared model.
   
   **Before → after**
   
   ```
    caller with no privilege on wid
      |
      v                                   v
    POST /workflow/clone/{wid}          POST /workflow/clone/{wid}
      |                                   |
      |  (no check)                       +-- hasReadAccess(wid, uid)? --> no 
--> 403
      v                                   |
    fetchOneByWid(wid)                    v  yes (owner / READ grant / public)
      |                                 fetchOneByWid(wid)
      v                                   |
    full content copied to caller         v
                                        full content copied to caller
   ```
   
   The fix adds the same three lines the siblings use. `hasReadAccess` already 
returns true for public workflows, so the hub's clone button — the only caller, 
and always acting on a published workflow — is unaffected. A caller holding an 
explicit READ grant can still clone.
   
   ### Any related issues, documentation, discussions?
   
   Found while reviewing the clone-endpoint test in #7592, which this is 
stacked on; only the last commit belongs to this PR. Not filed as an issue, 
because SECURITY.md asks that security bugs not be reported through public 
issues.
   
   ### How was this PR tested?
   
   Two cases added to the existing `WorkflowResourceSpec`, and the pre-existing 
success case in #7592 now publishes its source first so it exercises the public 
path.
   
   | Test | Pins |
   |---|---|
   | `clone a private workflow the caller has been granted read access to` | 
the guard does not over-block a legitimate READ grant |
   | `reject a caller with no access to the source workflow` | 403, no copy 
reaches the caller, and no `WORKFLOW_USER_CLONES` row is written for the 
rejected attempt |
   
   Red before the guard, green after — with the guard reverted the rejection 
case fails and the other 69 pass, so it is the guard the test is pinning and 
not a fixture.
   
   ```
   sbt "WorkflowExecutionService/testOnly 
org.apache.texera.web.resource.dashboard.file.WorkflowResourceSpec"
   ```
   
   ```
   [info] Total number of tests run: 70
   [info] Tests: succeeded 70, failed 0, canceled 0, ignored 0, pending 0
   ```
   
   `scalafmtCheck` and `scalafix --check` pass for both `Compile` and `Test`.
   
   ### Was this PR authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code (Opus 5)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to