CVE-2016-9955: Simplesamlphp/simplesamlphp Incorrect Signature Verification Vulnerability

MODERATE
Advisory Identifier: GHSA-p9cm-r7jg-8q3g
CVSS 6.3
CWE-20
Published
Advisory Summary

CVE-2016-9955 is a MODERATE (CVSS 6.3) incorrect signature verification vulnerability (CWE-20: Improper Input Validation) affecting Simplesamlphp/simplesamlphp libraries in the Packagist ecosystem. The issue involves incorrect signature verification in simplesamlphp. Remediation is available by upgrading affected packages to version 1.14.11.

CVE-2016-9955 at a Glance

CVE Identifier CVE-2016-9955
GHSA Identifier GHSA-p9cm-r7jg-8q3g
Severity MODERATE
CVSS v3.1 Base Score 6.3
CWE Classification CWE-20: Improper Input Validation
Affected Product Simplesamlphp/simplesamlphp
Package Ecosystem Packagist
Published Date
Last Updated

Security Impact

CVSS: 6.3

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

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

How to Fix CVE-2016-9955

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

simplesamlphp/simplesamlphp fixed: 1.14.11
Upgrade simplesamlphp/simplesamlphp to 1.14.11
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 simplesamlphp/simplesamlphp

How to Check if You Are Affected

To determine whether your application is affected by CVE-2016-9955, inspect your project dependencies for Simplesamlphp/simplesamlphp:

inspect dependencies for simplesamlphp/simplesamlphp

Analyze the terminal output to locate any version of Simplesamlphp/simplesamlphp in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.14.11), 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-20: Improper Input Validation, where the product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly. In Simplesamlphp/simplesamlphp, 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

### Background An incorrect check of return values in the signature validation utilities allows an attacker to get invalid signatures accepted as valid by forcing an error during validation. ### Description The `SimpleSAML_XML_Validator` class allows the verification of the XML digital signature of a SAML 1 message with a given key. In particular, the constructor of the class receives an XML node and a key to verify it and throws an exception in case there is an error, either caused by incorrect input or an invalid signature. This method uses the `verify()` method from the `RobRichards\XMLSecDSig` class to verify the signature with the given key, which in turn will end up calling `openssl_verify()` depending on the signature algorithm used. The `openssl_verify()` function returns `1` when the signature was successfully verified, `0` if it failed to verify with the given key and `-1` in case an error occurs. PHP allows translating numerical values to boolean implicitly, with the following correspondences: - `0` equals `false` - Non-zero equals `true` This means that an implicit conversion to _boolean_ of the values returned by `openssl_verify()` will convert an error state, signaled by the value `-1`, to successful verification of the signature (represented by the _boolean_ `true`). The aforementioned constructor was performing an implicit conversion to boolean of the values returned by the `verify()` method, which subsequently will return the same output as `openssl_verify()` under most circumstances. This means an error during signature verification is treated as a successful verification by the method. ### Affected versions All SimpleSAMLphp versions prior to **1.14.11**. ### Impact Upon successful exploitation, an invalid signature would be regarded as valid by an affected version of the software. This allows attackers to modify or manually craft **SAML 1 response messages** and, by triggering a signature validation error in the affected party, get those messages accepted as valid and coming from a trusted entity. In practice, this means full capabilities to impersonate any individual at a given service provider. The issue can be exploited to get other invalid messages accepted as valid, though the security implications there are minor. In order to exploit the issue, **SAML 1.1 metadata must be registered by the vulnerable Service Provider for the Identity Provider targeted by the attacker** (in `metadata/shib13-idp-remote.php`), and an incorrect context must be fed to the signature validation routines, or an exceptional error must be triggered. So far, the following cases have been identified: - Using a DSA public key to validate an XML signature made with an RSA-related algorithm. - Using an RSA public key to validate an XML signature made with a DSA-related algorithm. - Exhausting available memory while verifying the signature. SimpleSAMLphp **does not support DSA signatures or keys**. Therefore, it is not possible for an attacker to feed an incorrect context by sending a signature with an incorrect algorithm. Upon reception of a DSA-SHA1 signature, SimpleSAMLphp will refuse to perform the validation due to the algorithm not being supported. On the other hand, if an attacker manages to trick a service provider operator to change the public key associated to a certain IdP to a DSA key, signatures made with any combination of the RSA algorithm will be accepted, regardless of whether they are valid or not. This means some serious misconfiguration or social engineering is needed in this case for a successful attack. Regarding memory exhaustion, it is in theory possible to attack a service provider causing the consumption of all available memory while a message with an invalid signature is being validated. However, memory exhaustion must happen only during signature validation and not immediately before or after. This means exploitation of this case is extremely difficult due to the small time window available for the attacker and the precise control that is needed over the service provider. All in all, the consequences of this issue are critical, so even though we consider it difficult to exploit, and considering that other ways to trigger failures in signature validation could be possible but so far unidentified, we recommend updating the affected software as soon as possible. ### Resolution Upgrade to the latest version. ### Credit This security issue was discovered and reported on December 3, 2016 by Thijs Kinkhorst.

CVE-2016-9955 Affected Simplesamlphp/simplesamlphp Versions

1 component(s)
Fixed Versions:
1.14.11
Product / Package Ecosystem Affected Versions Fixed Version
simplesamlphp/simplesamlphp
Packagist
< 1.14.11
1.14.11

References

Frequently Asked Questions

