VDB
KO
LOW

GHSA-r557-wffq-wvrc

@astrojs/node: Backslash-prefixed paths not recognized as internal by trailing-slash redirect

Quick fix

GHSA-r557-wffq-wvrc — @astrojs/node: upgrade to the fixed version with the command below.

npm install @astrojs/node@11.0.2

Details

### Impact

With `trailingSlash: 'always'` configured, the `@astrojs/node` standalone server's static file handler appends a trailing slash to request paths and issues a `301` redirect. Paths beginning with `/\` (slash-backslash) were not recognized as internal paths, so the handler would echo the raw path back in the `Location` header. Because browsers treat `\` as `/` per the WHATWG URL specification, the resulting redirect could resolve to an external host.

**Preconditions:** - `trailingSlash: 'always'` must be set (non-default; the default is `'ignore'`) - The request path must not have a file extension in its final segment - An attacker must deliver the crafted link to a user

### Patches

Fixed by treating backslash-prefixed paths the same as `//`-prefixed paths in `isInternalPath()`, so they are no longer rewritten with a trailing slash.

### Workarounds

Use the default `trailingSlash: 'ignore'` setting, which does not issue trailing-slash redirects in the static file handler.

### References

- [WHATWG URL spec: backslash normalization](https://url.spec.whatwg.org/#url-parsing)

Are you affected?

Enter the version of the package you're using.

Affected packages

npm / @astrojs/node
Introduced in: 8.1.0 Fixed in: 11.0.2
Fix npm install @astrojs/node@11.0.2

References