Implement immediate payload option validation on set calls#21609
Open
dwelch-r7 wants to merge 1 commit into
Open
Implement immediate payload option validation on set calls#21609dwelch-r7 wants to merge 1 commit into
dwelch-r7 wants to merge 1 commit into
Conversation
|
Additional test pipeline started ⌛ |
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.
Description
Payload option validation (LHOST, LPORT, etc.) was timing-dependent — it only fired on
setcalls aftershow optionshad been run, becauseshow optionstriggersshare_datastorewhich imports the payload's typed option definitions into the exploit module's datastore as a side effect. Before that call,DataStore#[]=skipped validation entirely since no option metadata was registered for payload keys.This change eagerly imports payload option definitions when:
set PAYLOAD <name>on an exploit/evasion moduleuseand a default payload is selected bychoose_payloadAfter this fix,
set LPORT not_a_portimmediately reports a validation error regardless of whethershow optionshas been called.A shared
import_payload_optionshelper is added toCommandDispatcher::Commonto avoid duplicating the logic betweencmd_set(core.rb) andcmd_use(modules.rb).Related Issue: Related to #21552 (LHOST validation behavior)
Verification Steps
msfconsoleuse exploit/multi/handlerset PAYLOAD windows/meterpreter/reverse_tcpset LPORT not_a_port— should immediately report validation errorset LHOST 192.0.2.1— should succeeduse exploit/windows/smb/psexecset PAYLOAD windows/meterpreter/reverse_tcpset LPORT abc— should immediately report validation error (previously this would silently succeed untilshow optionswas called first)Test Evidence
Before
After
Environment
AI Usage Disclosure
Kiro
Pre-Submission Checklist
rubocopon new files with no new offensesRan(not applicable — no module files changed)msftidyon changed module files with no new offensesIncluded a corresponding documentation markdown file(not applicable)