#47728 [W&A-Critical] Server-Side Request Forgery (SSRF) Vulnerability in Next.js _app.tsx component
Description
App.getInitialProps = async (context: any) => {
try {
const pageProps = await NextApp.getInitialProps(context);
if (!context.ctx.req) return pageProps;
const host = context.ctx.req.headers.host; // Unvalidated user input
const configData = await fetch(`http://${host}/api/config`) // Direct usage in URL construction
.then(res => res.json()) as GetConfigRes;
return {
...pageProps,
config: configData.data
};
} catch (error) {
console.log(`Unable to fetch config data from http://${context?.ctx?.req?.headers?.host}/api/config`); // Error message leaks attempted URL
console.log(error);
return await NextApp.getInitialProps(context);
}
}Proof of Concept
Proof of Concept
Was this helpful?