-
Notifications
You must be signed in to change notification settings - Fork 86
test: add test ensuring GHSA-f82v-jwr5-mffw
doesn't affect Next.js on Netlify
#2778
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
tests/fixtures/middleware-subrequest-vuln/app/[[...wildcard]]/page.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default function Home() { | ||
return ( | ||
<main> | ||
<h1>Hi</h1> | ||
</main> | ||
) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export const metadata = { | ||
title: 'Simple Next App', | ||
description: 'Description for Simple Next App', | ||
} | ||
|
||
export default function RootLayout({ children }) { | ||
return ( | ||
<html lang="en"> | ||
<body>{children}</body> | ||
</html> | ||
) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { NextResponse } from 'next/server' | ||
import { NextRequest } from 'next/server' | ||
|
||
import packageJson from 'next/package.json' | ||
|
||
export async function middleware(request: NextRequest) { | ||
const response = NextResponse.next() | ||
|
||
response.headers.set('x-test-used-middleware', 'true') | ||
response.headers.set('x-test-used-next-version', packageJson.version) | ||
|
||
return response | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = { | ||
output: 'standalone', | ||
eslint: { | ||
ignoreDuringBuilds: true, | ||
}, | ||
} | ||
|
||
module.exports = nextConfig |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "middleware-subrequest-vuln", | ||
"version": "0.1.0", | ||
"private": true, | ||
"scripts": { | ||
"postinstall": "next build", | ||
"dev": "next dev", | ||
"build": "next build" | ||
}, | ||
"dependencies": { | ||
"next": "15.2.2", | ||
"react": "18.2.0", | ||
"react-dom": "18.2.0" | ||
}, | ||
"test": { | ||
"dependencies": { | ||
"next": "15.2.2" | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is inspired by vercel/next.js@52a078d#diff-c5e08cd8ee165bce3a9fb81c8315d6e149b76f6f9b2e53f70bb2f39fb248d2aeR148-R157
Just assertions are hopefully more readable in their intention - goal is to ensure that middleware is not skipped when
x-middleware-subrequest
request header with 5+ hops is provided ( as then https://github.com/vercel/next.js/blob/cdb9a8c3b355593ab19ee6dec7c59e622bf59c81/packages/next/src/server/web/sandbox/sandbox.ts#L96-L114 this code path with early bail (circuit breaker to prevent infinite recursion) would be executed that would skip execution of actual middleware - at least when self hosting, but we don't even use this code path for our handling)