Skip to content

Conversation

@Chocapikk
Copy link
Contributor

@Chocapikk Chocapikk commented Nov 19, 2025

Adds support for GHSA (GitHub Security Advisory) and OSV (Open Source Vulnerabilities) references in Metasploit modules. Modules can now use structured reference formats instead of full URLs.

GHSA Support

The format depends on whether the GHSA is available globally or repository-specific:

  • Global format: ['GHSA', 'xxxx-xxxx-xxxx'] => https://github.com/advisories/GHSA-xxxx-xxxx-xxxx
  • Repository-specific format: ['GHSA', 'xxxx-xxxx-xxxx', 'owner/repo'] => https://github.com/owner/repo/security/advisories/GHSA-xxxx-xxxx-xxxx

OSV Support

OSV (Open Source Vulnerabilities) is a modern vulnerability database created by Google that aggregates 15+ sources and covers 25+ ecosystems (Go, Python, npm, Maven, RubyGems, GitHub advisories, and more). It provides a unified format for open source vulnerabilities.

  • Format: ['OSV', 'ECOSYSTEM-YEAR-ID'] => https://osv.dev/vulnerability/ECOSYSTEM-YEAR-ID
  • Examples: ['OSV', 'GO-2021-0113'], ['OSV', 'PYSEC-2024-123'], ['OSV', 'GHSA-8c52-x9w7-vc95']
  • Supports all OSV formats including ecosystem-specific IDs (GO-, PYSEC-, GHSA-, MINI-, etc.)

This PR also:

  • Updates existing modules to use the correct repository-specific format where needed, ensuring all GHSA references are accessible and properly linked
  • Fixes a bug with nested array structures in module references that could cause TypeError
  • Adds validation to prevent nested arrays in references (fixing a 20-year-old bug in the core)
  • Adds string conversion safety for reference initialization (handles ATT&CK constants and edge cases)

@Chocapikk Chocapikk force-pushed the add-ghsa-reference-support branch 4 times, most recently from 7ad0e36 to 5bee4a1 Compare November 20, 2025 00:07
@Chocapikk Chocapikk changed the title Add GHSA reference type support Add GHSA and OSV reference type support Nov 20, 2025
if(refs and not refs.empty?)
refs.each_index do |i|
if !(refs[i].respond_to?('[]') and refs[i].length == 2)
if !(refs[i].respond_to?('[]') and (refs[i].length == 2 || refs[i].length == 3))
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be possible to check if GHSA present then only check for three in that particular scenario?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in commit 990ed30. We added a ReferencesWithOptionalThirdElement constant to define which reference types can have 2 or 3 elements, and updated the validation logic to check if a reference type is in this list before allowing 3 elements. This makes the code extensible for future reference types that may need an optional third element.

The validation now only checks for 3 elements when the reference type is GHSA (or other types added to the constant), as shown in lines 81-83:

ref_type = refs[i][0]
can_have_third_element = ReferencesWithOptionalThirdElement.include?(ref_type)
valid_length = can_have_third_element ? (refs[i].length == 2 || refs[i].length == 3) : (refs[i].length == 2)

@Chocapikk Chocapikk force-pushed the add-ghsa-reference-support branch from 9f1642e to 990ed30 Compare November 27, 2025 20:03
@Chocapikk Chocapikk force-pushed the add-ghsa-reference-support branch from 990ed30 to f677696 Compare November 27, 2025 20:07
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.

2 participants