Back to skill

Security audit

NestJS Development Guide

Security checks for vulnerabilities and agentic risk

Overview

This NestJS guide is mostly coherent, but it includes copy-pasteable setup and production-sensitive configuration examples that are under-scoped enough to warrant Review before installation.

Install only if you are comfortable treating this as a developer reference, not production-ready security guidance. Pin npm package versions, avoid global installs when possible, do not use TypeORM `synchronize: true` outside disposable local development, and replace permissive CORS examples with explicit trusted origins before deployment.

Vulnerability Patterns
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
Findings (3)

T08 · Insecure Dependencies

Warning
Location
SKILL.md:19
Finding

Unpinned npm CLI Installation and Execution

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 19-24
Vulnerability Type: Unpinned third-party package execution
Risk Level: Medium

Vulnerable Code

bash
npm i -g @nestjs/cli
nest new my-project
cd my-project && npm run start:dev
text
Or use `npx @nestjs/cli@latest new my-project` to avoid global installation.

Technical Analysis

The guide instructs users to install @nestjs/cli globally without an exact version or to download and execute the mutable latest release through npx. npm packages and their lifecycle scripts execute with the privileges of the invoking user. The latest tag can change after the Skill has been reviewed, so the effective code executed by this procedure is not fixed by the audited content.

Although @nestjs/cli is a purpose-appropriate dependency and there is no evidence that its current releases are malicious, this pattern unnecessarily exposes users to registry compromise, maintainer-account compromise, malicious release replacement, and unexpected behavior introduced by future versions. A global installation also increases the persistence and system-wide availability of the installed executable.

Attack Path

  1. An attacker compromises the npm package, a maintainer account, the registry delivery path, or a release referenced by the mutable latest tag.
  2. A user or Agent follows the Quick Start instructions.
  3. npm resolves and downloads the compromised or unexpectedly changed release.
  4. npm lifecycle scripts or CLI initialization code execute locally.
  5. The package operates with the invoking user's privileges and can access resources available to that account.

Impact Assessment

Successful exploitation could execute arbitrary code as the invoking user. This may expose source code, environment variables, npm credentials, SSH material, and other files accessible to that account. It could also modify generated projects ...[truncated 229 chars]

Remediation
View remediation

Remediation Suggestions

  • Replace mutable or unversioned commands with a reviewed exact version, such as npx @nestjs/cli@<reviewed-exact-version> new my-project.
  • Prefer a project-local development dependency over a global installation.
  • Generate and commit a lockfile, and use deterministic installation commands such as npm ci for existing projects.
  • Review package provenance, release signatures or attestations, and registry configuration before execution.
  • Avoid running npm installation or initialization commands with administrative privileges.
  • Document a controlled upgrade process instead of relying on the latest distribution tag.

T09 · Insecure Skill Coding Practices

Error
Location
SKILL.md:337
Finding

Automatic TypeORM Schema Synchronization Presented Without a Production Warning

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, line 337
Vulnerability Type: Unsafe database schema-management configuration
Risk Level: High

Vulnerable Code

ts
TypeOrmModule.forRoot({ type: 'postgres', host: 'localhost', database: 'mydb', autoLoadEntities: true, synchronize: true })

Technical Analysis

TypeORM's synchronize: true option automatically reconciles the connected database schema with application entity metadata during startup. This behavior bypasses an explicit, reviewed migration process. Depending on entity changes and the database state, synchronization can add, alter, or remove schema objects and may cause destructive or incompatible changes.

The example does not constrain this option to disposable development databases and does not warn readers against using it in staging or production. As a result, an Agent or developer may copy the configuration into an environment containing persistent data.

Attack Path

  1. A developer or Agent copies the documented TypeORM configuration into an application.
  2. The application is configured to connect to a persistent staging or production database.
  3. Entity definitions are changed, removed, or interpreted differently after an application update.
  4. The application starts with a database account that has schema-modification privileges.
  5. TypeORM automatically attempts to reconcile the database schema, potentially applying unreviewed or destructive changes.

