|
| 1 | +--- |
| 2 | +gem: camaleon_cms |
| 3 | +cve: 2024-46987 |
| 4 | +ghsa: cp65-5m9r-vc2c |
| 5 | +url: https://github.com/owen2345/camaleon-cms/security/advisories/GHSA-cp65-5m9r-vc2c |
| 6 | +title: Camaleon CMS vulnerable to arbitrary path traversal (GHSL-2024-183) |
| 7 | +date: 2024-09-18 |
| 8 | +description: | |
| 9 | + A path traversal vulnerability accessible via MediaController's |
| 10 | + download_private_file method allows authenticated users to download |
| 11 | + any file on the web server Camaleon CMS is running on (depending |
| 12 | + on the file permissions). |
| 13 | +
|
| 14 | + In the [download_private_file] method: |
| 15 | +
|
| 16 | + ```ruby |
| 17 | + def download_private_file |
| 18 | + cama_uploader.enable_private_mode! |
| 19 | +
|
| 20 | + file = cama_uploader.fetch_file("private/#{params[:file]}") |
| 21 | +
|
| 22 | + send_file file, disposition: 'inline' |
| 23 | + end |
| 24 | + ``` |
| 25 | +
|
| 26 | + [download_private_file]: https://github.com/owen2345/camaleon-cms/blob/feccb96e542319ed608acd3a16fa5d92f13ede67/app/controllers/camaleon_cms/admin/media_controller.rb#L28 |
| 27 | +
|
| 28 | + The file parameter is passed to the [fetch_file] method of the |
| 29 | + CamaleonCmsLocalUploader class (when files are uploaded locally): |
| 30 | +
|
| 31 | + ```ruby |
| 32 | + def fetch_file(file_name) |
| 33 | + raise ActionController::RoutingError, 'File not found' unless file_exists?(file_name) |
| 34 | +
|
| 35 | + file_name |
| 36 | + end |
| 37 | + ``` |
| 38 | +
|
| 39 | + [fetch_file]: https://github.com/owen2345/camaleon-cms/blob/feccb96e542319ed608acd3a16fa5d92f13ede67/app/uploaders/camaleon_cms_local_uploader.rb#L27 |
| 40 | +
|
| 41 | + If the file exists it's passed back to the download_private_file method |
| 42 | + where the file is sent to the user via [send_file]. |
| 43 | +
|
| 44 | + [send_file]: https://github.com/owen2345/camaleon-cms/blob/feccb96e542319ed608acd3a16fa5d92f13ede67/app/controllers/camaleon_cms/admin/media_controller.rb#L33-L34 |
| 45 | +
|
| 46 | + ## Proof of concept |
| 47 | +
|
| 48 | + An authenticated user can download the /etc/passwd file by visiting an URL such as: |
| 49 | +
|
| 50 | + https://<camaleon-host>/admin/media/download_private_file?file=../../../../../../etc/passwd |
| 51 | +
|
| 52 | + ## Impact |
| 53 | +
|
| 54 | + This issue may lead to Information Disclosure. |
| 55 | +
|
| 56 | + ## Remediation |
| 57 | +
|
| 58 | + Normalize file paths constructed from untrusted user input before using |
| 59 | + them and check that the resulting path is inside the targeted directory. |
| 60 | + Additionally, do not allow character sequences such as `..` in untrusted |
| 61 | + input that is used to build paths. |
| 62 | +
|
| 63 | + ## See Also |
| 64 | +
|
| 65 | + * [CodeQL: Uncontrolled data used in path expression](https://codeql.github.com/codeql-query-help/ruby/rb-path-injection/) |
| 66 | + * [OWASP: Path Traversal](https://owasp.org/www-community/attacks/Path_Traversal) |
| 67 | +cvss_v3: 7.7 |
| 68 | +patched_versions: |
| 69 | + - ">= 2.8.1" |
| 70 | +related: |
| 71 | + url: |
| 72 | + - https://nvd.nist.gov/vuln/detail/CVE-2024-46987 |
| 73 | + - https://github.com/owen2345/camaleon-cms/security/advisories/GHSA-cp65-5m9r-vc2c |
| 74 | + - https://github.com/owen2345/camaleon-cms/commit/071b1b09d6d61ab02a5960b1ccafd9d9c2155a3e |
| 75 | + - https://codeql.github.com/codeql-query-help/ruby/rb-path-injection |
| 76 | + - https://owasp.org/www-community/attacks/Path_Traversal |
| 77 | + - https://www.reddit.com/r/rails/comments/1exwtdm/camaleon_cms_281_has_been_released |
| 78 | + - https://github.com/advisories/GHSA-cp65-5m9r-vc2c |
0 commit comments