Kiuwan logo

JavaScript static code analysis: How to find vulnerabilities before release

JavaScript-static-code-analysis-How-to-find-vulnerabilities-before-release-blog-image

JavaScript runs across browsers, servers, mobile applications, desktop applications, and cloud services. That reach makes JavaScript applications valuable targets for attacks against both proprietary code and open-source dependencies.

The scale of npm supply chain risk is especially difficult to ignore. Sonatype reported that it identified more than 454,600 new malicious open-source packages in 2025 across npm, PyPI, Maven Central, NuGet, and Hugging Face. More than 99% occurred on npm. The same report says the September 2025 Shai-Hulud worm compromised more than 500 packages. GitHub responded by removing more than 500 affected packages and introducing plans for stricter npm publishing controls.

Static code analysis helps teams identify insecure patterns, vulnerabilities, and quality issues without executing the application. For JavaScript projects, it should be paired with software composition analysis (SCA), linting, testing, and runtime security controls. No single scanning method covers every risk.

This guide explains what JavaScript static code analysis can detect, where its limits are, and how to add it to a development pipeline.

Key takeaways

  • Static application security testing (SAST) analyzes the JavaScript and TypeScript your team writes.
  • SCA inventories open-source packages and checks them for known vulnerabilities, license risks, and obsolescence.
  • ESLint is valuable for style, correctness, and selected security rules, but it does not replace a security-focused SAST tool.
  • JavaScript’s dynamic behavior and extensive dependency trees make layered analysis particularly important.
  • Run fast checks in the IDE and on pull requests, then use deeper scans and quality gates in CI/CD.
  • Kiuwan Professional combines SAST, SCA, SBOM generation, code quality, governance, CI/CD integration, and on-premise deployment.

Why JavaScript benefits from static code analysis

JavaScript is dynamically typed and does not require a compile-time type-checking step. TypeScript adds static types, but unsafe data flows, insecure API usage, and configuration problems can still pass type checks.

JavaScript applications also operate across several trust boundaries. Browser code processes user-controlled input and interacts with the Document Object Model (DOM). Node.js services handle files, databases, operating-system commands, network requests, and server-side packages. Data can move through callbacks, promises, middleware, templates, and framework abstractions before reaching a sensitive operation.

Static analysis can follow those paths and flag patterns associated with vulnerabilities such as:

  • Cross-site scripting (XSS)
  • SQL and NoSQL injection
  • Operating-system command injection
  • Path traversal
  • Insecure deserialization
  • Server-side request forgery
  • Hardcoded secrets or credentials
  • Unsafe dynamic execution through eval(), Function(), or related APIs
  • Prototype pollution, depending on the tool’s JavaScript rules and framework support

The dependency layer expands the risk. A package may bring dozens of transitive dependencies into an application, and vulnerabilities can remain hidden several levels below the package listed in package.json. That is why JavaScript projects need both SAST and SCA.

What JavaScript static code analysis detects

Static analysis tools inspect source code, configuration files, and dependency manifests without running the complete application. Different tools focus on different problem types, so it helps to separate SAST, SCA, and code quality analysis.

Vulnerabilities in JavaScript and TypeScript source code

Static application security testing evaluates the code your team writes. Security-focused tools look for unsafe sources, data flows, sanitization gaps, and dangerous sinks.

Examples include:

  • User-controlled input reaching a database query without proper parameterization
  • Untrusted data rendered into HTML without appropriate output encoding
  • File paths built from request data without validation
  • Commands constructed from untrusted strings
  • Weak authentication or authorization checks
  • Insecure cryptographic choices
  • Secrets embedded directly in source code

More advanced SAST tools use interprocedural or cross-file analysis to trace data through multiple functions, modules, or application layers. Results still depend on the tool’s language and framework support, so teams should test representative repositories before buying.

Risks in npm and other open-source dependencies

SAST and SCA solve different problems. SAST analyzes proprietary source code. Software composition analysis identifies open-source components and evaluates associated risks.

An SCA tool may provide:

  • Direct and transitive dependency inventories
  • Known vulnerability and CVE matching
  • Affected and fixed version information
  • Open-source license identification
  • Component obsolescence data
  • Continuous alerts when new vulnerabilities affect existing applications
  • Software bill of materials (SBOM) generation

Known-vulnerability detection is not the same as identifying every malicious package. Traditional SCA is strongest when a package or version already has vulnerability intelligence associated with it. Detecting a newly published malicious package may require additional behavioral analysis, repository controls, or specialized malware intelligence.

