CVE-2023-40178: @node saml/node saml @node-saml/node-saml's ValidatePostRequestAsync Does Not Include Vulnerability

MODERATE
Advisory Identifier: GHSA-vx8m-6fhw-pccw
CVSS 5.3
CWE-613 CWE-347
Published
Advisory Summary

CVE-2023-40178 is a MODERATE (CVSS 5.3) @node-saml/node-saml's validatepostrequestasync does not include vulnerability (CWE-613: Insufficient Session Expiration) affecting @node saml/node saml libraries in the npm ecosystem. The issue involves @node-saml/node-saml's validatepostrequestasync does not include checktimestampsvalidityerror. Remediation is available by upgrading affected packages to version 4.0.5.

CVE-2023-40178 at a Glance

CVE Identifier CVE-2023-40178
GHSA Identifier GHSA-vx8m-6fhw-pccw
Severity MODERATE
CVSS v3.1 Base Score 5.3
CWE Classification CWE-613: Insufficient Session Expiration
Affected Product @node saml/node saml
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 5.3

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

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

How to Fix CVE-2023-40178

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

@node-saml/node-saml fixed: 4.0.5
npm install @node-saml/node-saml@4.0.5
Verify Direct and Transitive Dependencies

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

npm ls @node-saml/node-saml

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2023-40178, inspect your project dependencies using npm:

npm ls @node-saml/node-saml

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

Note: The npm ls @node-saml/node-saml command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-613: Insufficient Session Expiration, where according to wasc, "insufficient session expiration is when a web site permits an attacker to reuse old session credentials or session ids for authorization.". In @node saml/node saml, 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

### Summary The lack of checking of current timestamp allows a LogoutRequest XML to be reused multiple times even when the current time is past the NotOnOrAfter. ### Details It was noticed that in the validatePostRequestAsync() flow in saml.js, the current timestamp is never checked. This could present a vulnerability where a user who has an XML LogoutRequest could validated it if the IssueInstance and the NotOnOrAfter are valid along with valid credentials (signature, certificate etc.). ### PoC I was able to validate a sample valid LogoutRequest XML multiple times through postman by sending it to my endpoint regardless if the current present time was past the NotOnOrAfter time. After some further testing, it seems that only the IssueInstance is checked against NotOnOrAfter. Not sure if this was the intended behaviour but I believe having a never expiring valid LogoutRequest could be dangerous. ### Impact This could impact the user where they would be logged out from an expired LogoutRequest. In bigger contexts, if LogoutRequests are sent out in mass to different SPs, this could impact many users on a large scale.

CVE-2023-40178 Affected @node saml/node saml Versions

1 component(s)
Fixed Versions:
4.0.5
Product / Package Ecosystem Affected Versions Fixed Version
@node-saml/node-saml
npm
< 4.0.5
4.0.5

References

Frequently Asked Questions

What is CVE-2023-40178?
CVE-2023-40178 is a security vulnerability in @node saml/node saml involving @node-saml/node-saml's validatePostRequestAsync does not include checkTimestampsValidityError under CWE-613: Insufficient Session Expiration.
Which @node saml/node saml versions are affected?
Affected versions include releases prior to 4.0.5 across affected packages: @node-saml/node-saml.
What version fixes CVE-2023-40178?
Upgrading to 4.0.5 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @node-saml/node-saml affected?
Yes, @node-saml/node-saml is affected in releases prior to 4.0.5. Upgrade your dependency to 4.0.5 or later.
What is the CVSS score of CVE-2023-40178?
CVE-2023-40178 has a CVSS v3.1 base score of 5.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L.
What CWE is associated with CVE-2023-40178?
CVE-2023-40178 is classified under CWE-613: Insufficient Session Expiration (According to WASC, "Insufficient Session Expiration is when a web site permits an attacker to reuse old session credentials or session IDs for authorization.").
How can I check npm dependencies for CVE-2023-40178?
Run the dependency tree command: 'npm ls @node-saml/node-saml'. 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-vx8m-6fhw-pccw",
  "modified" : "2023-08-21T20:13:05Z",
  "published" : "2023-08-21T20:13:05Z",
  "aliases" : [ "CVE-2023-40178" ],
  "summary" : "@node-saml/node-saml's validatePostRequestAsync does not include checkTimestampsValidityError",
  "details" : "### Summary\n\nThe lack of checking of current timestamp allows a LogoutRequest XML to be reused multiple times even when the current time is past the NotOnOrAfter. \n\n### Details\n\nIt was noticed that in the validatePostRequestAsync() flow in saml.js, the current timestamp is never checked. This could present a vulnerability where a user who has an XML LogoutRequest could validated it if the IssueInstance and the NotOnOrAfter are valid along with valid credentials (signature, certificate etc.). \n\n### PoC\n\nI was able to validate a sample valid LogoutRequest XML multiple times through postman by sending it to my endpoint regardless if the current present time was past the NotOnOrAfter time. After some further testing, it seems that only the IssueInstance is checked against NotOnOrAfter. Not sure if this was the intended behaviour but I believe having a never expiring valid LogoutRequest could be dangerous.\n\n### Impact\n\nThis could impact the user where they would be logged out from an expired LogoutRequest. In bigger contexts, if LogoutRequests are sent out in mass to different SPs, this could impact many users on a large scale.\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@node-saml/node-saml"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.0.5"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/node-saml/node-saml/security/advisories/GHSA-vx8m-6fhw-pccw"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-40178"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/node-saml/node-saml/commit/045e3b9c54211fdb95f96edf363679845b195cec"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/node-saml/node-saml"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/node-saml/node-saml/releases/tag/v4.0.5"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-347", "CWE-613" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-08-21T20:13:05Z",
    "nvd_published_at" : "2023-08-23T21:15:08Z"
  }
}