CVE-2022-39369: Apereo/phpcas PhpCAS Vulnerable To Service Hostname Vulnerability

HIGH
Advisory Identifier: GHSA-8q72-6qq8-xv64
CVSS 8.0
CWE-1287
Published
Advisory Summary

CVE-2022-39369 is a HIGH (CVSS 8.0) phpcas vulnerable to service hostname vulnerability (CWE-1287: Improper Validation of Specified Type of Input) affecting Apereo/phpcas libraries in the Packagist ecosystem. The issue involves phpcas vulnerable to service hostname discovery exploitation. Remediation is available by upgrading affected packages to version 1.6.0.

CVE-2022-39369 at a Glance

CVE Identifier CVE-2022-39369
GHSA Identifier GHSA-8q72-6qq8-xv64
Severity HIGH
CVSS v3.1 Base Score 8.0
CWE Classification CWE-1287: Improper Validation of Specified Type of Input
Affected Product Apereo/phpcas
Package Ecosystem Packagist
Published Date
Last Updated

Security Impact

CVSS: 8.0

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2022-39369

To remediate this vulnerability, upgrade all affected Apereo/phpcas dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

apereo/phpcas fixed: 1.6.0
Upgrade apereo/phpcas to 1.6.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for apereo/phpcas

How to Check if You Are Affected

To determine whether your application is affected by CVE-2022-39369, inspect your project dependencies for Apereo/phpcas:

inspect dependencies for apereo/phpcas

Analyze the terminal output to locate any version of Apereo/phpcas in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.6.0), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-1287: Improper Validation of Specified Type of Input, where the product receives input that is expected to be of a certain type, but it does not validate or incorrectly validates that the input is actually of the expected type. In Apereo/phpcas, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Impact The phpCAS library uses HTTP headers to determine the service URL used to validate tickets. This allows an attacker to control the host header and use a valid ticket granted for any authorized service in the same SSO realm (CAS server) to authenticate to the service protected by phpCAS. Depending on the settings of the CAS server service registry in worst case this may be any other service URL (if the allowed URLs are configured to "^(https)://.*") or may be strictly limited to known and authorized services in the same SSO federation if proper URL service validation is applied. This vulnerability may allow an attacker to gain access to a victim's account on a vulnerable CASified service without victim's knowledge, when the victim visits attacker's website while being logged in to the same CAS server. ### Patch phpCAS 1.6.0 is a major version upgrade that starts enforcing service URL discovery validation, because there is unfortunately no 100% safe default config to use in PHP. Starting this version, it is required to pass in an additional service base URL argument when constructing the client class. For more information, please refer to the upgrading doc. ### Workarounds This vulnerability only impacts the CAS client that the phpCAS library protects against. The problematic service URL discovery behavior in phpCAS < 1.6.0 will only be disabled, and thus you are not impacted from it, if the phpCAS configuration has the following setup: 1. `phpCAS::setUrl()` is called (a reminder that you have to pass in the full URL of the current page, rather than your service base URL), and 2. `phpCAS::setCallbackURL()` is called, only when the proxy mode is enabled. 3. Alternatively, if your PHP's HTTP header input `X-Forwarded-Host`, `X-Forwarded-Server`, `Host`, `X-Forwarded-Proto`, `X-Forwarded-Protocol` is sanitized before reaching PHP (by a reverse proxy, for example), you will not be impacted by this vulnerability. Otherwise, you should upgrade the library to get the safe service discovery behavior. If your CAS server service registry is configured to only allow known and trusted service URLs, the severity of the vulnerability is reduced substantially since an attacker must be in control of another authorized service. ### Acknowledgement We would like to thank Filip Hejsek for discovering this vulnerability, responsibly reporting it to the developers, and helping harden the patch. Henry Pan and Joachim Fritschi helped with the patch and release effort as phpCAS developers.

CVE-2022-39369 Affected Apereo/phpcas Versions

1 component(s)
Fixed Versions:
1.6.0
Product / Package Ecosystem Affected Versions Fixed Version
apereo/phpcas
Packagist
< 1.6.0
1.6.0

References

Frequently Asked Questions

