Robert Metzger created FLINK-41694:
--------------------------------------

             Summary: Validate jar IDs in the web submission REST handlers
                 Key: FLINK-41694
                 URL: https://issues.apache.org/jira/browse/FLINK-41694
             Project: Flink
          Issue Type: Bug
          Components: Runtime / Web Frontend
            Reporter: Robert Metzger


JarIdPathParameter.convertFromString() only rejects values where 
Paths.get(value).getParent() != null. That lets .., . and an empty string 
through, because they have no parent. The handlers then resolve the value 
against the upload directory (jarDir.resolve(jarId)), which points at the 
upload directory itself or its parent instead of an uploaded jar:

- GET/POST /jars/../plan, /jars/./run and /jars//plan fail with HTTP 500 and a 
stack trace instead of HTTP 400.
- DELETE /jars/ with an empty ID calls Files.delete() on the upload directory, 
which deletes it when it is empty.

Proposed changes:

1. In JarIdPathParameter.convertFromString(), reject empty values, . and .., 
and keep the existing separator check.
2. In JarHandlerUtils and JarDeleteHandler, resolve the ID once in a shared 
helper. The helper normalizes the path and requires that its parent equals 
jarDir and that it is a regular file. Otherwise it returns HTTP 400 ("jar not 
found"), not 500.
3. Add tests for .., ., %2E%2E, an empty ID, an ID with a path separator, and a 
valid uploaded jar ID, for both the run/plan handlers and the delete handler.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to