Skip to content

Commit 256ad33

Browse files
authored
Merge pull request #20353 from cgranleese-r7/add-validation-for-arch-values
Add validation for arch values
2 parents bbcac72 + 00c88ca commit 256ad33

File tree

6 files changed

+29
-5
lines changed

6 files changed

+29
-5
lines changed

modules/exploits/linux/http/suitecrm_log_file_rce.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def initialize(info = {})
3737
['URL', 'http://web.archive.org/web/20211209044023/https://theyhack.me/SuiteCRM-RCE-2/'] # This exploit
3838
],
3939
'Platform' => %w[linux unix],
40-
'Arch' => %w[ARCH_X64 ARCH_CMD ARCH_X86],
40+
'Arch' => [ARCH_X64, ARCH_CMD, ARCH_X86],
4141
'Targets' => [
4242
[
4343
'Linux (x64)', {

modules/exploits/multi/http/spip_bigup_unauth_rce.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def initialize(info = {})
4141
['URL', 'https://blog.spip.net/Mise-a-jour-critique-de-securite-sortie-de-SPIP-4-3-2-SPIP-4-2-16-SPIP-4-1-18.html']
4242
],
4343
'Platform' => %w[php unix linux win],
44-
'Arch' => %w[ARCH_PHP ARCH_CMD],
44+
'Arch' => [ARCH_PHP, ARCH_CMD],
4545
'Targets' => [
4646
[
4747
'PHP In-Memory', {

modules/exploits/unix/webapp/byob_unauth_rce.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def initialize(info = {})
3535
['URL', 'https://blog.chebuya.com/posts/unauthenticated-remote-command-execution-on-byob/']
3636
],
3737
'Platform' => %w[unix linux],
38-
'Arch' => %w[ARCH_CMD],
38+
'Arch' => [ARCH_CMD],
3939
'Targets' => [
4040
[
4141
'Unix/Linux Command Shell', {

modules/exploits/unix/webapp/vicidial_agent_authenticated_rce.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def initialize(info = {})
3232
],
3333
'DisclosureDate' => '2024-09-10',
3434
'Platform' => %w[unix linux],
35-
'Arch' => %w[ARCH_CMD],
35+
'Arch' => [ARCH_CMD],
3636
'Targets' => [
3737
[
3838
'Unix/Linux Command Shell', {

spec/module_validation_spec.rb

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
file_path: 'modules/exploits/windows/smb/cve_2020_0796_smbghost.rb',
2626
type: 'exploit',
2727
platform: Msf::Module::PlatformList.new(Msf::Module::Platform::Windows),
28+
arch: [Rex::Arch::ARCH_X86],
2829
targets: [Msf::Module::Target.new('Windows 10 v1903-1909 x64', { 'Platform' => 'win', 'Arch' => ['x64'] })],
2930
description: %q{
3031
A vulnerability exists within the Microsoft Server Message Block 3.1.1 (SMBv3) protocol that can be leveraged to
@@ -234,6 +235,22 @@
234235
end
235236
end
236237

238+
context 'when the arch array contains a valid value' do
239+
it 'has no errors' do
240+
expect(subject.errors.full_messages).to be_empty
241+
end
242+
end
243+
244+
context 'when the arch array contains an invalid value' do
245+
let(:mod_options) do
246+
super().merge(arch: ["Rex::Arch::ARCH_X86"])
247+
end
248+
249+
it 'has errors' do
250+
expect(subject.errors.full_messages).to eq ["Arch contains invalid values [\"Rex::Arch::ARCH_X86\"] - only [\"x86\", \"x86_64\", \"x64\", \"mips\", \"mipsle\", \"mipsbe\", \"mips64\", \"mips64le\", \"ppc\", \"ppce500v2\", \"ppc64\", \"ppc64le\", \"cbea\", \"cbea64\", \"sparc\", \"sparc64\", \"armle\", \"armbe\", \"aarch64\", \"cmd\", \"php\", \"tty\", \"java\", \"ruby\", \"dalvik\", \"python\", \"nodejs\", \"firefox\", \"zarch\", \"r\", \"riscv32be\", \"riscv32le\", \"riscv64be\", \"riscv64le\", \"loongarch64\"] is allowed"]
251+
end
252+
end
253+
237254
context 'when the platform is missing and targets does not contain platform values' do
238255
let(:mod_options) do
239256
super().merge(platform: nil, targets: [Msf::Module::Target.new('Windows 10 v1903-1909 x64', { 'Arch' => ['x64'] })])
@@ -279,7 +296,7 @@
279296
super().merge(new_module_options, rank: Msf::GreatRanking, rank_to_s: 'great')
280297
end
281298

282-
it 'has no errors' do
299+
it 'has errors' do
283300
expect(subject.errors.full_messages).to eq [
284301
"Stability contains invalid values [[\"unknown-stability\"]] - only [\"crash-safe\", \"crash-service-restarts\", \"crash-service-down\", \"crash-os-restarts\", \"crash-os-down\", \"service-resource-loss\", \"os-resource-loss\"] is allowed",
285302
"Side effects contains invalid values [[\"unknown-side-effects\"]] - only [\"artifacts-on-disk\", \"config-changes\", \"ioc-in-logs\", \"account-lockouts\", \"account-logout\", \"screen-effects\", \"audio-effects\", \"physical-effects\"] is allowed",

spec/support/lib/module_validation.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ def validate_each(record, attribute, value)
99
return
1010
end
1111

12+
# Special cases for modules/exploits/bsd/finger/morris_fingerd_bof.rb which has a one-off architecture defined in
13+
# the module itself, and that value is not included in the valid list of architectures.
14+
# https://github.com/rapid7/metasploit-framework/blob/389d84cbf0d7c58727846466d9a9f6a468f32c61/modules/exploits/bsd/finger/morris_fingerd_bof.rb#L11
15+
return if attribute == :arch && value == ["vax"] && record.fullname == "exploit/bsd/finger/morris_fingerd_bof"
1216
return if value == options[:sentinel_value]
1317

1418
invalid_options = value - options[:in]
@@ -187,6 +191,9 @@ def validate_name_does_not_contain_non_printable_chars
187191
'module_validation/array_inclusion': { in: VALID_RELIABILITY_VALUES, sentinel_value: Msf::UNKNOWN_RELIABILITY }
188192
end
189193

194+
validates :arch,
195+
'module_validation/array_inclusion': { in: Rex::Arch::ARCH_TYPES }
196+
190197
validates :license,
191198
presence: true,
192199
inclusion: { in: LICENSES, message: 'must include a valid license' }

0 commit comments

Comments
 (0)