Skip to content

Commit 951c00b

Browse files
jasnowpostmodern
andauthored
GHSA SYNC: 2 brand new advisories (#817)
--------- Co-authored-by: Postmodern <[email protected]>
1 parent ebac396 commit 951c00b

File tree

2 files changed

+133
-0
lines changed

2 files changed

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

0 commit comments

Comments
 (0)