Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
next-security
Advanced tools
Security plugin for Next.js based on OWASP and Helmet.
[Coming soon]
Content Security Policy (CSP) for SSG apps[Coming soon]
Request Size limiter[Coming soon]
Cross Site Scripting (XSS) Validation[Coming soon]
Cross-Origin Resource Sharing (CORS) support[Coming soon]
[Optional]
Allowed HTTP Methods, Basic Auth, CSRF, Rate LimiterInstall the plugin:
npm i next-security
yarn add next-security
pnpm add next-security
Add the plugin to the next.config.js
like following:
/** @type {import('next').NextConfig} */
const { nextSecurity } = require('next-security');
const nextConfig = {
...nextSecurity(),
};
module.exports = nextConfig;
Or, if you want to have more control over the source for the headers:
/** @type {import('next').NextConfig} */
const { generateSecurityHeaders } = require('next-security');
const nextConfig = {
async headers() {
return [
{
source: '/(.*)',
headers: generateSecurityHeaders(),
},
];
},
};
module.exports = nextConfig;
And that's it! The plugin will now register security response headers so that your application will be more secure.
If you inspect the headers that are being returned by the Next application in the browser, you should see the following result:
cross-origin-resource-policy: same-origin
cross-origin-opener-policy: same-origin
cross-origin-embedder-policy: require-corp
content-security-policy: base-uri 'self'; font-src 'self' https: data:; form-action 'self'; frame-ancestors 'self'; img-src 'self' data:; object-src 'none'; script-src-attr 'none'; style-src 'self' https: 'unsafe-inline'; upgrade-insecure-requests
origin-agent-cluster: ?1
referrer-policy: no-referrer
strict-transport-security: max-age=15552000; includeSubDomains
x-content-type-options: nosniff
x-dns-prefetch-control: off
x-download-options: noopen
x-frame-options: SAMEORIGIN
x-permitted-cross-domain-policies: none
x-xss-protection: 0
permissions-policy: camera=(), display-capture=(), fullscreen=(), geolocation=(), microphone=()
You can pass configuration to the plugin like following:
/** @type {import('next').NextConfig} */
const { nextSecurity } = require('next-security');
const nextConfig = {
...nextSecurity({
headers: {
xXSSProtection: '1',
crossOriginResourcePolicy: 'cross-origin',
contentSecurityPolicy: false,
},
}),
};
module.exports = nextConfig;
FAQs
Security plugin for Next.js based on OWASP and Helmet
The npm package next-security receives a total of 0 weekly downloads. As such, next-security popularity was classified as not popular.
We found that next-security demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.