Skip to content

Preserve Android configuration bytes in DEX - #2

Closed
pauljccode wants to merge 2 commits into
masterfrom
fix/android-config-bytes
Closed

pauljccode wants to merge 2 commits into
masterfrom
fix/android-config-bytes

Conversation

@pauljccode

@pauljccode pauljccode commented Oct 3, 2026 •

Copy link
Copy Markdown
Owner

Description

Android payload generation passes binary configuration to gsub! as a replacement string. Bytes such as \k< can raise invalid group name reference format; \1 and \& can silently alter the DEX.

Use the block form to insert bytes literally. Eight regression cases cover staged and stageless generation, checking configuration, surrounding data, length, SHA-1 signature and Adler-32 checksum.

Related: rapid7#10636. The exception also interrupted this Verify job.

Breaking Changes

None.

Verification Steps

  1. Run bundle exec rspec spec/lib/msf/core/payload/android_spec.rb; expect eight examples and no failures.
  2. Restore the replacement-string call while retaining the spec. Expect six failures: two exceptions and four DEX size mismatches. The two ordinary-binary cases should pass.
  3. Restore the correction and run Verify.

Test Evidence

Local isolated tests reproduce all six failures and pass with the correction. They use real DEX assets and archive generation, with controlled configuration input and stubbed JAR signing; no Android device was tested. The new spec is RuboCop-clean, with no new library offenses.

Verify at this branch's head passed all 14 jobs without failures or retries, including the new examples across Ruby 3.2–3.4.

Separate Meterpreter failures are addressed by rapid7/mettle#298, rapid7/mettle#299 and rapid7/metasploit-payloads#818. Combined acceptance passed all 23 applicable jobs, with one optional-build skip; it includes those additional corrections.

Environment

Field Details
Operating System macOS 27, Apple Silicon with packaged Intel Ruby through Rosetta; Ubuntu in CI
Software Local Ruby 3.4.4 and RSpec 3.13; CI Ruby 3.2–3.4

AI Usage Disclosure

Codex assisted with investigation, implementation, tests and this description.

Pre-Submission Checklist

  • No sensitive information included.
  • Tested in the environments above, with validation limits stated.
  • Included library regression tests.
  • Read CONTRIBUTING.md, AGENTS.md and the acceptance guidelines.
  • Module-only documentation and checks do not apply.

Upstream: rapid7/metasploit-framework#21968.

Use the block form of gsub! so binary configuration bytes are inserted
literally instead of being parsed as replacement backreferences.

Cover staged and stageless generation with ordinary bytes, malformed
named references, numbered references and whole-match references. Check
the generated DEX data, length, signature and checksum.

See rapid7#10636.
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown

Thanks for your pull request! As part of our landing process, we manually verify that all modules work as expected.

We've added the additional-testing-required label to indicate that additional testing is required before this pull request can be merged.
For maintainers, this means visiting here.

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.

1 participant