Skip to content

Security: Unsafe forwarding of inbound SSR headers to upstream API#624

Open
tuanaiseo wants to merge 1 commit intonuxt-community:mainfrom
tuanaiseo:contribai/fix/security/unsafe-forwarding-of-inbound-ssr-headers
Open

Security: Unsafe forwarding of inbound SSR headers to upstream API#624
tuanaiseo wants to merge 1 commit intonuxt-community:mainfrom
tuanaiseo:contribai/fix/security/unsafe-forwarding-of-inbound-ssr-headers

Conversation

@tuanaiseo
Copy link
Copy Markdown

Problem

When proxyHeaders is enabled (default), the plugin copies almost all incoming request headers from ctx.req.headers into outbound Axios headers. This includes sensitive and trust-bearing headers such as cookie, authorization, x-forwarded-for, and x-real-ip unless explicitly ignored. If the upstream API is less trusted, misconfigured, or attacker-influenced via deployment config, this can leak credentials and enable header spoofing against backend auth/rate-limit logic.

Severity: high
File: lib/plugin.js

Solution

Use an allowlist instead of pass-through by default (for example only accept, content-type, and explicitly required app headers). Add cookie, authorization, x-forwarded-for, x-real-ip, and similar headers to deny-by-default behavior unless explicitly opted in.

Changes

  • lib/plugin.js (modified)

Testing

  • Existing tests pass
  • Manual review completed
  • No new warnings/errors introduced

When `proxyHeaders` is enabled (default), the plugin copies almost all incoming request headers from `ctx.req.headers` into outbound Axios headers. This includes sensitive and trust-bearing headers such as `cookie`, `authorization`, `x-forwarded-for`, and `x-real-ip` unless explicitly ignored. If the upstream API is less trusted, misconfigured, or attacker-influenced via deployment config, this can leak credentials and enable header spoofing against backend auth/rate-limit logic.

Affected files: plugin.js

Signed-off-by: tuanaiseo <221258316+tuanaiseo@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant