Skip to content

fix gitlab version errors#21489

Draft
h00die wants to merge 2 commits into
rapid7:masterfrom
h00die:fix_gitlab_errors
Draft

fix gitlab version errors#21489
h00die wants to merge 2 commits into
rapid7:masterfrom
h00die:fix_gitlab_errors

Conversation

@h00die
Copy link
Copy Markdown
Contributor

@h00die h00die commented May 21, 2026

While using MSF Pro's autodiscovery feature, it ran auxiliary/scanner/http/gitlab_version against some non-gitlab instances. The module attempted to JSON parse an HTTP HTML response during the API version portion. There were 2 bugs here:

  1. if the response isn't JSON it'll bomb out
  2. if the API version detection bombs out, the error is raised up and the help page version detection never runs

This PR fixes both by adding some rescue blocks.

Old and busted

msf > use auxiliary/scanner/http/gitlab_version 
msf auxiliary(scanner/http/gitlab_version) > set rport 8080
rport => 8080
msf auxiliary(scanner/http/gitlab_version) > set rhosts 1.1.1.1
rhosts => 11.1.1.1
msf auxiliary(scanner/http/gitlab_version) > run
[*] Error: 1.1.1.1: JSON::ParserError unexpected character: '<!doctype' at line 1 column 5
[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed
msf auxiliary(scanner/http/gitlab_version) > 

Fixed

msf > use auxiliary/scanner/http/gitlab_version
msf auxiliary(scanner/http/gitlab_version) > set rport 8080
rport => 8080
msf auxiliary(scanner/http/gitlab_version) > set rhosts 1.1.1.1
rhosts => 1.1.1.1
msf auxiliary(scanner/http/gitlab_version) > run
[-] Unable to find Gitlab version for 1.1.1.1.
[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed

Verification

  • Start msfconsole
  • use auxiliary/scanner/http/gitlab_version
  • set rhosts (for an IP that isn't running gitlab)
  • run

@smcintyre-r7
Copy link
Copy Markdown
Contributor

While using MSF Pro's autodiscovery feature, it ran auxiliary/scanner/http/gitlab_version against some non-gitlab instances. The module attempted to JSON parse an HTTP HTML response during the API version portion. There were 2 bugs here:

We definitely get issues like this coming up relatively often. Thanks for submitting this to us, I appreciate you taking the time here.

@h00die
Copy link
Copy Markdown
Contributor Author

h00die commented May 28, 2026

While using MSF Pro's autodiscovery feature, it ran auxiliary/scanner/http/gitlab_version against some non-gitlab instances. The module attempted to JSON parse an HTTP HTML response during the API version portion. There were 2 bugs here:

We definitely get issues like this coming up relatively often. Thanks for submitting this to us, I appreciate you taking the time here.

I'm guilty of creating the issue in modules, happens to the best (and worst) of us

Copy link
Copy Markdown
Contributor

@smcintyre-r7 smcintyre-r7 left a comment

Choose a reason for hiding this comment

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

Changes look good. I just ran into the one issue.

end

version = gitlab_version_help_commit(normalize_uri(target_uri.path))
return convert_to_rex_version_range(version) if version
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm getting a crash right here when the hash isn't in the map. We won't always have all the hashes in the map, so it'd be helpful if we could catch the error and handle it appropriately.

msf auxiliary(scanner/http/gitlab_version) > run
[!] The GITLAB_CSS_PATTERN was found in the response body but the hash found: b78b47d220ed679cc6edeca9043fd7b2742bc435978bd31676c59653a0a12392 does not have a corresponding version in the GITLAB_CSS_MAP
[-] Auxiliary failed: ArgumentError Malformed version number string 35d349e97ce
[-] Call stack:
[-]   /home/smcintyre/.rvm/rubies/ruby-3.3.8/lib/ruby/site_ruby/3.3.0/rubygems/version.rb:210:in `initialize'
[-]   /home/smcintyre/Projects/metasploit-framework.pr/lib/rex/version.rb:10:in `initialize'
[-]   /home/smcintyre/.rvm/rubies/ruby-3.3.8/lib/ruby/site_ruby/3.3.0/rubygems/version.rb:199:in `new'
[-]   /home/smcintyre/.rvm/rubies/ruby-3.3.8/lib/ruby/site_ruby/3.3.0/rubygems/version.rb:199:in `new'
[-]   /home/smcintyre/Projects/metasploit-framework.pr/lib/msf/core/exploit/remote/http/gitlab/version.rb:436:in `convert_to_rex_version_range'
[-]   /home/smcintyre/Projects/metasploit-framework.pr/lib/msf/core/exploit/remote/http/gitlab/version.rb:457:in `gitlab_version'
[-]   /home/smcintyre/Projects/metasploit-framework.pr/modules/auxiliary/scanner/http/gitlab_version.rb:23:in `run_host'
[-]   /home/smcintyre/Projects/metasploit-framework.pr/lib/msf/core/auxiliary/scanner.rb:130:in `block (2 levels) in run'
[-]   /home/smcintyre/Projects/metasploit-framework.pr/lib/msf/core/thread_manager.rb:105:in `block in spawn'
[*] Auxiliary module execution completed
msf auxiliary(scanner/http/gitlab_version) >

FWIW my version is 19.0.0 and the hash is b78b47d220ed679cc6edeca9043fd7b2742bc435978bd31676c59653a0a12392 if you want to add it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed it, not pushing yet though. going to work on a way to build out this css_map. we're about 200 releases behind so this needs to be automated.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

msf auxiliary(scanner/http/gitlab_version) > rerun
[*] Reloading module...
[!] The GITLAB_CSS_PATTERN was found in the response body but the hash found: b78b47d220ed679cc6edeca9043fd7b2742bc435978bd31676c59653a0a12392 does not have a corresponding version in the GITLAB_CSS_MAP
[!] Unable to process version 5ac3a0e92e7 from help page (possible commit hash)
[-] Unable to find Gitlab version for 127.0.0.1.

@github-project-automation github-project-automation Bot moved this from Todo to Waiting on Contributor in Metasploit Kanban May 28, 2026
@h00die h00die marked this pull request as draft May 28, 2026 17:26
@h00die
Copy link
Copy Markdown
Contributor Author

h00die commented May 28, 2026

bringing back to draft while I try out and update the 425 missing versions from here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Waiting on Contributor

Development

Successfully merging this pull request may close these issues.

2 participants