Skip to content

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

Open

Description

@pwntester

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.

Activity

  1. changed the title [-]General issue[/-] [+]Java: queries about user-controlled URLs should be sanitized by enforcing a prefix[/+] on Oct 21, 2020
  2. smowton commented on Oct 21, 2020

    @smowton
    Contributor

    Added a descriptive title

  3. smowton commented on Oct 21, 2020

    @smowton
    Contributor

    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

  4. github-actions commented on Apr 16, 2021

    @github-actions
    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.

  5. neverlovelynn commented on Apr 16, 2021

    @neverlovelynn

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

  6. smowton commented on Apr 16, 2021

    @smowton
    Contributor

    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.

  7. ZH3FENG commented on May 20, 2021

    @ZH3FENG

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

  8. pwntester commented on Feb 23, 2022

    @pwntester
    ContributorAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    JavaquestionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions