{"answers":{"affected":"2 open source packages ship an affected version, including camaleon_cms.","exploited":"There is no known exploitation of GHSA-7x4w-cj9r-h4v9 in the wild and no public exploit code.","fix":"Upgrade camaleon_cms to 2.8.1 or later.","what":"GHSA-7x4w-cj9r-h4v9 is a path traversal vulnerability in camaleon_cms, published on 18 Sep 2024. An attacker needs administrator access to exploit it, with no action from the victim."},"fix_prompt":"Check this codebase for GHSA-7x4w-cj9r-h4v9 and fix it if it is affected.\n\nWhat it is: GHSA-7x4w-cj9r-h4v9 is a path traversal vulnerability in camaleon_cms, published on 18 Sep 2024. An attacker needs administrator access to exploit it, with no action from the victim.\nExploitation: There is no known exploitation of GHSA-7x4w-cj9r-h4v9 in the wild and no public exploit code.\n\nAffected packages and fixed versions:\n- camaleon_cms (RubyGems): affected all versions; fixed in 2.8.1\n- camaleon_cms (RubyGems): affected all versions; fixed in 2.8.1\n\nTask:\n1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.\n2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.\n3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.\n4. Run the tests and summarise what changed and why.\n5. If nothing in the project is affected, say so and change nothing.\n\nReference: https://insights.sbomify.com/GHSA-7x4w-cj9r-h4v9/ (Markdown: https://insights.sbomify.com/GHSA-7x4w-cj9r-h4v9/index.md)","id":"GHSA-7x4w-cj9r-h4v9","markdown":"https://insights.sbomify.com/GHSA-7x4w-cj9r-h4v9/index.md","name":"GHSA-7x4w-cj9r-h4v9","record":{"aliases":[],"analysis":{"component_type":"web_application","fix_type":"patch","impacts":["data_modify","denial_of_service"],"network_reachable":"yes","non_default_config":false,"product_category":"Camaleon CMS","requires_auth":"high_privilege","summary":"An authenticated administrator can delete arbitrary files on the server via path traversal in the media controller, potentially causing denial of service or data loss.","user_interaction":"not_required","vuln_class":"path_traversal"},"analysis_generated_by":"qwen3.8-flash-next","assigner":null,"cpe":[],"cvss":{"score":null,"severity":null,"source":null,"vector":null,"version":null},"cwes":[],"description":"The [actions](https://github.com/owen2345/camaleon-cms/blob/feccb96e542319ed608acd3a16fa5d92f13ede67/app/controllers/camaleon_cms/admin/media_controller.rb#L51-L52) defined inside of the MediaController class do not check whether a given path is inside a certain path (e.g. inside the media folder). If an attacker performed an account takeover of an administrator account (See: GHSL-2024-184) they could delete arbitrary files or folders on the server hosting Camaleon CMS. The [crop_url](https://github.com/owen2345/camaleon-cms/blob/feccb96e542319ed608acd3a16fa5d92f13ede67/app/controllers/camaleon_cms/admin/media_controller.rb#L64-L65) action might make arbitrary file writes (similar impact to GHSL-2024-182) for any authenticated user possible, but it doesn't seem to work currently.\n\nArbitrary file deletion can be exploited with following code path: The parameter folder flows from the actions method:\n```ruby\n  def actions\n    authorize! :manage, :media if params[:media_action] != 'crop_url'\n    params[:folder] = params[:folder].gsub('//', '/') if params[:folder].present?\n    case params[:media_action]\n    [..]\n    when 'del_file'\n      cama_uploader.delete_file(params[:folder].gsub('//', '/'))\n      render plain: ''\n```\ninto the method delete_file of the CamaleonCmsLocalUploader class (when files are uploaded locally):\n```ruby\ndef delete_file(key)\n  file = File.join(@root_folder, key)\n  FileUtils.rm(file) if File.exist? file\n  @instance.hooks_run('after_delete', key)\n  get_media_collection.find_by_key(key).take.destroy\nend\n```\nWhere it is joined in an unchecked manner with the root folder and then deleted.\n\n**Proof of concept**\nThe following request would delete the file README.md in the top folder of the Ruby on Rails application. (The values for auth_token, X-CSRF-Token and _cms_session would also need to be replaced with authenticated values in the curl command below)\n```\ncurl --path-as-is -i -s -k -X $'POST' \\\n    -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' \\\n    -b $'auth_token=[..]; _cms_session=[..]' \\\n    --data-binary $'versions=\u0026thumb_size=\u0026formats=\u0026media_formats=\u0026dimension=\u0026private=\u0026folder=..%2F..%2F..%2FREADME.md\u0026media_action=del_file' \\\n    $'https://\u003ccamaleon-host\u003e/admin/media/actions?actions=true'\n```\n**Impact**\nThis issue may lead to a defective CMS or system.\n\n**Remediation**\nNormalize all file paths constructed from untrusted user input before using them and check that the resulting path is inside the targeted directory. Additionally, do not allow character sequences such as .. in untrusted input that is used to build paths.\n\n**See also:**\n\n[CodeQL: Uncontrolled data used in path expression](https://codeql.github.com/codeql-query-help/ruby/rb-path-injection/)\n[OWASP: Path Traversal](https://owasp.org/www-community/attacks/Path_Traversal)","ecosystems":["RubyGems"],"exploits":{"exploitdb":null,"first_seen":null,"github_poc":null,"max_poc_stars":null,"metasploit":null,"nuclei":null,"refs":[],"tier":null},"has_fix":true,"headline":"Camaleon CMS vulnerable to remote code execution through code injection (GHSL-2024-185)","id":"GHSA-7x4w-cj9r-h4v9","indexable":true,"kev":null,"kind":"advisory","links":{"ecosystem":"RubyGems","product":null,"products":[],"type":"path_traversal","year":"2024"},"n_packages":2,"n_references":null,"packages":[{"ecosystem":"RubyGems","fixed":["2.8.1"],"introduced":["0"],"last_affected":[],"package":"camaleon_cms","purl":null,"source":"GHSA-7x4w-cj9r-h4v9"},{"ecosystem":"RubyGems","fixed":["2.8.1"],"introduced":["0"],"last_affected":[],"package":"camaleon_cms","purl":"pkg:gem/camaleon_cms","source":"GHSA-7x4w-cj9r-h4v9"}],"products":null,"published":"2024-09-18","related":[],"sources":[{"class":"attribution","licence":"CC BY 4.0","name":"GitHub Advisory Database","prefix":"GHSA"}],"ssvc":{"automatable":null,"exploitation":null,"technical_impact":null},"state":null,"updated":null,"vendors":null},"summary":"An authenticated administrator can delete arbitrary files on the server via path traversal in the media controller, potentially causing denial of service or data loss.","url":"https://insights.sbomify.com/GHSA-7x4w-cj9r-h4v9/"}