Fix db_import crash#21557
Merged
adfoster-r7 merged 1 commit intoJun 11, 2026
Merged
Conversation
adfoster-r7
force-pushed
the
add-additional-import-tests
branch
from
June 10, 2026 13:17
6d0ff9a to
d760213
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR expands coverage around Metasploit Framework ZIP imports and adjusts the ZIP extraction implementation used by Msf::DBManager to better handle (and test for) unsafe ZIP entry paths.
Changes:
- Adds shared RSpec examples that exercise
#import_msf_zipextraction behavior (including a zip-slip/path traversal scenario). - Updates
import_msf_zipZIP entry extraction logic in the importer implementation.
Impact Analysis:
- Blast radius: medium — affects
Msf::DBManagerZIP import path for Metasploit ZIP exports and any callers that rely on that importer. - Data and contract effects: no schema/DB contract changes; does change filesystem extraction behavior and traversal mitigation semantics.
- Rollback and test focus: focus on importing a normal MSF ZIP export (loot/tasks present) and malicious ZIPs with traversal/prefix-bypass entry names; rollback is straightforward (single-method change) but reintroduces traversal risk.
Reviewed changes
Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| spec/support/shared/examples/msf/db_manager/import/metasploit_framework/zip.rb | Adds new shared examples to validate ZIP extraction and traversal protections. |
| lib/msf/core/db_manager/import/metasploit_framework/zip.rb | Modifies how ZIP entries are extracted during MSF ZIP import. |
Comment on lines
+5
to
+8
| describe '#import_msf_zip' do | ||
| let(:zip_tmp_root) { Dir.mktmpdir('msf-zip-import-test') } | ||
|
|
||
| after { FileUtils.rm_rf(zip_tmp_root) } |
Comment on lines
+52
to
+70
| it 'extracts zip entries to the temporary directory' do | ||
| subject.import_msf_zip( | ||
| data: File.binread(zip_path), | ||
| workspace: subject.workspace | ||
| ) | ||
|
|
||
| extracted_tmp = subject.instance_variable_get(:@import_filedata)[:zip_tmp] | ||
| expect(extracted_tmp).not_to be_nil | ||
| expect(File.exist?(File.join(extracted_tmp, 'test_export.xml'))).to be true | ||
| expect(File.exist?(File.join(extracted_tmp, 'loot/file1.bin'))).to be true | ||
| expect(File.exist?(File.join(extracted_tmp, 'tasks/task1.log'))).to be true | ||
| expect(File.read(File.join(extracted_tmp, 'loot/file1.bin'))).to eq('loot content here') | ||
| end | ||
|
|
||
| it 'identifies the XML export file for subsequent import' do | ||
| subject.import_msf_zip( | ||
| data: File.binread(zip_path), | ||
| workspace: subject.workspace | ||
| ) |
adfoster-r7
force-pushed
the
add-additional-import-tests
branch
2 times, most recently
from
June 10, 2026 14:11
4397084 to
c4c0721
Compare
adfoster-r7
force-pushed
the
add-additional-import-tests
branch
3 times, most recently
from
June 10, 2026 15:35
236f4e8 to
997766c
Compare
adfoster-r7
force-pushed
the
add-additional-import-tests
branch
from
June 10, 2026 17:43
997766c to
40a6474
Compare
adfoster-r7
force-pushed
the
add-additional-import-tests
branch
from
June 10, 2026 21:17
40a6474 to
cf67b7f
Compare
cgranleese-r7
approved these changes
Jun 11, 2026
Contributor
Author
Release NotesFixes a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes a
db_importcrash when importing zip filesVerification
zip new_archive.zip test_export.xmldb_import new_archive.zipMaster:
This branch: