GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Java: CWE-552 Query to detect configuration file/source code exposure from unsafe request dispatcher by luchua-bc · Pull Request #6251 · github/codeql

Conversation

@luchua-bc

@luchua-bc luchua-bc commented Jul 11, 2021

Copy link
Copy Markdown
Contributor

Directly incorporating user input into HTTP requests dispatched from the Java EE RequestDispatcher without validating the input can allow any web application resource such as configuration files and source code to be disclosed.

As stated in the Java API doc, when using a Java EE RequestDispatcher, requests may be dispatched to any part of the web application bypassing both implicit (no direct access to WEB-INF or META-INF) and explicit (defined by the web application) security constraints. Unsanitized user provided data must not be used to construct the path passed to the RequestDispatcher as it is very likely to create a security vulnerability in the application.

This query detects unsafe invocations of RequestDispatcher with user controlled input. Please consider to merge the PR. Thanks.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@luchua-bc
Query to detect unsafe request dispatcher
be830de
@luchua-bc
luchua-bc requested a review from a team as a code owner July 11, 2021 20:35
@github-actions github-actions Bot added documentation Java labels Jul 11, 2021
@luchua-bc luchua-bc mentioned this pull request Jul 11, 2021
[Java] CWE-552: Query to detect configuration file/source code exposure from unsafe request dispatcher github/securitylab#398
Closed
1 task done
@haby0

haby0 commented Jul 12, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

@luchua-bc Hello, this pr is the same as the one I submitted. #6240

In addition, your title is wrong, it should be CWE-552.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@luchua-bc luchua-bc changed the title Java: CWE-522 Query to detect configuration file/source code exposure from unsafe request dispatcher Java: CWE-552 Query to detect configuration file/source code exposure from unsafe request dispatcher Jul 12, 2021
@luchua-bc

luchua-bc commented Jul 12, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

@luchua-bc Hello, this pr is the same as the one I submitted. #6240

In addition, your title is wrong, it should be CWE-552.

Oops! I searched security lab issues that are in the open status and the keyword CWE-552 in the codeql repository but didn't find anything including yours before I started to work on my submission. I should have searched pull requests that are in the open status.

I just took a look and our queries do have a common piece - yours already covers the getRequestDispatcher method in the method ServletRequestGetRequestDispatcherMethod with ServletRequest. However, my query also covers RequestDispatcher initialized from ServletContext as well as the new/latest API in the package jakarta.servlet.

I will merge my query with yours after yours is merged into the main branch.

@luchua-bc

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@luchua-bc
Add query for Java EE resource loading check
93ab08b
@luchua-bc

luchua-bc commented Jul 18, 2021

Copy link
Copy Markdown
Contributor Author

@haby0 I've added a distinct new category of checking getResource to my query, which also touches the path traversal vulnerability in this scenario. That is, it not only allows to check the malicious pattern of /WEB-INF/web.xml but also allows to check the pattern with path traversal such as /pages/public_page.jsp/../../WEB-INF/web.xml.

haby0 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@luchua-bc luchua-bc closed this Jan 23, 2022
@luchua-bc
luchua-bc deleted the java/unsafe-request-dispatch branch January 23, 2022 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

documentation Java

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@luchua-bc @haby0
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.