Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java: queries about user-controlled URLs should be sanitized by enforcing a prefix #4530

Open
pwntester opened this issue Oct 21, 2020 · 7 comments
Labels
Java question Further information is requested

Comments

@pwntester
Copy link
Contributor

This comes from a discussion with @smowton over here.

Certain categories such as Open Redirect, SSRF and Android WebView URL injection will benefit from a sanitizer which would clean the taint in case the dataflow goes through a string prefix operation (concatenation, format strings, string buffers, string writer ...). Since not controlling the begging of the URL will severely decrease the exploitability of these issues.

@pwntester pwntester added the question Further information is requested label Oct 21, 2020
@smowton smowton changed the title General issue Java: queries about user-controlled URLs should be sanitized by enforcing a prefix Oct 21, 2020
@smowton
Copy link
Contributor

smowton commented Oct 21, 2020

Added a descriptive title

@smowton
Copy link
Contributor

smowton commented Oct 21, 2020

Looks like as well as the XSS query's clause relating to user-controlled fetches, this should also apply to other URL-based queries like java/unvalidated-url-redirection. Go's version of the same query already filters in this way here: https://github.com/github/codeql-go/blob/main/ql/src/semmle/go/security/UrlConcatenation.qll#L94

@github-actions
Copy link
Contributor

This issue is stale because it has been open 14 days with no activity. Comment or remove the stale label in order to avoid having this issue closed in 7 days.

@github-actions github-actions bot added the Stale label Apr 16, 2021
@neverlovelynn
Copy link

I encountered the same problem when using codeql. Is this problem solved now?

@aschackmull aschackmull removed the Stale label Apr 16, 2021
@smowton
Copy link
Contributor

smowton commented Apr 16, 2021

Hah, I'd forgotten about this. I ported this from Go when promoting the Java SSRF query from experimental (#5587). That should be generalised to other queries concerned with a user-controlled URL.

@ZH3FENG
Copy link

ZH3FENG commented May 20, 2021

Same as javascript, so many false-positive reports, particularly SSRF.
Is there any filter in js?

@pwntester
Copy link
Contributor Author

Another category that would benefit from this is JNDI injections where attackers need to control the beginning of the url /cc @atorralba

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Java question Further information is requested
Projects
None yet
Development

No branches or pull requests

6 participants
@pwntester @smowton @neverlovelynn @ZH3FENG @aschackmull and others