Fix undefined variable in Host.normalize_host causing session failures when DB is connected#20772
Merged
smcintyre-r7 merged 1 commit intorapid7:masterfrom Jan 15, 2026
Merged
Conversation
smcintyre-r7
approved these changes
Jan 15, 2026
Contributor
smcintyre-r7
left a comment
There was a problem hiding this comment.
Thanks a lot for this fix and the detailed description of it. I gave it a test and confirmed that the session is working when the database is connected now.
Contributor
Release NotesThis fixes an issue that would prevent sessions from being opened due to a bug in the logic that logs the session's network information to the database. |
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.
Bug Fix: shell_bind_aws_ssm Session Fails with Database Connected
Issue Summary
The
payload/generic/shell_bind_aws_ssmmodule failed to establish a session when a database was connected to Metasploit Framework, while working correctly without a database connection.Steps to Reproduce
ACCESS_KEY_ID,EC2_ID,REGIONandSECRET_ACCESS_KEYdatastore optionsRoot Cause Analysis
The bug was located in
lib/msf/util/host.rbat line 46.The Bug
The variable
sessiondoes not exist in this method scope - it should behost.Why Database Connection Triggered the Bug
The execution flow when a database is connected:
on_session_openevent fireslib/msf/core/framework.rbhandles the event:report_sessioncallscreate_mdm_session_from_sessionwhich calls:session_hostreturnsnilbecause host info is stored inpeer_infohash, not in standard session attributessock.peerhostfallback at lines 40-46sessionvariable →NameErrorexceptionWithout a database,
framework.db.report_sessionis never called, so the buggy code path is never executed.The Fix
File:
lib/msf/util/host.rbLine: 46
Before
After
Files Modified
lib/msf/util/host.rb- Fixed typo on line 46Impact
This fix resolves session establishment issues for any session type where:
session_hostmethod returnsnilsockattribute with validpeerhostinformationThis primarily affects:
payload/generic/shell_bind_aws_ssmTesting Recommendations
payload/generic/shell_bind_aws_ssmagainst an SSM targetDate
December 12, 2025
Fixes: #20675