An attacker who can influence deployed entity definitions or application artifacts could amplify this configuration weakness by introducing schema changes that are applied automatically at startup. Such influence is not established within the audited project, but automatic synchronization removes an important review boundary if that prerequisite is met.

Impact Assessment

The application does not gain privileges beyond those of its configured database account. Within tha ...[truncated 368 chars]

Remediation
View remediation

Remediation Suggestions

  • Set synchronize: false in the primary example and in every non-disposable environment.
  • Manage schema changes through version-controlled, reviewed TypeORM migrations.
  • If synchronization is demonstrated for local development, label it explicitly as development-only and gate it through a validated environment setting.
  • Use separate database credentials per environment and apply least privilege; production application accounts should not receive unnecessary schema-owner permissions.
  • Test migrations against production-like data before deployment.
  • Require backups and a verified rollback or restoration procedure before applying schema changes.
  • Add deployment checks that reject synchronize: true in staging and production configurations.

T09 · Insecure Skill Coding Practices

Warning
Location
references/api-reference.md:61
Finding

Permissive Cross-Origin Resource Sharing Configuration

Content
View full analysis

Vulnerability Details

File Location: references/api-reference.md, line 61
Vulnerability Type: Unrestricted CORS origin configuration
Risk Level: Medium

Vulnerable Code

ts
cors: true,              // or { origin: '*', methods: 'GET,POST' }

Technical Analysis

Enabling CORS without an explicit trusted-origin policy, or setting origin: '*', permits scripts hosted on arbitrary origins to read eligible API responses through a user's browser. CORS is not an authentication mechanism and does not by itself allow credentialed requests when wildcard origins are used, but unrestricted access can still expose public or bearer-token-accessible endpoints to untrusted web origins.

The reference presents the permissive setting without separating development and production behavior or explaining the need for an allowlist. The severity depends on the API's authentication, credential, token-storage, and response-handling design.

Attack Path

  1. A developer or Agent copies the permissive CORS example into a deployed API.
  2. A victim visits an attacker-controlled website.
  3. JavaScript on that site sends cross-origin requests to the API.
  4. The API returns permissive CORS headers.
  5. The browser allows the attacker's script to read responses that are otherwise available under the request's authentication context.

Exploitation involving cookies additionally requires a compatible credential configuration and cannot rely on a wildcard origin with credentialed CORS under standard browser enforcement. However, public endpoints, tokens deliberately attached by frontend code, or incorrectly combined dynamic-origin and credential settings may remain exposed.

Impact Assessment

This issue does not grant server or operating-system privileges. Its scope is limited to API operations and data available through the affected cross-origin requests. Depending on surrounding authentication controls, consequences ma ...[truncated 147 chars]

Remediation
View remediation

Remediation Suggestions

  • Replace wildcard behavior with an explicit allowlist of trusted production origins.
  • Maintain separate CORS policies for local development, testing, and production.
  • Validate origins using exact normalized matches rather than substring or permissive regular-expression checks.
  • Allow only the HTTP methods and headers required by the application.
  • Enable credentialed CORS only when necessary, and never combine it with a wildcard origin.
  • Add automated tests verifying that untrusted origins do not receive permissive CORS response headers.
  • Document that CORS does not replace authentication, authorization, CSRF protection, or secure token handling.
Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (3)

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · SKILL.md (reported line 351)May include surrounding context.

ts
// app.module.ts
ConfigModule.forRoot({ isGlobal: true, envFilePath: '.env' })

// Usage
constructor(private configService: ConfigService) {}

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

This markdown file defines invocation guidance using broad phrases such as "create API", "backend service", "guard", "pipe", and "interceptor", plus "etc.", without clear boundaries or exclusions. These terms are common across many frameworks and general software discussions, so the skill could be invoked unintentionally outside a clearly NestJS-specific context.

Content

No source excerpt is available for this finding.

Rp1

Medium
Category
MCP Rug Pull
Confidence
70% confidence
Finding

npx commands without a version suffix (e.g. @1.0.0) create a rug-pull risk if the upstream server is compromised and publishes a malicious update.

Content

No source excerpt is available for this finding.