NodeSecure / NodeSecure/js-x-ray

Optional warning for crypto API misuse detection

Open
#506 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help wanted
Dominant language
TypeScript
Stars
287
Forks
43
Avg merge
16h 34m
Merged PRs (30d)
19

Description

Implement a new optional warning and probe to detect usage of Node.js crypto APIs that could lead to security vulnerabilities, particularly around incorrect hash generation and weak cryptographic practices.

Proposed approach:

Add detection for potentially insecure usage of the following crypto methods:

Password hashing functions:

  • crypto.argon2()
  • crypto.bcrypt()
  • crypto.scrypt()
  • crypto.pbkdf2() / crypto.pbkdf2Sync()

Insecure random generation:

  • Math.random() used for security-sensitive operations (instead of crypto.randomBytes())

Note: This list should be expanded by reviewing the Node.js crypto documentation to ensure comprehensive coverage.

Examples:

// Should trigger warning - insufficient iterations for pbkdf2
crypto.pbkdf2(password, salt, 1000, 64, 'sha512', callback);

// Should trigger warning - insecure random for tokens
const token = Math.random().toString(36);

// Should NOT trigger warning - proper usage
crypto.scrypt(password, salt, 64, (err, derivedKey) => {
  // proper implementation
});

Detection criteria:

The probe should identify:

  1. Insufficient iteration counts for key derivation functions
  2. Missing or weak salt generation
  3. Use of non-cryptographic random functions for security contexts

Expected behavior:

Emit warnings with severity levels:

  • Warning Weak parameters (low iteration counts)
  • Information Potential misuse requiring manual review

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files, tests, or entry points. Start by reviewing the Node.js crypto documentation and define coverage for the listed APIs, then verify that weak parameters, salts, and non-cryptographic randomness produce the specified warning or information messages.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
security
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.