You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
java.io.File, java.nio.file.Paths/Path constructors (verify they are already modeled)
Spring MultipartFile.transferTo and servlet Part.write
Data Extension Description
A public synthetic Spring app accepts an unvalidated username on profile update and uses it in a filesystem path for the upload. java/path-injection did not alert; the workbook calls it a missing summary. Verify which step (string concat into new File(base, user) or a stored value rather than a request value) is not covered before adding rows.
Profile updates accept an unvalidated username and use it in a filesystem path for the uploaded file.
Findings come from AI Scan on public synthetic apps. CodeQL alerts were not produced in the baseline CodeQL default-setup scan. Hypotheses above are unverified until reproduced with a test database.
Code Examples
Filedest = newFile(uploadDir + "/" + username + ".png"); // should be flaggedfile.transferTo(dest);
The public index page prefixes the attacker-controlled content parameter with static/ and passes it directly to <jsp:include>, without canonicalization or an allowlist.
Update: additional findings from a later rescan fit this gap (gap-key java/data-extension/path-injection-username-upload). Forwarded to pull request #62 for the Copilot agent to re-validate.
precision:very-highExact API/type-based fix, no heuristics. github/codeql candidate if the pattern is real-world.
Candidate for github/codeql. Very high precision with a real-world basis and no material performance or false-positive concerns. No tags:experimental label.
Why. Stock CodeQL models MultipartFile and Part as sources but has no path-injection sink for MultipartFile.transferTo(File|Path) or Part.write(String), which write an upload to a caller-supplied path. Four exact sink rows for public Spring and Servlet APIs, with javax and jakarta variants and passing tests, are a clear model addition used by many upload handlers. Precision is very-high and the real-world basis is general.
Change
Data extension (model) addition
Target
java/path-injection sinks: Spring MultipartFile.transferTo(File|Path) and servlet Part.write(String), javax and jakarta
Precision
assessed very-high. Four sinkModel rows with exact qualified names and signatures for public Spring and Servlet APIs whose argument is the destination path; no heuristics. Tests cover javax, jakarta, Spring File and Path, and Content-Disposition filename cases.
Real-world basis
general. Spring MVC MultipartFile.transferTo(File|Path) and servlet Part.write(String) (javax and jakarta) are standard upload-handling APIs used by many applications; no synthetic identifiers in the model.
Stock overlap
none. java-all 9.3.0 ext models MultipartFile and Part as sources only (grep); github/codeql main has no transferTo or Part.write sink (gh code search and multipart model file).
Concerns, overlap and next steps
False-positive concerns
Part.write(String) resolves relative names against the configured upload location, so a tainted bare file name is lower impact than an absolute path.
What an upstream change would look like. Add the four path-injection sinkModel rows to java/ql/lib/ext/jakarta.servlet.http.model.yml, javax.servlet.http.model.yml and org.springframework.web.multipart.model.yml; test under java/ql/test/query-tests/security/CWE-022 with upstream stubs; java/ql/lib/change-notes minorAnalysis note.
Before opening an upstream pull request
Move the rows from the custom pack into the three existing ext model files instead of a new model file.
Rebuild the test on the upstream Spring multipart and servlet Part stubs under java/ql/test/stubs and the CWE-022 query test.
Add a java/ql/lib/change-notes entry (minorAnalysis).
Describe a real upload handler where an unsanitized name reaches transferTo or Part.write in the PR text.
This is a recommendation only. A human reviews it before any pull request is opened against github/codeql or the Community Packs repository.
Activity
felickz commentedon Oct 16, 2026
Additional high-severity AI Scan findings matching this gap:
contentparameter withstatic/and passes it directly to<jsp:include>, without canonicalization or an allowlist.felickz commentedon Oct 30, 2026
Update: additional findings from a later rescan fit this gap (gap-key
java/data-extension/path-injection-username-upload). Forwarded to pull request #62 for the Copilot agent to re-validate.felickz commentedon Nov 3, 2026
Upstream triage
precision:very-highExact API/type-based fix, no heuristics. github/codeql candidate if the pattern is real-world.
Candidate for
github/codeql. Very high precision with a real-world basis and no material performance or false-positive concerns. Notags:experimentallabel.Linked pull request: #62
Why. Stock CodeQL models MultipartFile and Part as sources but has no path-injection sink for MultipartFile.transferTo(File|Path) or Part.write(String), which write an upload to a caller-supplied path. Four exact sink rows for public Spring and Servlet APIs, with javax and jakarta variants and passing tests, are a clear model addition used by many upload handlers. Precision is very-high and the real-world basis is general.
Concerns, overlap and next steps
False-positive concerns
What an upstream change would look like. Add the four path-injection sinkModel rows to java/ql/lib/ext/jakarta.servlet.http.model.yml, javax.servlet.http.model.yml and org.springframework.web.multipart.model.yml; test under java/ql/test/query-tests/security/CWE-022 with upstream stubs; java/ql/lib/change-notes minorAnalysis note.
Before opening an upstream pull request
This is a recommendation only. A human reviews it before any pull request is opened against
github/codeqlor the Community Packs repository.