@@ -9,74 +9,38 @@ description: |
99 functionality that can be used by normal registered users:
1010 It is possible to upload a SVG image containing JavaScript and
1111 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.)
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.)
1917
20- ** Proof of concept **
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
2120
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**
21+ ## Impact
6022
6123 This issue may lead to account takeover due to reflected
6224 Cross-site scripting (XSS).
6325
64- ** Remediation**
26+ ## Remediation
6527
6628 Only allow the upload of safe files such as PNG, TXT and others
6729 or serve all "unsafe" files such as SVG and other files with a
6830 content-disposition: attachment header, which should prevent
6931 browsers from displaying them.
7032
71- Additionally, a [Content security policy (CSP)](https://web.dev/articles/csp)
33+ Additionally, a [Content security policy (CSP)][3]
7234 can be created that disallows inlined script. (Other parts of the
7335 application might need modification to continue functioning.)
7436
37+ [3]: https://web.dev/articles/csp
38+
7539 To prevent the theft of the auth_token it could be marked with
7640 HttpOnly. This would however not prevent that actions could be
7741 performed as the authenticated user/administrator. Furthermore,
7842 it could make sense to use the authentication provided by
79- Ruby on Rails, so that stolen tokens cannot be used anymore
43+ Ruby on Rails, so that stolen tokens cannot be used anymore
8044 after some time.
8145cvss_v3 : 5.4
8246patched_versions :
0 commit comments