Skip to main content

A static analysis framework for JavaScript vulnerability detection

Project description

probejs

probejs is a static analysis tool for JavaScript and TypeScript that detects taint-style vulnerabilities via Object Property Graph (OPG) construction and flow-based trace rules. Its canonical machine-readable output is report.json.

Overview

probejs is a JavaScript static analysis framework that:

  • Generates Object Property Graphs (OPG) from JavaScript source code
  • Statically tracks object property flows by simulating assignments, property accesses, and function calls
  • Detects taint-style vulnerabilities including:
    • OS command injection
    • Cross-site scripting (XSS)
    • Code execution vulnerabilities
    • Prototype pollution
    • Internal property tampering
    • Path traversal
    • NoSQL injection
  • Emits structured JSON bug reports with source snippets, path diagnostics, and trace rule evaluations
  • Exports analysis results to CSV/TSV format for further processing
  • Supports npm package analysis

Architecture

See docs/ARCHITECTURE.md for detailed architecture information.

Installation

System Requirements

  • Node.js and npm: Required for JavaScript/TypeScript AST parsing (automated setup)
  • Python 3.8+: Required for the core analysis engine

From PyPI (Recommended)

pip install probejs

On first run, the tool will automatically install its JavaScript dependencies into ~/.cache/probejs/parser/ via npm install. You can also trigger this step manually ahead of time:

probejs-setup                # or: python -m probejs setup

From Source (Development)

git clone <repository-url>
cd probejs

# Install Python package in editable mode
pip install -e .

# Install JavaScript parser dependencies
cd probejs/_parser && npm install && cd ../..

# Verify
python -m probejs input.js

Or use the provided installation script:

./install.sh

Python Dependencies

  • networkx (~=2.4): Graph data structure library
  • z3-solver (~=4.8.8.0): Heuristic path feasibility check (used only with -X flag)
  • sty (~=1.0.0rc0): Terminal styling and formatting
  • func_timeout (~=4.3.5): Function timeout handling
  • tqdm (~=4.48.2): Progress bars for long-running operations

JavaScript Dependencies

The JavaScript parser scripts are bundled with the Python package and installed lazily via npm on first use (or via probejs-setup). They include:

  • esprima (^4.0.1): JavaScript parser for AST generation
  • typescript (^5.9): TypeScript/TSX lowering and project configuration support
  • source-map (^0.6.1): Original TypeScript source location mapping
  • commander (^3.0.2): Command-line interface utilities
  • ansicolor (^1.1.84): Terminal color formatting

Quick Start

# Analyze a JavaScript or TypeScript file
python -m probejs input.js
python -m probejs input.ts

# Analyze a TypeScript project directory
python -m probejs ./src

# Parse TypeScript supplied on stdin
printf 'const value: string = process.argv[2];' | python -m probejs --typescript -

# Analyze with specific vulnerability type
python -m probejs -t os_command input.js

# Emit a canonical JSON report
python -m probejs --json -t os_command input.js

# Check for prototype pollution
python -m probejs -P input.js

# Disable JS-modeled stubs in builtin_packages/
python -m probejs --no-builtin-packages input.js

When --json is passed, the JSON report is written to the run log directory as:

  • report.json: structured bug report with source snippets, path diagnostics, and trace rule evaluations
  • report.schema.json: schema for the report format

See docs/USAGE.md for detailed usage instructions, examples, and advanced configuration.

TypeScript support

TypeScript files (.ts, .tsx, .mts, and .cts) and ArkTS .ets files are automatically lowered to CommonJS before the existing JavaScript AST pipeline runs. The frontend:

  • removes type-only syntax while preserving runtime behavior
  • converts ES module imports/exports to the existing module-analysis representation
  • follows transitive TypeScript imports
  • compiles the nearest tsconfig.json as a project, including project references
  • resolves baseUrl/paths, package exports/imports, and workspace packages
  • maps AST locations and reports back to the original TypeScript source
  • lowers TSX and modern JavaScript syntax to parser-compatible JavaScript
  • models tslib interop/decorator helpers and uses declaration signatures to identify callback arguments
  • normalizes common ArkTS component syntax (struct, state/component decorators, and declarative UI blocks) and treats @Entry build bodies as analysis entrypoints
  • prefers the project's installed TypeScript compiler and records compiler diagnostics/version information in report.json
  • recognizes callback properties in typed options objects and common Fastify, NestJS, EventEmitter, Commander, Yargs, worker, and serverless entrypoints
  • reads HarmonyOS build-profile.json5, module.json5, and oh-package.json5 project metadata
  • consumes existing external or inline JavaScript source maps when analyzing generated CommonJS

Declaration files (.d.ts, .d.mts, and .d.cts) are not emitted as runtime files, but their signatures inform callback and promise metadata. Common generated/dependency directories are skipped during directory analysis. Type errors do not prevent emission because probejs analyzes runtime flows.

Experimental: PoC generation utilities. The directories pocgen/ and skills/probejs-poc-generation/ contain experimental utilities that consume report.json to assist with proof-of-concept generation. These are separate from the core analysis pipeline and currently rely on LLM-based coding agents (e.g., Codex, Claude) rather than automated symbolic reasoning.

Documentation

  • Architecture: Detailed architecture, how it works, and output format
  • Usage Guide: Command-line options, canonical JSON reporting, programmatic usage, and examples
  • Vulnerability Types: Detailed information about each vulnerability type with examples
  • Troubleshooting: Limitations, common issues, debugging tips, and references
  • PoC Generation Workflows: Difference between the interactive skill and automated runner approaches
  • PoC Skill: Agent skill for turning report.json findings into runnable PoCs

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

probejs-1.0.0.tar.gz (203.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

probejs-1.0.0-py3-none-any.whl (220.0 kB view details)

Uploaded Python 3

File details

Details for the file probejs-1.0.0.tar.gz.

File metadata

  • Download URL: probejs-1.0.0.tar.gz
  • Upload date:
  • Size: 203.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for probejs-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f3ee3a16652046d2aedebf44b400131bea9d2540563259e2f5ede9701b2a43ac
MD5 80ce6fac361eb96eac2565391dda939c
BLAKE2b-256 915e0a3f98e13fba5172d0c854ece3ac54181c0178fa98363a16a61f76c3f168

See more details on using hashes here.

File details

Details for the file probejs-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: probejs-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 220.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for probejs-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 18ed56f071c4f9280da844f2af80c2fae72c311fb79eda7c272c53f9d6290864
MD5 f1ff6f95813cf76e44809b8e71d0f5fb
BLAKE2b-256 a51c166abe2b87a563bec28ba8dd1a0fb71473d3671565ea22a7f36755fefc15

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page