|
| 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 |
| 13 | + [documents](https://github.com/owen2345/camaleon-cms/blob/feccb96e542319ed608acd3a16fa5d92f13ede67/app/uploaders/camaleon_cms_uploader.rb#L105-L106) |
| 14 | + or a string of an |
| 15 | + [unsupported format](https://github.com/owen2345/camaleon-cms/blob/feccb96e542319ed608acd3a16fa5d92f13ede67/app/uploaders/camaleon_cms_uploader.rb#L110-L111). |
| 16 | + If an authenticated user or administrator visits that uploaded |
| 17 | + image or document malicious JavaScript can be executed on their |
| 18 | + behalf (e.g. changing or deleting content inside of the CMS.) |
| 19 | +
|
| 20 | + ** Proof of concept ** |
| 21 | +
|
| 22 | + Login as a normal user (if user signup is enabled). |
| 23 | + Go to the user's profile. |
| 24 | + And upload the following profile picture via drag and drop. |
| 25 | + The content of the SVG file could be as follows (e.g. name it test-xss.svg): |
| 26 | +
|
| 27 | + <?xml version="1.0" encoding="UTF-8" standalone="no"?> |
| 28 | + <svg |
| 29 | + xmlns:dc="http://purl.org/dc/elements/1.1/" |
| 30 | + xmlns:cc="http://creativecommons.org/ns#" |
| 31 | + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
| 32 | + xmlns:svg="http://www.w3.org/2000/svg" |
| 33 | + xmlns="http://www.w3.org/2000/svg" |
| 34 | + width="500" |
| 35 | + height="500" |
| 36 | + viewBox="0 0 198.4375 52.916666" |
| 37 | + version="1.1"> |
| 38 | + <g |
| 39 | + transform="translate(-9.8676114,4.8833333)"> |
| 40 | + <path |
| 41 | + d="m 107.79557,-10.430538 -7.33315,-0.02213 -3.647402,-6.361755 3.685742,-6.339624 7.33314,0.02213 3.64741,6.361756 z" |
| 42 | + style="fill:#131f6b;fill-opacity:1;stroke-width:0.05937638" |
| 43 | + transform="scale(1,-1)" /> |
| 44 | + <!-- The below lines were added in a text editor to the image XML. This is the stored XSS attack. --> |
| 45 | + <script type="text/javascript"> |
| 46 | + alert("This is an example of a stored XSS attack in an SVG image, here's the cookie: " + document.cookie); |
| 47 | + </script> |
| 48 | + </g> |
| 49 | + </svg> |
| 50 | +
|
| 51 | + The server might fail with a 500 internal server error, but the |
| 52 | + uploaded image should be available at a location like |
| 53 | + https://<camaleon-host>/media/1/test-xss-cookie.svg. If an |
| 54 | + authenticated user or administrator accesses that link their |
| 55 | + auth_token is reflected. Since the auth_token cookie contains a |
| 56 | + static [auth token](https://github.com/owen2345/camaleon-cms/blob/feccb96e542319ed608acd3a16fa5d92f13ede67/app/models/concerns/camaleon_cms/user_methods.rb#L18-L19) |
| 57 | + value that only changes when a user changes their password. |
| 58 | +
|
| 59 | + **Impact** |
| 60 | +
|
| 61 | + This issue may lead to account takeover due to reflected |
| 62 | + Cross-site scripting (XSS). |
| 63 | +
|
| 64 | + **Remediation** |
| 65 | +
|
| 66 | + Only allow the upload of safe files such as PNG, TXT and others |
| 67 | + or serve all "unsafe" files such as SVG and other files with a |
| 68 | + content-disposition: attachment header, which should prevent |
| 69 | + browsers from displaying them. |
| 70 | +
|
| 71 | + Additionally, a [Content security policy (CSP)](https://web.dev/articles/csp) |
| 72 | + can be created that disallows inlined script. (Other parts of the |
| 73 | + application might need modification to continue functioning.) |
| 74 | +
|
| 75 | + To prevent the theft of the auth_token it could be marked with |
| 76 | + HttpOnly. This would however not prevent that actions could be |
| 77 | + performed as the authenticated user/administrator. Furthermore, |
| 78 | + it could make sense to use the authentication provided by |
| 79 | + Ruby on Rails, so that stolen tokens cannot be used anymore |
| 80 | + after some time. |
| 81 | +cvss_v3: 5.4 |
| 82 | +patched_versions: |
| 83 | + - ">= 2.8.1" |
| 84 | +related: |
| 85 | + url: |
| 86 | + - https://github.com/owen2345/camaleon-cms/security/advisories/GHSA-r9cr-qmfw-pmrc |
| 87 | + - https://github.com/owen2345/camaleon-cms/commit/b18fbc74f3ecd98a1f781d015f5466ef16b1425b |
| 88 | + - https://github.com/advisories/GHSA-r9cr-qmfw-pmrc |
0 commit comments