@nuxt/nitro-server-nightly 3.21.2-29554080.0366bcf6 → 3.21.2-29554630.2194e2c3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -20,7 +20,7 @@ import { ImpoundPlugin } from "impound";
20
20
  import { resolveModulePath } from "exsolve";
21
21
  import { runtimeDependencies } from "nitropack/runtime/meta";
22
22
  //#region package.json
23
- var version = "3.21.2-29554080.0366bcf6";
23
+ var version = "3.21.2-29554630.2194e2c3";
24
24
  //#endregion
25
25
  //#region src/utils.ts
26
26
  function toArray(value) {
@@ -1,5 +1,5 @@
1
1
  import { destr } from "destr";
2
- import { defineEventHandler, getQuery, readBody, setResponseHeaders } from "h3";
2
+ import { createError, defineEventHandler, getQuery, readBody, setResponseHeaders } from "h3";
3
3
  import { resolveUnrefHeadInput } from "@unhead/vue";
4
4
  import { getRequestDependencies } from "vue-bundle-renderer/runtime";
5
5
  import { getQuery as getURLQuery } from "ufo";
@@ -99,26 +99,37 @@ const handler = defineEventHandler(async (event) => {
99
99
  return islandResponse;
100
100
  });
101
101
  export default handler;
102
+ const ISLAND_PATH_PREFIX = "/__nuxt_island/";
103
+ const VALID_COMPONENT_NAME_RE = /^[a-z][\w.-]*$/i;
102
104
  async function getIslandContext(event) {
103
- // TODO: Strict validation for url
104
105
  let url = event.path || "";
105
106
  if (import.meta.prerender && event.path && await islandPropCache.hasItem(event.path)) {
106
107
  // rehydrate props from cache so we can rerender island if cache does not have it any more
107
108
  url = await islandPropCache.getItem(event.path);
108
109
  }
109
- const componentParts = url.substring("/__nuxt_island".length + 1).replace(ISLAND_SUFFIX_RE, "").split("_");
110
+ if (!url.startsWith(ISLAND_PATH_PREFIX)) {
111
+ throw createError({
112
+ statusCode: 400,
113
+ statusMessage: "Invalid island request path"
114
+ });
115
+ }
116
+ const componentParts = url.substring(ISLAND_PATH_PREFIX.length).replace(ISLAND_SUFFIX_RE, "").split("_");
110
117
  const hashId = componentParts.length > 1 ? componentParts.pop() : undefined;
111
118
  const componentName = componentParts.join("_");
112
- // TODO: Validate context
119
+ if (!componentName || !VALID_COMPONENT_NAME_RE.test(componentName)) {
120
+ throw createError({
121
+ statusCode: 400,
122
+ statusMessage: "Invalid island component name"
123
+ });
124
+ }
113
125
  const context = event.method === "GET" ? getQuery(event) : await readBody(event);
114
- const ctx = {
115
- url: "/",
116
- ...context,
126
+ // Only extract known context fields to prevent arbitrary data injection
127
+ return {
128
+ url: typeof context?.url === "string" ? context.url : "/",
117
129
  id: hashId,
118
130
  name: componentName,
119
131
  props: destr(context.props) || {},
120
132
  slots: {},
121
133
  components: {}
122
134
  };
123
- return ctx;
124
135
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/nitro-server-nightly",
3
- "version": "3.21.2-29554080.0366bcf6",
3
+ "version": "3.21.2-29554630.2194e2c3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/nuxt.git",
@@ -19,7 +19,7 @@
19
19
  ],
20
20
  "dependencies": {
21
21
  "@nuxt/devalue": "^2.0.2",
22
- "@nuxt/kit": "npm:@nuxt/kit-nightly@3.21.2-29554080.0366bcf6",
22
+ "@nuxt/kit": "npm:@nuxt/kit-nightly@3.21.2-29554630.2194e2c3",
23
23
  "@unhead/vue": "^2.1.12",
24
24
  "@vue/shared": "^3.5.30",
25
25
  "consola": "^3.4.2",
@@ -47,11 +47,11 @@
47
47
  "vue-devtools-stub": "^0.1.0"
48
48
  },
49
49
  "peerDependencies": {
50
- "nuxt": "npm:nuxt-nightly@3.21.2-29554080.0366bcf6"
50
+ "nuxt": "npm:nuxt-nightly@3.21.2-29554630.2194e2c3"
51
51
  },
52
52
  "devDependencies": {
53
- "@nuxt/schema": "npm:@nuxt/schema-nightly@3.21.2-29554080.0366bcf6",
54
- "nuxt": "npm:nuxt-nightly@3.21.2-29554080.0366bcf6",
53
+ "@nuxt/schema": "npm:@nuxt/schema-nightly@3.21.2-29554630.2194e2c3",
54
+ "nuxt": "npm:nuxt-nightly@3.21.2-29554630.2194e2c3",
55
55
  "obuild": "0.4.32",
56
56
  "vitest": "4.0.18"
57
57
  },