diff --git a/patches/cloudcmd-file-type-security.patch b/patches/cloudcmd-file-type-security.patch new file mode 100644 index 0000000..81bd472 --- /dev/null +++ b/patches/cloudcmd-file-type-security.patch @@ -0,0 +1,60 @@ +diff --git a/node_modules/join-io/node_modules/ponse/node_modules/file-type/core.js b/node_modules/join-io/node_modules/ponse/node_modules/file-type/core.js +--- a/node_modules/join-io/node_modules/ponse/node_modules/file-type/core.js ++++ b/node_modules/join-io/node_modules/ponse/node_modules/file-type/core.js +@@ -1073,8 +1073,9 @@ + + await tokenizer.ignore(30); + // Search for header should be in first 1KB of file. +- while (tokenizer.position + 24 < tokenizer.fileInfo.size) { +- const header = await readHeader(); ++ while (tokenizer.position + 24 < tokenizer.fileInfo.size) { ++ const previousPosition = tokenizer.position; ++ const header = await readHeader(); + let payload = header.size - 24; + if (_check(header.id, [0x91, 0x07, 0xDC, 0xB7, 0xB7, 0xA9, 0xCF, 0x11, 0x8E, 0xE6, 0x00, 0xC0, 0x0C, 0x20, 0x53, 0x65])) { + // Sync on Stream-Properties-Object (B7DC0791-A9B7-11CF-8EE6-00C00C205365) +@@ -1100,8 +1101,12 @@ + break; + } + +- await tokenizer.ignore(payload); +- } ++ await tokenizer.ignore(payload); ++ // Upstream GHSA-5v7r-6r5c-r473: malformed ASF headers must advance. ++ if (tokenizer.position <= previousPosition) { ++ break; ++ } ++ } + + // Default to ASF generic extension + return { +diff --git a/node_modules/restbox/node_modules/ponse/node_modules/file-type/core.js b/node_modules/restbox/node_modules/ponse/node_modules/file-type/core.js +--- a/node_modules/restbox/node_modules/ponse/node_modules/file-type/core.js ++++ b/node_modules/restbox/node_modules/ponse/node_modules/file-type/core.js +@@ -1073,8 +1073,9 @@ + + await tokenizer.ignore(30); + // Search for header should be in first 1KB of file. +- while (tokenizer.position + 24 < tokenizer.fileInfo.size) { +- const header = await readHeader(); ++ while (tokenizer.position + 24 < tokenizer.fileInfo.size) { ++ const previousPosition = tokenizer.position; ++ const header = await readHeader(); + let payload = header.size - 24; + if (_check(header.id, [0x91, 0x07, 0xDC, 0xB7, 0xB7, 0xA9, 0xCF, 0x11, 0x8E, 0xE6, 0x00, 0xC0, 0x0C, 0x20, 0x53, 0x65])) { + // Sync on Stream-Properties-Object (B7DC0791-A9B7-11CF-8EE6-00C00C205365) +@@ -1100,8 +1101,12 @@ + break; + } + +- await tokenizer.ignore(payload); +- } ++ await tokenizer.ignore(payload); ++ // Upstream GHSA-5v7r-6r5c-r473: malformed ASF headers must advance. ++ if (tokenizer.position <= previousPosition) { ++ break; ++ } ++ } + + // Default to ASF generic extension + return { diff --git a/patches/cloudcmd-glob-security.patch b/patches/cloudcmd-glob-security.patch new file mode 100644 index 0000000..15348e8 --- /dev/null +++ b/patches/cloudcmd-glob-security.patch @@ -0,0 +1,90 @@ +diff --git a/node_modules/glob/dist/commonjs/walker.js b/node_modules/glob/dist/commonjs/walker.js +--- a/node_modules/glob/dist/commonjs/walker.js ++++ b/node_modules/glob/dist/commonjs/walker.js +@@ -184,16 +184,16 @@ + } + walkCB(target, patterns, cb) { + /* c8 ignore start */ +- if (this.signal?.aborted) +- cb(); ++ if (this.signal?.aborted) ++ return cb(); + /* c8 ignore stop */ + this.walkCB2(target, patterns, new processor_js_1.Processor(this.opts), cb); + } + walkCB2(target, patterns, processor, cb) { + if (this.#childrenIgnored(target)) + return cb(); +- if (this.signal?.aborted) +- cb(); ++ if (this.signal?.aborted) ++ return cb(); + if (this.paused) { + this.onResume(() => this.walkCB2(target, patterns, processor, cb)); + return; +@@ -248,16 +248,16 @@ + } + walkCBSync(target, patterns, cb) { + /* c8 ignore start */ +- if (this.signal?.aborted) +- cb(); ++ if (this.signal?.aborted) ++ return cb(); + /* c8 ignore stop */ + this.walkCB2Sync(target, patterns, new processor_js_1.Processor(this.opts), cb); + } + walkCB2Sync(target, patterns, processor, cb) { + if (this.#childrenIgnored(target)) + return cb(); +- if (this.signal?.aborted) +- cb(); ++ if (this.signal?.aborted) ++ return cb(); + if (this.paused) { + this.onResume(() => this.walkCB2Sync(target, patterns, processor, cb)); + return; +diff --git a/node_modules/glob/dist/esm/walker.js b/node_modules/glob/dist/esm/walker.js +--- a/node_modules/glob/dist/esm/walker.js ++++ b/node_modules/glob/dist/esm/walker.js +@@ -181,16 +181,16 @@ + } + walkCB(target, patterns, cb) { + /* c8 ignore start */ +- if (this.signal?.aborted) +- cb(); ++ if (this.signal?.aborted) ++ return cb(); + /* c8 ignore stop */ + this.walkCB2(target, patterns, new Processor(this.opts), cb); + } + walkCB2(target, patterns, processor, cb) { + if (this.#childrenIgnored(target)) + return cb(); +- if (this.signal?.aborted) +- cb(); ++ if (this.signal?.aborted) ++ return cb(); + if (this.paused) { + this.onResume(() => this.walkCB2(target, patterns, processor, cb)); + return; +@@ -245,16 +245,16 @@ + } + walkCBSync(target, patterns, cb) { + /* c8 ignore start */ +- if (this.signal?.aborted) +- cb(); ++ if (this.signal?.aborted) ++ return cb(); + /* c8 ignore stop */ + this.walkCB2Sync(target, patterns, new Processor(this.opts), cb); + } + walkCB2Sync(target, patterns, processor, cb) { + if (this.#childrenIgnored(target)) + return cb(); +- if (this.signal?.aborted) +- cb(); ++ if (this.signal?.aborted) ++ return cb(); + if (this.paused) { + this.onResume(() => this.walkCB2Sync(target, patterns, processor, cb)); + return; diff --git a/patches/cloudcmd-got-security.patch b/patches/cloudcmd-got-security.patch new file mode 100644 index 0000000..225260b --- /dev/null +++ b/patches/cloudcmd-got-security.patch @@ -0,0 +1,20 @@ +diff --git a/node_modules/got/dist/source/request-as-event-emitter.js b/node_modules/got/dist/source/request-as-event-emitter.js +--- a/node_modules/got/dist/source/request-as-event-emitter.js ++++ b/node_modules/got/dist/source/request-as-event-emitter.js +@@ -103,8 +103,14 @@ + } + // Handles invalid URLs. See https://github.com/sindresorhus/got/issues/604 + const redirectBuffer = Buffer.from(typedResponse.headers.location, 'binary').toString(); +- const redirectUrl = new url_1.URL(redirectBuffer, options.url); +- // Redirecting to a different site, clear cookies. ++ const redirectUrl = new url_1.URL(redirectBuffer, options.url); ++ // Upstream GHSA-pfrx-2q88-qq97: reject redirects from HTTP(S) to UNIX sockets. ++ const sourceIsUnixSocket = options.url.protocol === 'unix:' || options.url.hostname === 'unix'; ++ const redirectIsUnixSocket = redirectUrl.protocol === 'unix:' || redirectUrl.hostname === 'unix'; ++ if (!sourceIsUnixSocket && redirectIsUnixSocket) { ++ throw new errors_1.RequestError(new Error('Cannot redirect to UNIX socket'), options); ++ } ++ // Redirecting to a different site, clear cookies. + if (redirectUrl.hostname !== options.url.hostname && Reflect.has(options.headers, 'cookie')) { + delete options.headers.cookie; + } diff --git a/patches/cloudcmd-minimatch-security.patch b/patches/cloudcmd-minimatch-security.patch new file mode 100644 index 0000000..fcd3165 --- /dev/null +++ b/patches/cloudcmd-minimatch-security.patch @@ -0,0 +1,152 @@ +diff --git a/node_modules/glob/node_modules/minimatch/dist/commonjs/index.js b/node_modules/glob/node_modules/minimatch/dist/commonjs/index.js +--- a/node_modules/glob/node_modules/minimatch/dist/commonjs/index.js ++++ b/node_modules/glob/node_modules/minimatch/dist/commonjs/index.js +@@ -445,13 +445,17 @@ + // + // **/*/ -> */**/ <== not valid because ** doesn't follow + // this WOULD be allowed if ** did follow symlinks, or * didn't +- firstPhasePreProcess(globParts) { +- let didSomething = false; ++ firstPhasePreProcess(globParts) { ++ const { braceExpandMax = 100000 } = this.options; ++ let didSomething = false; + do { + didSomething = false; + //
/**/../

