InspectJS: Leveraging Code Similarity and User-Feedback for Effective Taint Specification Inference for JavaScript

Saikat Dutta, Diego Garbervetsky, Shuvendu K. Lahiri, Max Schäfer

Abstract

InspectJS is an automated framework designed to infer taint specifications for JavaScript libraries, addressing the scalability challenges of manual security modeling. By integrating probabilistic inference with transformer-based code similarity and a human-in-the-loop feedback mechanism, InspectJS effectively identifies security sinks while minimizing manual triage effort. Experimental results demonstrate that InspectJS can reduce the manual workload by up to 3x and has successfully identified hundreds of previously unmodeled sinks in popular libraries.

Introduction

Static taint analysis is a fundamental technique for identifying security vulnerabilities by tracking the flow of untrusted data from sources to sensitive sinks. A vulnerability exists if data reaches a sink without passing through a sanitizer.

Basic taint flow model consisting of source (src), sanitizer (san), and sink (snk).

In the rapidly expanding JavaScript ecosystem, manually creating taint specifications for thousands of libraries is increasingly impractical. While machine learning approaches have been proposed to automate this process, they often suffer from high false-positive rates, overwhelming security engineers. InspectJS aims to bridge this gap by combining automated inference with intelligent refinement and user feedback.

The InspectJS Pipeline

InspectJS implements a multi-stage pipeline built upon the GitHub CodeQL analysis framework to automate the discovery and refinement of security sinks.

The InspectJS pipeline, integrating Seldon* inference, similarity-based refinement, and human feedback.

1. Probabilistic Inference (Seldon*)

The first stage utilizes an adapted version of the Seldon algorithm. By mining approximately 200,000 GitHub projects from LGTM.com, the tool identifies "triples" of sources, sanitizers, and sinks. It uses probabilistic inference to predict likely sinks based on their usage patterns relative to known security components.

2. Similarity-Based Refinement

To reduce noise, InspectJS employs GraphCodeBERT, a transformer model trained on code structure. This refiner compares predicted sinks against a corpus of known, manually-modeled sinks. Predictions that are syntactically and contextually similar to established sinks receive a confidence boost, helping to distinguish legitimate sensitive functions from harmless ones.

3. Feedback-Driven Refinement

The final stage incorporates a human-in-the-loop approach. A specialized UI allows security engineers to triage predictions. A key innovation is the "ban similar" feature: when a user identifies a false positive, the system automatically suppresses other predictions with high syntactic similarity, exponentially speeding up the manual review process.

Experimental Evaluation

The researchers evaluated InspectJS focusing on three major vulnerability classes: TaintedPath (562 projects), Cross-Site Scripting (2,834 projects), and NoSQL Injection (833 projects).

Key Results

  • Discovery of New Sinks: InspectJS identified 56 new true-positive sinks for TaintedPath and 187 for NoSQL Injection that were missing from standard CodeQL models.
  • Efficiency Gains: The combination of similarity-based filtering and the "ban similar" feedback mechanism reduced the manual steps required for triage by approximately 3x. For instance, NoSQL Injection triage steps were reduced from 666 to 243.
  • High Recall: The tool demonstrated the ability to recover a high percentage of alerts found in the latest manual versions of security queries, indicating its effectiveness in anticipating expert manual work.

Conclusion and Future Work

InspectJS demonstrates that combining probabilistic machine learning with deep code embeddings and interactive feedback can significantly alleviate the burden of taint specification. While highly effective, challenges remain in areas like XSS, where harmless UI functions often mimic dangerous sinks. Future research will focus on extending the framework to infer source and sanitizer specifications and exploring abductive inference to further refine library models.

Summary updated

BibTeX
@inproceedings{dutta2022inspectjs,
  author = {Saikat Dutta and Diego Garbervetsky and Shuvendu K. Lahiri and Max Schäfer},
  title = {{InspectJS: Leveraging Code Similarity and User-Feedback for Effective Taint Specification Inference for JavaScript}},
  booktitle = {ICSE (SEIP)},
  year = {2022},
  doi = {10.1109/icse-seip55303.2022.9794015},
}
Figure