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

OneDev Unauthenticated Arbitrary File Read (CVE-2024-45309) #19614

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

vultza
Copy link

@vultza vultza commented Nov 2, 2024

This module exploits an unauthenticated arbitrary file read vulnerability (CVE-2024-45309), which affects OneDev versions <= 11.0.8.

Verification

A vulnerable Docker image version (v11.0.8) can be found here.

  1. Setup the OneDev application
  2. Start msfconsole
  3. Do: use auxiliary/gather/onedev_arbitrary_file_read
  4. Set the RHOSTS and RPORT options as necessary
  5. Set the TARGETFILE option with the absolute path of the target file to read

If a valid project name is known:

  1. Set the PROJECT_NAME option with the known project name
  2. Do: run
  3. If the file exists, the contents will be displayed to the user

If there is no information about existing projects:

  1. Set the PROJECT_NAMES_FILE option with the absolute path of a wordlist that contains multiple possible values for a valid project name
  2. Do: run
  3. If a valid project name is found, the target file contents will be displayed to the user

modules/auxiliary/gather/onedev_arbitrary_file_read.rb Outdated Show resolved Hide resolved
modules/auxiliary/gather/onedev_arbitrary_file_read.rb Outdated Show resolved Hide resolved
modules/auxiliary/gather/onedev_arbitrary_file_read.rb Outdated Show resolved Hide resolved
Comment on lines 105 to 107
fail_with(Failure::NoTarget, 'No valid OneDev project was found.') unless project_name

fail_with(Failure::NoTarget, 'Provided project name is invalid.') unless validate_project_exists(project_name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will validate twice that the project is valid. It's not super-duper-critical, but it would be nice to minimize the amount of requests :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I agree that this double check is redundant, I updated this section on c9e0668 to validate the project name only with the user-provided project name

modules/auxiliary/gather/onedev_arbitrary_file_read.rb Outdated Show resolved Hide resolved
modules/auxiliary/gather/onedev_arbitrary_file_read.rb Outdated Show resolved Hide resolved
def find_project
print_status 'Bruteforcing a valid project name…'

File.open(datastore['PROJECT_NAMES_FILE'], 'rb').each do |project|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed there is no PROJECT_NAMES_FILE included in the PR. Could you add a guard here incase the file doesn't exist to prevent the module from failing?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used as the PROJECT_NAMES_FILE option fallback a metasploit wordlist namelist.txt that exists in every metasploit installation. Even if the provided file path doesn't exist, the module doesn't crash because it throws a validation error (Msf::OptionValidateError) before running the module.

The only thing I can do is to remove the default fallback path for the case that somehow the default wordlist file doesn't exist.

##

class MetasploitModule < Msf::Auxiliary
include Msf::Exploit::Remote::HttpClient
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will run the check method automagically

Suggested change
include Msf::Exploit::Remote::HttpClient
include Msf::Exploit::Remote::HttpClient
prepend Msf::Exploit::Remote::AutoCheck

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason why I didn't place the autocheck is to prevent the module execution interruption when the target OneDev instance doesn't have anonymous access enabled, since in this case, the check function fails to detect if the OneDev instance is vulnerable, even thought it is. Should I still enable the autocheck in this case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants