Vulnerabilities in pkg:npm/better-helperjs

PACKAGE
Advisory Summary

GHSA-3p34-w4f6-5xh2 is a HIGH (CVSS 7.5) path traversal vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Better helperjs libraries in the npm ecosystem. The issue involves better-helperjs vulnerable to directory traversal via string prefix bypass in static server. Remediation is available by upgrading affected packages to version 3.0.6.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:npm/better-helperjs

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:npm/better-helperjs. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-3p34-w4f6-5xh2 - HIGH better-helperjs Vulnerable to Directory Traversal via String Prefix Bypass in Static Server

GHSA-3p34-w4f6-5xh2 at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-3p34-w4f6-5xh2
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Product Better helperjs
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:H/I:N/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 High (C:H)
Integrity None (I:N)
Availability None (A:N)

How to Fix GHSA-3p34-w4f6-5xh2

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

better-helperjs fixed: 3.0.6
npm install better-helperjs@3.0.6
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 better-helperjs

How to Check if You Are Affected

To determine whether your Node.js application is affected by GHSA-3p34-w4f6-5xh2, inspect your project dependencies using npm:

npm ls better-helperjs

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

Note: The npm ls better-helperjs 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-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. In Better helperjs, 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 A directory traversal vulnerability exists in the production static file server of `better-helperjs` (`<= 3.0.5`). Attackers can read arbitrary files located in adjacent directory structures that share the same string prefix as the intended static root directory. ## Details The framework utilizes a custom static file server engine used when running in `NODE_ENV=production` (`src/ssr/site-server.ts`). Inside the `safeStaticPath()` method, the requested path is checked against the static root directory to prevent directory traversal out of the designated public folder. However, the validation uses `String.prototype.startsWith()`: ```typescript const root = path.resolve(rootDir); const resolved = path.resolve(root, `.${decodedPath}`); if (!resolved.startsWith(root)) { return null; } ``` This is logically flawed because `startsWith` evaluates plain strings rather than structural directory paths. If the application's assigned `rootDir` is `/app/dist/client`, and an attacker tries to access `/app/dist/client-secrets/database.sqlite`, the string `"/app/dist/client-secrets/database.sqlite"` successfully **starts with** `"/app/dist/client"`. Because of this bypass, an attacker can read sensitive files stored inside any adjacent directory traversing through the parent, as long as the adjacent directory name begins with the exact same prefix as the target public directory. ## Impact - **Severity:** High (7.5) - **Vector:** `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N` - **Affected Versions:** `<= 3.0.5` - **Patched Version:** `>= 3.0.6` ## Proof of Concept To reproduce this locally on a vulnerable installation: 1. Assume the framework static configuration serves from a `.dist/client` directory. 2. Build the project and create an adjacent prefix secret simulating sensitive deployment structure: ```bash npm run build mkdir -p dist/client-secrets echo "EXPOSED_SECRET" > dist/client-secrets/secret.txt ``` 3. Start the application in Production mode (`NODE_ENV=production tsx server.ts`). 4. Using an HTTP client that doesn't pre-normalize `/../` paths (e.g., `netcat` or raw sockets), send a GET request spanning into the prefix-sharing adjacent folder: ```http GET /%2e%2e%2fclient-secrets/secret.txt HTTP/1.1 Host: localhost:4174 Connection: close ``` 5. The server incorrectly validates the path and responds with `HTTP/1.1 200 OK` exposing `EXPOSED_SECRET`. *(Note: Developer environment `npm run dev` servers are immune as static requests are handled defensively by Vite's Dev Middlewares. This vulnerability only triggers upon `production` starts).* ## Remediation / Patches The path validation block has been updated to mandate exact path separation bounds by enforcing `path.sep` onto the evaluated traversal string. ```typescript // Enforces separator OR exact root matches preventing prefix extension if (!resolved.startsWith(root + path.sep) && resolved !== root) { return null; } ``` ## Workarounds If upgrading is temporarily impossible, users can safeguard their environment by ensuring no sensitive directories are deployed adjacent to their static build `client` directories sharing the identical word-prefix string.

GHSA-3p34-w4f6-5xh2 Affected Better helperjs Versions

1 component(s)
Fixed Versions:
3.0.6
Product / Package Ecosystem Affected Versions Fixed Version
better-helperjs
npm
< 3.0.6
3.0.6

References

Frequently Asked Questions