/

/ -> {

/../

/

/,

/**/

/

/} +- for (let parts of globParts) { +- let gs = -1; ++ for (let parts of globParts) { ++ // Upstream GHSA-g3hv-75wg-m249: bound iterative globparts expansion. ++ if (globParts.length >= braceExpandMax) ++ return globParts; ++ let gs = -1; + while (-1 !== (gs = parts.indexOf('**', gs + 1))) { + let gss = gs; + while (parts[gss + 1] === '**') { +@@ -529,8 +533,10 @@ + // + // {

/**/,
/**/

/} ->

/**/
+     // ^-- not valid because ** doens't follow symlinks
+-    secondPhasePreProcess(globParts) {
+-        for (let i = 0; i < globParts.length - 1; i++) {
++    secondPhasePreProcess(globParts) {
++        if (globParts.length > 1000)
++            return globParts;
++        for (let i = 0; i < globParts.length - 1; i++) {
+             for (let j = i + 1; j < globParts.length; j++) {
+                 const matched = this.partsMatch(globParts[i], globParts[j], !this.preserveMultipleSlashes);
+                 if (matched) {
+diff --git a/node_modules/glob/node_modules/minimatch/dist/esm/index.js b/node_modules/glob/node_modules/minimatch/dist/esm/index.js
+--- a/node_modules/glob/node_modules/minimatch/dist/esm/index.js
++++ b/node_modules/glob/node_modules/minimatch/dist/esm/index.js
+@@ -433,13 +433,17 @@
+     //
+     // **/*/ -> */**/ <== not valid because ** doesn't follow
+     // this WOULD be allowed if ** did follow symlinks, or * didn't
+-    firstPhasePreProcess(globParts) {
+-        let didSomething = false;
++    firstPhasePreProcess(globParts) {
++        const { braceExpandMax = 100000 } = this.options;
++        let didSomething = false;
+         do {
+             didSomething = false;
+             // 
/**/../

/

/ -> {

/../

/

/,

/**/

/

/} +- for (let parts of globParts) { +- let gs = -1; ++ for (let parts of globParts) { ++ // Upstream GHSA-g3hv-75wg-m249: bound iterative globparts expansion. ++ if (globParts.length >= braceExpandMax) ++ return globParts; ++ let gs = -1; + while (-1 !== (gs = parts.indexOf('**', gs + 1))) { + let gss = gs; + while (parts[gss + 1] === '**') { +@@ -517,8 +521,10 @@ + // + // {

/**/,
/**/

/} ->

/**/
+     // ^-- not valid because ** doens't follow symlinks
+-    secondPhasePreProcess(globParts) {
+-        for (let i = 0; i < globParts.length - 1; i++) {
++    secondPhasePreProcess(globParts) {
++        if (globParts.length > 1000)
++            return globParts;
++        for (let i = 0; i < globParts.length - 1; i++) {
+             for (let j = i + 1; j < globParts.length; j++) {
+                 const matched = this.partsMatch(globParts[i], globParts[j], !this.preserveMultipleSlashes);
+                 if (matched) {
+diff --git a/node_modules/onezip/node_modules/glob/node_modules/minimatch/dist/commonjs/index.js b/node_modules/onezip/node_modules/glob/node_modules/minimatch/dist/commonjs/index.js
+--- a/node_modules/onezip/node_modules/glob/node_modules/minimatch/dist/commonjs/index.js
++++ b/node_modules/onezip/node_modules/glob/node_modules/minimatch/dist/commonjs/index.js
+@@ -452,13 +452,17 @@
+     //
+     // **/*/ -> */**/ <== not valid because ** doesn't follow
+     // this WOULD be allowed if ** did follow symlinks, or * didn't
+-    firstPhasePreProcess(globParts) {
+-        let didSomething = false;
++    firstPhasePreProcess(globParts) {
++        const { braceExpandMax = 100000 } = this.options;
++        let didSomething = false;
+         do {
+             didSomething = false;
+             // 
/**/../

/

/ -> {

/../

/

/,

/**/

/

/} +- for (let parts of globParts) { +- let gs = -1; ++ for (let parts of globParts) { ++ // Upstream GHSA-g3hv-75wg-m249: bound iterative globparts expansion. ++ if (globParts.length >= braceExpandMax) ++ return globParts; ++ let gs = -1; + while (-1 !== (gs = parts.indexOf('**', gs + 1))) { + let gss = gs; + while (parts[gss + 1] === '**') { +@@ -536,8 +540,10 @@ + // + // {

/**/,
/**/

/} ->

/**/
+     // ^-- not valid because ** doens't follow symlinks
+-    secondPhasePreProcess(globParts) {
+-        for (let i = 0; i < globParts.length - 1; i++) {
++    secondPhasePreProcess(globParts) {
++        if (globParts.length > 1000)
++            return globParts;
++        for (let i = 0; i < globParts.length - 1; i++) {
+             for (let j = i + 1; j < globParts.length; j++) {
+                 const matched = this.partsMatch(globParts[i], globParts[j], !this.preserveMultipleSlashes);
+                 if (matched) {
+diff --git a/node_modules/onezip/node_modules/glob/node_modules/minimatch/dist/esm/index.js b/node_modules/onezip/node_modules/glob/node_modules/minimatch/dist/esm/index.js
+--- a/node_modules/onezip/node_modules/glob/node_modules/minimatch/dist/esm/index.js
++++ b/node_modules/onezip/node_modules/glob/node_modules/minimatch/dist/esm/index.js
+@@ -443,13 +443,17 @@
+     //
+     // **/*/ -> */**/ <== not valid because ** doesn't follow
+     // this WOULD be allowed if ** did follow symlinks, or * didn't
+-    firstPhasePreProcess(globParts) {
+-        let didSomething = false;
++    firstPhasePreProcess(globParts) {
++        const { braceExpandMax = 100000 } = this.options;
++        let didSomething = false;
+         do {
+             didSomething = false;
+             // 
/**/../

/

/ -> {

/../

/

/,

/**/

/

/} +- for (let parts of globParts) { +- let gs = -1; ++ for (let parts of globParts) { ++ // Upstream GHSA-g3hv-75wg-m249: bound iterative globparts expansion. ++ if (globParts.length >= braceExpandMax) ++ return globParts; ++ let gs = -1; + while (-1 !== (gs = parts.indexOf('**', gs + 1))) { + let gss = gs; + while (parts[gss + 1] === '**') { +@@ -527,8 +531,10 @@ + // + // {

/**/,
/**/

/} ->

/**/
+     // ^-- not valid because ** doens't follow symlinks
+-    secondPhasePreProcess(globParts) {
+-        for (let i = 0; i < globParts.length - 1; i++) {
++    secondPhasePreProcess(globParts) {
++        if (globParts.length > 1000)
++            return globParts;
++        for (let i = 0; i < globParts.length - 1; i++) {
+             for (let j = i + 1; j < globParts.length; j++) {
+                 const matched = this.partsMatch(globParts[i], globParts[j], !this.preserveMultipleSlashes);
+                 if (matched) {