
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
nuxt-security
Advanced tools
[OWASP Top 10](https://cheatsheetseries.owasp.org/cheatsheets/Nodejs_Security_Cheat_Sheet.html#nodejs-security-cheat-sheet) module that adds a few security improvements in form of a customizable server middlewares to your Nuxt 3 application. All middlewar
OWASP Top 10 module that adds a few security improvements in form of a customizable server middlewares to your Nuxt 3 application. All middlewares can be modified or disabled if needed. They can also be configured to work only on certain routes. By default all middlewares are configured to work globally.
yarn add nuxt-security # yarn
npm i nuxt-security # npm
// nuxt.config.js
{
modules: [
"nuxt-security",
],
}
The module will configure for you several response headers with the values recommended by Helmet as well as two custom middlewares for rate and request size limiting.
If you wish to modify them you can do so from the configuration:
export interface CorsOptions {
origin?: '*' | 'null' | (string | RegExp)[] | ((origin: string) => boolean);
methods?: '*' | HTTPMethod[];
allowHeaders?: '*' | string[];
exposeHeaders?: '*' | string[];
credentials?: boolean;
maxAge?: string | false;
preflight?: {
statusCode?: number;
};
}
export type RequestSizeLimiter = {
maxRequestSizeInBytes: number;
maxUploadFileRequestInBytes: number;
};
export type RateLimiter = {
tokensPerInterval: number;
interval: string | number;
fireImmediately?: boolean;
};
export type MiddlewareConfiguration<MIDDLEWARE> = {
value: MIDDLEWARE;
route: string;
}
export type XssValidator = {
whiteList: Record<string, any>;
stripIgnoreTag: boolean;
stripIgnoreTagBody: boolean;
css: Record<string, any> | boolean;
} | {};
export type SecurityHeaders = {
crossOriginResourcePolicy: MiddlewareConfiguration<string> | boolean;
crossOriginOpenerPolicy: MiddlewareConfiguration<string> | boolean;
crossOriginEmbedderPolicy: MiddlewareConfiguration<string> | boolean;
contentSecurityPolicy: MiddlewareConfiguration<string> | boolean;
originAgentCluster: MiddlewareConfiguration<string> | boolean;
referrerPolicy: MiddlewareConfiguration<string> | boolean;
strictTransportSecurity: MiddlewareConfiguration<string> | boolean;
xContentTypeOptions: MiddlewareConfiguration<string> | boolean;
xDNSPrefetchControl: MiddlewareConfiguration<string> | boolean;
xDownloadOptions: MiddlewareConfiguration<string> | boolean;
xFrameOptions: MiddlewareConfiguration<string> | boolean;
xPermittedCrossDomainPolicies: MiddlewareConfiguration<string> | boolean;
xXSSProtection: MiddlewareConfiguration<number> | boolean;
};
export interface ModuleOptions {
headers: SecurityHeaders | boolean;
requestSizeLimiter: MiddlewareConfiguration<RequestSizeLimiter> | boolean;
rateLimiter: MiddlewareConfiguration<RateLimiter> | boolean;
xssValidator: MiddlewareConfiguration<XssValidator> | boolean;
corsHandler: MiddlewareConfiguration<CorsOptions> | boolean;
}
The default values are as follows:
security: {
headers: {
crossOriginResourcePolicy: {
value: "same-origin",
route: '',
},
crossOriginOpenerPolicy: {
value: "same-origin",
route: '',
},
crossOriginEmbedderPolicy: {
value: "require-corp",
route: '',
},
contentSecurityPolicy: {
value:
"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",
route: '',
},
originAgentCluster: {
value: "?1",
route: '',
},
referrerPolicy: {
value: "no-referrer",
route: '',
},
strictTransportSecurity: {
value: "max-age=15552000; includeSubDomains",
route: '',
},
xContentTypeOptions: {
value: "nosniff",
route: '',
},
xDNSPrefetchControl: {
value: "off",
route: '',
},
xDownloadOptions: {
value: "noopen",
route: '',
},
xFrameOptions: {
value: "SAMEORIGIN",
route: '',
},
xPermittedCrossDomainPolicies: {
value: "none",
route: '',
},
xXSSProtection: {
value: 0,
route: '',
},
},
requestSizeLimiter: {
value: {
maxRequestSizeInBytes: 2000000,
maxUploadFileRequestInBytes: 8000000,
},
route: '',
},
rateLimiter: {
// Twitter search rate limiting
value: {
tokensPerInterval: 150,
interval: "hour",
fireImmediately: true,
},
route: '',
},
xssValidator: {
value: {},
route: '',
},
corsHandler: {
value: {
origin: '*',
methods: ['GET','HEAD','PUT','PATCH','POST','DELETE'],
preflight: {
statusCode: 204
}
},
route: '',
}
}
npm run dev:prepare
to generate type stubs.npm run dev
to start playground in development mode.FAQs
🛡️ Security Module for Nuxt based on HTTP Headers and Middleware
The npm package nuxt-security receives a total of 47,145 weekly downloads. As such, nuxt-security popularity was classified as popular.
We found that nuxt-security demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.