What is GHSA-3p34-w4f6-5xh2?
GHSA-3p34-w4f6-5xh2 is a security vulnerability in Better helperjs involving better-helperjs Vulnerable to Directory Traversal via String Prefix Bypass in Static Server under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which Better helperjs versions are affected?
Affected versions include releases prior to 3.0.6 across affected packages: better-helperjs.
What version fixes GHSA-3p34-w4f6-5xh2?
Upgrading to 3.0.6 (or the latest patched release for your respective branch) resolves the vulnerability.
Is better-helperjs affected?
Yes, better-helperjs is affected in releases prior to 3.0.6. Upgrade your dependency to 3.0.6 or later.
What is the CVSS score of GHSA-3p34-w4f6-5xh2?
GHSA-3p34-w4f6-5xh2 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:H/I:N/A:N.
What CWE is associated with GHSA-3p34-w4f6-5xh2?
GHSA-3p34-w4f6-5xh2 is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') (The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.).
How can I check npm dependencies for GHSA-3p34-w4f6-5xh2?
Run the dependency tree command: 'npm ls better-helperjs'. 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-3p34-w4f6-5xh2",
  "modified" : "2026-06-26T20:56:26Z",
  "published" : "2026-06-26T20:56:26Z",
  "aliases" : [ ],
  "summary" : "better-helperjs Vulnerable to Directory Traversal via String Prefix Bypass in Static Server",
  "details" : "## Summary\nA directory traversal vulnerability exists in the production static file server of `better-helperjs` (`<= 3.0.5`). Attackers can read arbitrary files located in adjacent directory structures that share the same string prefix as the intended static root directory.\n\n## Details\nThe framework utilizes a custom static file server engine used when running in `NODE_ENV=production` (`src/ssr/site-server.ts`). Inside the `safeStaticPath()` method, the requested path is checked against the static root directory to prevent directory traversal out of the designated public folder.\n\nHowever, the validation uses `String.prototype.startsWith()`:\n```typescript\n  const root = path.resolve(rootDir);\n  const resolved = path.resolve(root, `.${decodedPath}`);\n  \n  if (!resolved.startsWith(root)) {\n    return null;\n  }\n```\nThis is logically flawed because `startsWith` evaluates plain strings rather than structural directory paths. If the application's assigned `rootDir` is `/app/dist/client`, and an attacker tries to access `/app/dist/client-secrets/database.sqlite`, the string `\"/app/dist/client-secrets/database.sqlite\"` successfully **starts with** `\"/app/dist/client\"`. \n\nBecause of this bypass, an attacker can read sensitive files stored inside any adjacent directory traversing through the parent, as long as the adjacent directory name begins with the exact same prefix as the target public directory.\n\n## Impact\n- **Severity:** High (7.5)\n- **Vector:** `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N`\n- **Affected Versions:** `<= 3.0.5`\n- **Patched Version:** `>= 3.0.6`\n\n## Proof of Concept\nTo reproduce this locally on a vulnerable installation:\n1. Assume the framework static configuration serves from a `.dist/client` directory.\n2. Build the project and create an adjacent prefix secret simulating sensitive deployment structure:\n   ```bash\n   npm run build\n   mkdir -p dist/client-secrets\n   echo \"EXPOSED_SECRET\" > dist/client-secrets/secret.txt\n   ```\n3. Start the application in Production mode (`NODE_ENV=production tsx server.ts`).\n4. Using an HTTP client that doesn't pre-normalize `/../` paths (e.g., `netcat` or raw sockets), send a GET request spanning into the prefix-sharing adjacent folder:\n   ```http\n   GET /%2e%2e%2fclient-secrets/secret.txt HTTP/1.1\n   Host: localhost:4174\n   Connection: close\n   ```\n5. The server incorrectly validates the path and responds with `HTTP/1.1 200 OK` exposing `EXPOSED_SECRET`.\n\n*(Note: Developer environment `npm run dev` servers are immune as static requests are handled defensively by Vite's Dev Middlewares. This vulnerability only triggers upon `production` starts).*\n\n## Remediation / Patches\nThe path validation block has been updated to mandate exact path separation bounds by enforcing `path.sep` onto the evaluated traversal string.\n```typescript\n  // Enforces separator OR exact root matches preventing prefix extension\n  if (!resolved.startsWith(root + path.sep) && resolved !== root) {\n    return null;\n  }\n```\n\n## Workarounds\nIf upgrading is temporarily impossible, users can safeguard their environment by ensuring no sensitive directories are deployed adjacent to their static build `client` directories sharing the identical word-prefix string.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "better-helperjs"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.0.6"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 3.0.5"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/Rigby-Foundation/BetterHelperjs/security/advisories/GHSA-3p34-w4f6-5xh2"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/Rigby-Foundation/BetterHelperjs"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-06-26T20:56:26Z",
    "nvd_published_at" : null
  }
}