CVE-2024-29896: @kindspells/astro shield Content-Security-Policy Header Generation Vulnerability

HIGH
Advisory Identifier: GHSA-w387-5qqw-7g8m
CVSS 7.5
CWE-74
Published
Advisory Summary

CVE-2024-29896 is a HIGH (CVSS 7.5) content-security-policy header generation vulnerability (CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')) affecting @kindspells/astro shield libraries in the npm ecosystem. The issue involves content-security-policy header generation in middleware could be compromised by malicious injections. Remediation is available by upgrading affected packages to version 1.3.0.

CVE-2024-29896 at a Glance

CVE Identifier CVE-2024-29896
GHSA Identifier GHSA-w387-5qqw-7g8m
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
Affected Product @kindspells/astro shield
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 7.5

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:H/A:N).

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 High (I:H)
Availability None (A:N)

How to Fix CVE-2024-29896

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

@kindspells/astro-shield fixed: 1.3.0
npm install @kindspells/astro-shield@1.3.0
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 @kindspells/astro-shield

How to Check if You Are Affected

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

npm ls @kindspells/astro-shield

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

Note: The npm ls @kindspells/astro-shield 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-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection'), where the product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component. In @kindspells/astro shield, 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 When the following conditions are met: - Automated CSP headers generation for SSR content is enabled - The web application serves content that can be partially controlled by external users Then it is possible that the CSP headers generation feature might be "allow-listing" malicious injected resources like inlined JS, or references to external malicious scripts. ### Patches Available in version 1.3.0 . ### Workarounds - Do not enable CSP headers generation. - Use it only for dynamically generated content that cannot be controlled by external users in any way. ### References _Are there any links users can visit to find out more?_

CVE-2024-29896 Affected @kindspells/astro shield Versions

1 component(s)
Fixed Versions:
1.3.0
Product / Package Ecosystem Affected Versions Fixed Version
@kindspells/astro-shield
npm
≥ 1.2.0
< 1.3.0
All 1 versions
1.2.0
1.3.0

References

Frequently Asked Questions

What is CVE-2024-29896?
CVE-2024-29896 is a security vulnerability in @kindspells/astro shield involving Content-Security-Policy header generation in middleware could be compromised by malicious injections under CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection').
Which @kindspells/astro shield versions are affected?
Affected versions include releases prior to 1.3.0 across affected packages: @kindspells/astro-shield.
What version fixes CVE-2024-29896?
Upgrading to 1.3.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @kindspells/astro-shield affected?
Yes, @kindspells/astro-shield is affected in releases prior to 1.3.0. Upgrade your dependency to 1.3.0 or later.
What is the CVSS score of CVE-2024-29896?
CVE-2024-29896 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N.
What CWE is associated with CVE-2024-29896?
CVE-2024-29896 is classified under CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') (The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.).
How can I check npm dependencies for CVE-2024-29896?
Run the dependency tree command: 'npm ls @kindspells/astro-shield'. 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-w387-5qqw-7g8m",
  "modified" : "2024-09-12T13:52:22Z",
  "published" : "2024-03-29T19:03:59Z",
  "aliases" : [ "CVE-2024-29896" ],
  "summary" : "Content-Security-Policy header generation in middleware could be compromised by malicious injections",
  "details" : "### Impact\n\nWhen the following conditions are met:\n- Automated CSP headers generation for SSR content is enabled\n- The web application serves content that can be partially controlled by external users\n\nThen it is possible that the CSP headers generation feature might be \"allow-listing\" malicious injected resources like inlined JS, or references to external malicious scripts.\n\n### Patches\nAvailable in version 1.3.0 .\n\n### Workarounds\n- Do not enable CSP headers generation.\n- Use it only for dynamically generated content that cannot be controlled by external users in any way.\n\n### References\n_Are there any links users can visit to find out more?_\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:H/VA:N/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@kindspells/astro-shield"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.2.0"
      }, {
        "fixed" : "1.3.0"
      } ]
    } ],
    "versions" : [ "1.2.0" ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/KindSpells/astro-shield/security/advisories/GHSA-w387-5qqw-7g8m"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-29896"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/KindSpells/astro-shield/commit/41b84576d37fa486a57005ea297658d0bc38566d"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/KindSpells/astro-shield/commit/ad3abf5577bae9be420b7ddf376337a5b8817869"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/KindSpells/astro-shield"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/KindSpells/astro-shield/compare/1.2.0...1.3.0"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-74" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-03-29T19:03:59Z",
    "nvd_published_at" : "2024-03-28T13:15:47Z"
  }
}