This distinction matters in incidents such as Shai-Hulud. A package can be compromised and republished before it receives a CVE. Teams should combine SCA with locked dependency versions, trusted publishing, multifactor authentication, controlled registries, and review of unexpected package or maintainer changes.

Code quality issues that increase security risk

Not every code quality issue is a vulnerability. However, high complexity, duplication, dead code, and unclear control flow can make security review and remediation harder.

Code quality analysis can identify:

  • High cyclomatic or cognitive complexity
  • Duplicated code
  • Unreachable or unused code
  • Error-handling gaps
  • Maintainability problems
  • Coding-standard violations
  • Accumulated technical debt

These findings help teams focus on refactoring work and reduce the amount of difficult-to-review code. They should be prioritized separately from confirmed security vulnerabilities so developers understand which issues create direct security exposure and which affect long-term maintainability.

What static analysis cannot find by itself

Static analysis is valuable, but it does not observe the application behaving in production. Some issues require other testing methods.

Examples include:

  • Authentication or authorization flaws that depend on runtime state
  • Business-logic abuse
  • Vulnerabilities introduced by server, proxy, browser, or cloud configuration
  • DOM behavior that depends on data assembled dynamically at runtime
  • Third-party services or APIs that behave differently from their declared interfaces
  • Runtime-only dependency loading
  • Vulnerabilities in deployed infrastructure or container images

Use dynamic application security testing, API testing, penetration testing, container scanning, runtime monitoring, and manual review where those risks apply.

How to add JavaScript static analysis to CI/CD

JavaScript code analysis is most useful when feedback arrives at the right stage. A single deep scan at the end of a release creates a backlog; a layered pipeline catches new issues while preserving broader coverage.

1. Start in the IDE

Use linting and security analysis while code is being written. Fast feedback helps developers correct straightforward issues before committing them and reduces noise later in the pipeline.

2. Scan pull requests

Run SAST, SCA, and tests on each pull request. Focus the review on new or changed code so legacy findings do not obscure the risk introduced by the current change.

3. Create a baseline

Scan the existing application before enforcing a quality gate. Classify or suppress accepted findings and create a remediation plan for the backlog. Without a baseline, the first gated build may fail because of unrelated historical issues.

4. Define quality gates

Set thresholds based on risk and context. For example, block new critical vulnerabilities, hardcoded secrets, or prohibited licenses while allowing lower-priority findings to enter a tracked remediation queue.

Avoid treating every scanner alert as equally urgent. A useful gate accounts for severity, confidence, exploitability, application exposure, and whether the vulnerable code path is reachable.

5. Scan dependencies continuously

A dependency can become vulnerable after it is merged. Monitor deployed and maintained applications so teams receive alerts when new vulnerability data affects an existing package version.

6. Customize rules carefully

Use custom rules and exclusions to reflect organizational policies and application architecture. Document why rules are changed, and review suppressions regularly. Excessive tuning can hide risk just as easily as it can reduce false positives.

7. Track ownership and remediation

Route findings to the team that owns the affected application. Track time to triage, time to remediate, reopened issues, accepted risk, and repeated vulnerability classes. Scanner volume alone does not show whether risk is decreasing.

How Kiuwan analyzes JavaScript applications

Kiuwan supports more than 30 programming languages, including JavaScript. Its Professional plan combines proprietary-code analysis, open-source dependency analysis, code quality, and portfolio governance.

Kiuwan Code Security for JavaScript SAST

Kiuwan Code Security analyzes source code for vulnerability classes including injection, XSS, cross-site request forgery, broken authentication, insecure cryptography, access-control flaws, and security misconfigurations.

Teams can:

  • Review remediation guidance with findings
  • Customize rules and quality models
  • Map findings to standards and classifications including OWASP, CWE, PCI DSS, CERT, MISRA, and SANS
  • Analyze code in supported IDEs
  • Add scans and quality gates to CI/CD pipelines
  • Export SARIF reports

Kiuwan Insights for npm dependency analysis

Kiuwan Insights scans open-source and third-party components against sources including the NIST National Vulnerability Database. It identifies known vulnerabilities, licenses, component obsolescence, and transitive dependencies.

Insights can also generate a CycloneDX SBOM containing components, licenses, dependencies, and known vulnerabilities. SBOMs improve inventory and auditability, but they must be regenerated as dependencies change.

Code quality and governance

Kiuwan Professional includes code quality and portfolio-level governance. Teams can compare applications, monitor trends, quantify technical debt, and prioritize remediation across a software portfolio.

Kiuwan also maps findings and reporting to standards and quality models including ISO/IEC 25000. That does not certify an application as compliant, but it can reduce the manual work required to organize evidence for security and quality reviews.

