Skip to content

Commit d51949b

Browse files
authored
Merge pull request #79 from trailofbits/mschwager-marshal-load-rule
Add rule for blog post
2 parents 2a30493 + 202d8b8 commit d51949b

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

ruby/marshal-load-method.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
require 'marshal'
2+
3+
class Foo
4+
# ruleid: marshal-load-method
5+
def marshal_load(array)
6+
initialize array[0]
7+
end
8+
end
9+
10+
# ok: marshal-load-method
11+
class Bar
12+
end

ruby/marshal-load-method.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
rules:
2+
- id: marshal-load-method
3+
message: |
4+
Found `marshal_load` class method. This implies custom Marshal
5+
deserialization is occuring. This can lead to RCE and other
6+
deserialization-type bugs. Usage should be audited and, at least, fuzzed.
7+
languages: [ruby]
8+
severity: INFO
9+
metadata:
10+
category: security
11+
cwe: "CWE-502: Deserialization of Untrusted Data"
12+
subcategory: [audit]
13+
confidence: LOW
14+
likelihood: LOW
15+
impact: HIGH
16+
technology: [ruby]
17+
references:
18+
- https://github.blog/2024-06-20-execute-commands-by-sending-json-learn-how-unsafe-deserialization-vulnerabilities-work-in-ruby-projects/
19+
- https://github.com/GitHubSecurityLab/ruby-unsafe-deserialization/blob/main/marshal/3.4-rc/marshal-rce-ruby-3.4-rc.rb
20+
patterns:
21+
- pattern-inside: |
22+
class $CLS
23+
...
24+
end
25+
- pattern: |
26+
def marshal_load(...)
27+
...
28+
end

0 commit comments

Comments
 (0)