Fix analyze_db size bypass for dynamic payloads - #21743
Open
keyanskv wants to merge 1 commit into
Open
Conversation
Adds payload_cached_size to module metadata cache to allow is_payload_compatible? to correctly reject large payloads with dynamic sizes.
keyanskv
commented
Aug 3, 2026
keyanskv
left a comment
Author
There was a problem hiding this comment.
Hello Maintainers,
I have reviewed the proposed changes in this pull request and believe they are ready for GitHub Actions to run. Could a maintainer please review the changes and approve the pending workflow execution?
Thank you for your time and assistance.
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.
Adds payload_cached_size to module metadata cache to allow is_payload_compatible? to correctly reject large payloads with dynamic sizes.
Description
This change adds
payload_cached_sizeto the module metadata cache so thatis_payload_compatible?can make payload size decisions without loading the payload module.Previously, payloads with dynamic sizes could not always be evaluated correctly from cached metadata alone. As a result, oversized payloads could pass compatibility checks because the cached metadata did not include the information needed to determine their effective size.
With this change:
payload_cached_sizeis stored in the module metadata cache.is_payload_compatible?uses the cached size information when performing compatibility checks.Dynamic payloads with cached size metadata are correctly rejected when they exceed the exploit's available payload space.
Existing behavior for static payloads remains unchanged.
Related Issue: None
Breaking Changes
None.
Reviewer Notes
The primary implementation is the addition of
payload_cached_sizeto the module metadata cache and updating payload compatibility checks to consume the cached value.The accompanying RSpec tests verify:
Msf::Payload.cached_sizebehavior.Payload cached size metadata generation and validation.
Handling of static and dynamic payloads.
Cached size override generation for staged payloads.
Verification Steps
Build the project and install dependencies.
Apply this patch.
Run:
Expected result:
12 examples
0 failures
Run:
Expected result:
16 examples
0 failures
Verify that payload metadata now includes
payload_cached_size.Verify that
is_payload_compatible?correctly rejects payloads whose cached size exceeds the available payload space, including dynamically-sized payloads.Test Evidence
Test 1
Test 2
Environment
AI Usage Disclosure
ChatGPT was used to assist with drafting the pull request description and improving documentation. The implementation, testing, debugging, and validation of the code were completed by the contributor.
Pre-Submission Checklist
No sensitive information (credentials, API keys, IP addresses, or secrets) included
Tested on the target environment specified above
Included RSpec tests for library changes
Read the CONTRIBUTING.md and module acceptance guidelines
Included a corresponding documentation markdown file (Not applicable — library change only)