In this article I will present you the latest major version π. I didn't do an article on version 4 and 5 because they didn't introduce new features (only breaking changes on the API).
π’ What is JS-X-Ray ?
If you are new in town, JS-X-Ray is an open source JavaScript SAST (Static Application Security Testing). The tool analyzes your JavaScript sources for patterns that may affect the security and quality of your project π.
Among the notable features:
Retrieving dependencies (CJS & ESM support) and detecting suspicious import/require.
Detecting unsafe RegEx.
Detecting obfuscated source (and provide hints on the tool used).
This class is able to follow all declarations, assignments and patterns (and those even through very obscure patterns).
constaA=Function.prototype.call;constbB=require;constcrypto=aA.call(bB,bB,"crypto");constcr=crypto.createHash;cr("md5");// weak-crypto warning is throw here
This allows us to implement Probes in a much simpler way (which makes maintenance and testing much easier).
By default the Tracer follows all ways of requiring dependencies with CJS and also usage of eval or Function.
π§ Removing unsafe-assign warning
This warning was required at the beginning of the project because it was difficult for me to correctly identify some malicious patterns.
However, with the introduction of the new Tracer, which is very complete and precise, this warning no longer makes sense has it only generates unnecessary noise and false positives.
π Better ESM source parsing
We previously had a lot of parsing-error warnings because the NodeSecure scanner failed to detect if the file was using either CJS or ESM.
That new version will automatically retry with ESM enabled if it fails with CJS.
π Reducing false positives
To continue the momentum of the previous sections. This version drops a lot of warnings and significantly improves others.
Reducing false positives for encoded-literal warning by introducing new way of detecting safe values.
Improve short-identifiers by also storing ClassDeclaration, MethodDefinition and Function parameters.
We are also introducing a new suspicious-file warning when a file contain more than 10 encoded-literal warnings to avoid having file with hundreds or thousands of warnings.
Of the 500 most popular NPM packages, we previously had 24k warnings with version 5. The latest version brings that number down to approximatively 5k warnings.
π¬ Improving coverage
A lot of work has been done to add unit tests on all the probes of the project. We are near 100% of coverage πͺ.
JavaScript & Node.js open-source SAST scanner. A static analyser for detecting most common malicious patterns π¬.
JavaScript AST analysis. This package has been created to export the Node-Secure AST Analysis to enable better code evolution and allow better access to developers and researchers.
The goal is to quickly identify dangerous code and patterns for developers and Security researchers. Interpreting the results of this tool will still require you to have a set of security notions.
Note I have no particular background in security. I'm simply becoming more and more interested and passionate about static code analysis. But I would be more than happy to learn that my work can help prevent potential future attacks (or leaks).
Goals
The objective of the project is to successfully detect all potentially suspicious JavaScript codes.. The target is obviously codes that are added or injected for malicious purposes..
Most of the time these hackers will try to hide the behaviour of their codes as much as possible to avoid beingβ¦