What is CVE-2022-39369?
CVE-2022-39369 is a security vulnerability in Apereo/phpcas involving phpCAS vulnerable to Service Hostname Discovery Exploitation under CWE-1287: Improper Validation of Specified Type of Input.
Which Apereo/phpcas versions are affected?
Affected versions include releases prior to 1.6.0 across affected packages: apereo/phpcas.
What version fixes CVE-2022-39369?
Upgrading to 1.6.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is apereo/phpcas affected?
Yes, apereo/phpcas is affected in releases prior to 1.6.0. Upgrade your dependency to 1.6.0 or later.
What is the CVSS score of CVE-2022-39369?
CVE-2022-39369 has a CVSS v3.1 base score of 8.0 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2022-39369?
CVE-2022-39369 is classified under CWE-1287: Improper Validation of Specified Type of Input (The product receives input that is expected to be of a certain type, but it does not validate or incorrectly validates that the input is actually of the expected type.).
How can I check Packagist dependencies for CVE-2022-39369?
Run the dependency tree command: 'inspect dependencies for apereo/phpcas'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-8q72-6qq8-xv64",
  "modified" : "2022-11-01T18:11:07Z",
  "published" : "2022-11-01T18:11:07Z",
  "aliases" : [ "CVE-2022-39369" ],
  "summary" : "phpCAS vulnerable to Service Hostname Discovery Exploitation",
  "details" : "### Impact\n\nThe phpCAS library uses HTTP headers to determine the service URL used to validate tickets. This allows an attacker to control the host header and use a valid ticket granted for any authorized service in the same SSO realm (CAS server) to authenticate to the service protected by phpCAS. \nDepending on the settings of the CAS server service registry in worst case this may be any other service URL (if the allowed URLs are configured to \"^(https)://.*\") or may be strictly limited to known and authorized services in the same SSO federation if proper URL service validation is applied.\n\nThis vulnerability may allow an attacker to gain access to a victim's account on a vulnerable CASified service without victim's knowledge, when the victim visits attacker's website while being logged in to the same CAS server. \n\n### Patch\n\nphpCAS 1.6.0 is a major version upgrade that starts enforcing service URL discovery validation, because there is unfortunately no 100% safe default config to use in PHP. Starting this version, it is required to pass in an additional service base URL argument when constructing the client class.\n\nFor more information, please refer to the upgrading doc.\n\n### Workarounds\n\nThis vulnerability only impacts the CAS client that the phpCAS library protects against. The problematic service URL discovery behavior in phpCAS < 1.6.0 will only be disabled, and thus you are not impacted from it, if the phpCAS configuration has the following setup:\n\n1. `phpCAS::setUrl()` is called (a reminder that you have to pass in the full URL of the current page, rather than your service base URL), and\n2. `phpCAS::setCallbackURL()` is called, only when the proxy mode is enabled.\n3. Alternatively, if your PHP's HTTP header input `X-Forwarded-Host`, `X-Forwarded-Server`, `Host`, `X-Forwarded-Proto`, `X-Forwarded-Protocol` is sanitized before reaching PHP (by a reverse proxy, for example), you will not be impacted by this vulnerability.\n\nOtherwise, you should upgrade the library to get the safe service discovery behavior.\n\nIf your CAS server service registry is configured to only allow known and trusted service URLs, the severity of the vulnerability is reduced substantially since an attacker must be in control of another authorized service.\n\n### Acknowledgement\n\nWe would like to thank Filip Hejsek for discovering this vulnerability, responsibly reporting it to the developers, and helping harden the patch.\n\nHenry Pan and Joachim Fritschi helped with the patch and release effort as phpCAS developers.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "apereo/phpcas"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.6.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/apereo/phpCAS/security/advisories/GHSA-8q72-6qq8-xv64"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-39369"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/apereo/phpCAS/commit/b759361d904a2cb2a3bcee9411fc348cfde5d163"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/apereo/phpCAS"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/apereo/phpCAS/releases/tag/1.6.0"
  }, {
    "type" : "WEB",
    "url" : "https://lists.debian.org/debian-lts-announce/2023/07/msg00007.html"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/2XL7SMW6ESSP2Y6HHRYWW2MMCZSI4LBZ"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/RUA2JM6YT3ZXSZLBJVRA32AXYM3GJMO3"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/VJZGTWJ5ZXUUT47EHARNOUUNTH6SYDSE"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-1287" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-11-01T18:11:07Z",
    "nvd_published_at" : "2022-11-01T17:15:00Z"
  }
}