
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
nestjs-api-keys
Advanced tools
A NestJS API keys utility which allows you to secure APIs using an API Key based system.
This library only works in APIs made with NestJS.
Install the package using:
npm i nestjs-api-keys
or
yarn add nestjs-api-keys
First, you need to register the ApiKeysModule. You can do that by going to your AppModule and calling the register static method of the ApiKeysModule class:
@Module({
imports: [
ApiKeysModule.register({
apiKeys: [],
}),
],
})
export class AppModule {}
In the apiKeys array you need to provide all available API Keys.
ApiKeysModule.register({
apiKeys: [
{
name: 'For reading users', // Descriptive name
keys: ['supersecretapikey'], // API keys composing this key
permissions: ['users.read'], // Permissions given to this key
},
],
}),
REMEMBER: it is recommended that you DON'T provide directly here these values in production. You should get keys from a .ENV file or any other secure source.
In production you should (for example):
ApiKeysModule.register({
apiKeys: JSON.parse(process.env.API_KEYS_JSON_STRING),
}),
You can secure any endpoint by using the ApiKeyGuard guard:
@UseGuards(
ApiKeyGuard({
permissions: ['users.read'],
}),
)
@Get('users')
async getUsers() {
// Fetch users
}
FAQs
A NestJS utility that allows API keys based security
The npm package nestjs-api-keys receives a total of 10 weekly downloads. As such, nestjs-api-keys popularity was classified as not popular.
We found that nestjs-api-keys demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.