What is CVE-2016-9955?
CVE-2016-9955 is a security vulnerability in Simplesamlphp/simplesamlphp involving Incorrect signature verification in SimpleSAMLphp under CWE-20: Improper Input Validation.
Which Simplesamlphp/simplesamlphp versions are affected?
Affected versions include releases prior to 1.14.11 across affected packages: simplesamlphp/simplesamlphp.
What version fixes CVE-2016-9955?
Upgrading to 1.14.11 (or the latest patched release for your respective branch) resolves the vulnerability.
Is simplesamlphp/simplesamlphp affected?
Yes, simplesamlphp/simplesamlphp is affected in releases prior to 1.14.11. Upgrade your dependency to 1.14.11 or later.
What is the CVSS score of CVE-2016-9955?
CVE-2016-9955 has a CVSS v3.1 base score of 6.3 (MODERATE) with vector string CVSS:3.0/AV:L/AC:H/PR:N/UI:R/S:U/C:N/I:H/A:H.
What CWE is associated with CVE-2016-9955?
CVE-2016-9955 is classified under CWE-20: Improper Input Validation (The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.).
How can I check Packagist dependencies for CVE-2016-9955?
Run the dependency tree command: 'inspect dependencies for simplesamlphp/simplesamlphp'. 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-p9cm-r7jg-8q3g",
  "modified" : "2021-08-19T16:43:43Z",
  "published" : "2020-01-24T21:27:42Z",
  "aliases" : [ "CVE-2016-9955" ],
  "summary" : "Incorrect signature verification in SimpleSAMLphp",
  "details" : "### Background\nAn incorrect check of return values in the signature validation utilities allows an attacker to get invalid signatures accepted as valid by forcing an error during validation.\n\n### Description\nThe `SimpleSAML_XML_Validator` class allows the verification of the XML digital signature of a SAML 1 message with a given key. In particular, the constructor of the class receives an XML node and a key to verify it and throws an exception in case there is an error, either caused by incorrect input or an invalid signature. This method uses the `verify()` method from the `RobRichards\\XMLSecDSig` class to verify the signature with the given key, which in turn will end up calling `openssl_verify()` depending on the signature algorithm used.\n\nThe `openssl_verify()` function returns `1` when the signature was successfully verified, `0` if it failed to verify with the given key and `-1` in case an error occurs. PHP allows translating numerical values to boolean implicitly, with the following correspondences:\n\n- `0` equals `false`\n- Non-zero equals `true`\n\nThis means that an implicit conversion to _boolean_ of the values returned by `openssl_verify()` will convert an error state, signaled by the value `-1`, to successful verification of the signature (represented by the _boolean_ `true`).\n\nThe aforementioned constructor was performing an implicit conversion to boolean of the values returned by the `verify()` method, which subsequently will return the same output as `openssl_verify()` under most circumstances. This means an error during signature verification is treated as a successful verification by the method.\n\n###  Affected versions\nAll SimpleSAMLphp versions prior to **1.14.11**.\n\n###  Impact\nUpon successful exploitation, an invalid signature would be regarded as valid by an affected version of the software. This allows attackers to modify or manually craft **SAML 1 response messages** and, by triggering a signature validation error in the affected party, get those messages accepted as valid and coming from a trusted entity. In practice, this means full capabilities to impersonate any individual at a given service provider.\n\nThe issue can be exploited to get other invalid messages accepted as valid, though the security implications there are minor.\n\nIn order to exploit the issue, **SAML 1.1 metadata must be registered by the vulnerable Service Provider for the Identity Provider targeted by the attacker** (in `metadata/shib13-idp-remote.php`), and an incorrect context must be fed to the signature validation routines, or an exceptional error must be triggered. So far, the following cases have been identified:\n\n- Using a DSA public key to validate an XML signature made with an RSA-related algorithm.\n- Using an RSA public key to validate an XML signature made with a DSA-related algorithm.\n- Exhausting available memory while verifying the signature.\n\nSimpleSAMLphp **does not support DSA signatures or keys**. Therefore, it is not possible for an attacker to feed an incorrect context by sending a signature with an incorrect algorithm. Upon reception of a DSA-SHA1 signature, SimpleSAMLphp will refuse to perform the validation due to the algorithm not being supported. On the other hand, if an attacker manages to trick a service provider operator to change the public key associated to a certain IdP to a DSA key, signatures made with any combination of the RSA algorithm will be accepted, regardless of whether they are valid or not. This means some serious misconfiguration or social engineering is needed in this case for a successful attack.\n\nRegarding memory exhaustion, it is in theory possible to attack a service provider causing the consumption of all available memory while a message with an invalid signature is being validated. However, memory exhaustion must happen only during signature validation and not immediately before or after. This means exploitation of this case is extremely difficult due to the small time window available for the attacker and the precise control that is needed over the service provider.\n\nAll in all, the consequences of this issue are critical, so even though we consider it difficult to exploit, and considering that other ways to trigger failures in signature validation could be possible but so far unidentified, we recommend updating the affected software as soon as possible.\n\n### Resolution\nUpgrade to the latest version.\n\n### Credit\nThis security issue was discovered and reported on December 3, 2016 by Thijs Kinkhorst.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.0/AV:L/AC:H/PR:N/UI:R/S:U/C:N/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "simplesamlphp/simplesamlphp"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.14.11"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/simplesamlphp/simplesamlphp/security/advisories/GHSA-p9cm-r7jg-8q3g"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2016-9955"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/FriendsOfPHP/security-advisories/blob/master/simplesamlphp/simplesamlphp/CVE-2016-9955.yaml"
  }, {
    "type" : "WEB",
    "url" : "https://lists.debian.org/debian-lts-announce/2018/03/msg00001.html"
  }, {
    "type" : "WEB",
    "url" : "https://simplesamlphp.org/security/201612-02"
  }, {
    "type" : "WEB",
    "url" : "http://www.securityfocus.com/bid/94946"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-20" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2020-01-24T21:21:43Z",
    "nvd_published_at" : null
  }
}