#186·TaxHacker

[Security] Unauthenticated SSRF & local file read via generateInvoicePDF Server Action

Author: CaptainceCreated Aug 26, 2026Updated Aug 26, 2026

Description

The Server Action generateInvoicePDF (exported from app/(app)/apps/invoices/actions.ts) does not perform any authentication or session validation. An unauthenticated attacker can call it directly via the Next-Action header. The businessLogo field is passed unsanitised to the @react-pdf/renderer image resolver, which on the server:

  • Treats absolute paths (e.g., /etc/passwd) as local files and calls fs.readFile().
  • Treats http:///https:// URLs as remote resources and makes server‑side fetch() requests.

This enables two attack vectors:

  1. Local file read – any file on the server filesystem can be opened (with the privileges of the Node.js process, which is root in the official Docker image).
    Note: Only image files (PNG/JPEG) or SVG/XML that render as text are reflected in the returned PDF; other formats are read but discarded, so they are not exfiltrated via the response.

  2. SSRF – the server can probe internal services; if those services respond with an image or SVG, the content is embedded in the generated PDF and can be retrieved.

This issue is especially critical in SaaS/multi‑tenant deployments, where an attacker could read other users’ uploaded invoice images (if their file UUID is known) or access internal network resources that return images/SVGs.


Steps to Reproduce

  1. Obtain the Server Action identifier
    Send an unauthenticated GET request to /apps/invoices. The page is accessible without a session (the middleware does not protect /apps/*).
    Extract the action ID from the _next/static/chunks/*.js files – it is the argument passed to createServerReference(...).

  2. Craft a POST request to the same endpoint with the Next-Action header set to that ID, and a JSON body that includes a businessLogo value pointing to a local file or an internal URL.

    Example (simplified):

    json
    {
      "title": "test",
      "businessLogo": "/etc/hosts",   // or "http://127.0.0.1:8080/admin"
      // ... other required fields (any valid invoice data)
    }
  3. Send the request without any authentication cookie – the server will process it and return a PDF.

    • If businessLogo points to a local image or an SVG, that content will appear in the PDF.
    • If it points to a non‑image file, the read still occurs (server logs may show the attempt), but the PDF will not leak the content.

(For a concrete demonstration, I can provide a full payload privately upon request.)


Expected Behavior

The Server Action should reject unauthenticated requests and sanitise/restrict the businessLogo field to trusted URLs (e.g., only data URIs or allowed domains), never accepting filesystem paths or arbitrary http:// destinations.

Actual Behavior

No authentication check is performed, and businessLogo is passed directly to the image resolver, which resolves both absolute filesystem paths and arbitrary URLs.

Environment

  • Affected versions: 0.8.5 and earlier (including the latest ghcr.io/vas3k/taxhacker:latest image).
  • Official Docker image runs as root, increasing the risk.

Additional Context

  • The middleware (proxy.ts) does not cover /apps/* routes or Server Action POST endpoints, which makes this action reachable without a session.
  • The action ID is deterministic and can be easily extracted from the client‑side chunks, making exploitation trivial.
  • I believe this should be treated as a security‑critical issue. I’m happy to provide more details or help test a fix, but I’d suggest keeping further discussion private until a patch is available (e.g., using GitHub Security Advisories).

Proposed Fix

  • Add getSession() / getCurrentUser() validation at the beginning of generateInvoicePDF.
  • Restrict businessLogo to data:image/ URIs or a whitelist of external domains; reject file://, absolute paths, and raw http:///https:// URLs.
  • Consider moving the action behind the authentication middleware or adding per‑route auth checks.