IDE, CI/CD, and deployment options

Kiuwan supports IDE integrations for Visual Studio, VS Code, Eclipse, and JetBrains environments. Its published CI/CD options include Jenkins, Azure DevOps, and GitLab CI, with command-line support for other workflows such as GitHub Actions, CircleCI, and TeamCity.

Teams can analyze code in the cloud or use the Kiuwan Local Analyzer when code must remain within their environment. Results can synchronize with the cloud dashboard or remain on premises, depending on the chosen architecture. Confirm data residency and hosting requirements during implementation rather than assuming local scanning and fully self-hosted deployment are identical.

Kiuwan’s current pricing places SAST for one language and basic compliance reporting in Starter. Professional adds 30+ languages, SCA, SBOM generation, code quality, governance, CI/CD integration, and on-premise deployment.

ESLint vs. SAST vs. SCA

JavaScript projects benefit from all three because they answer different questions.

Tool typePrimary questionExamples of findingsMain limitation
ESLint and related lintersDoes this code follow defined syntax, style, and correctness rules?Unused variables, risky patterns, inconsistent code, selected security rulesDoes not provide full security data-flow or dependency analysis
SASTCan data or control flow through proprietary code create a vulnerability?XSS, injection, unsafe API use, path traversal, hardcoded secretsDoes not inventory all open-source dependency risk or observe runtime behavior
SCAWhich open-source components are present, and what known risks do they carry?Known CVEs, license issues, obsolete components, transitive dependenciesDoes not find business-logic flaws or vulnerabilities in proprietary code

Run linting first because it is fast. Use SAST to analyze proprietary code and SCA to evaluate imported components. Add dynamic and manual testing for behavior that static tools cannot observe.

Build a layered JavaScript security program

JavaScript security is not only a source-code problem or only a dependency problem. Teams need visibility into the code they write, the packages they import, and the behavior of the deployed application.

Start with linting, SAST, and SCA in the development pipeline. Baseline existing applications, gate new high-risk issues, monitor dependencies continuously, and add dynamic or manual testing for runtime and business-logic risks.

Kiuwan gives teams a coordinated way to analyze JavaScript source code and npm dependencies while connecting findings to code quality, governance, and compliance reporting. Start a free 14-day Kiuwan trial to evaluate it against your own repositories and CI/CD workflows.


FAQ

What is JavaScript static code analysis?

JavaScript static code analysis examines JavaScript or TypeScript source code without running the complete application. It identifies security vulnerabilities, risky patterns, quality issues, and coding-standard violations before release.

Can static analysis find XSS vulnerabilities?

Yes. Security-focused SAST tools can identify paths where untrusted data reaches HTML, templates, or browser APIs without appropriate validation or output encoding. Results depend on the tool’s framework and data-flow support, so dynamic testing should still cover runtime behavior.

Is ESLint a SAST tool?

ESLint is primarily a linting platform. Security plugins can identify selected risky patterns, but ESLint does not replace a security-focused SAST tool with deeper cross-function or cross-file data-flow analysis.

What is the difference between SAST and SCA for JavaScript?

SAST analyzes the JavaScript and TypeScript your team writes. SCA inventories npm and other open-source dependencies and checks them for known vulnerabilities, license obligations, and obsolescence. Most JavaScript applications need both.

Can SCA detect malicious npm packages?

Some SCA and supply chain security products include malicious-package intelligence, but standard SCA is strongest at identifying known component vulnerabilities and license risks. Newly published malware may not yet have a CVE, so teams should also use repository controls, trusted publishing, locked dependencies, and additional malware detection where required.

Does Kiuwan support JavaScript and npm?

Yes. Kiuwan Code Security provides JavaScript SAST, while Kiuwan Insights analyzes supported open-source dependencies for known vulnerabilities, licenses, obsolescence, and transitive relationships. Professional includes SAST, SCA, CycloneDX SBOM generation, code quality, governance, CI/CD integration, and on-premise deployment.

In This Article:

Request Your Free Kiuwan Demo Today!

Get Your FREE Demo of Kiuwan Application Security Today!

Identify and remediate vulnerabilities with fast and efficient scanning and reporting. We are compliant with all security standards and offer tailored packages to mitigate your cyber risk within the SDLC.

Related Posts

CI/CD security: How to secure your pipeline

CI/CD security: How to secure your pipeline

CI/CD pipelines connect to many of an organization’s most sensitive assets, including source code, credentials, build systems, artifact registries, and production environments. That access makes automated delivery possible, but it…
Read more
JavaScript static code analysis How to find vulnerabilities before release
© 2026 Kiuwan. All Rights Reserved.