> ## Documentation Index
> Fetch the complete documentation index at: https://loadwise.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Security assurance

> What Loadwise promises about its own security, the threats it is designed against, and the controls that back each claim.

This page is the assurance case for Loadwise itself, not for the code it scans. Report a vulnerability through [SECURITY.md](https://github.com/loadwise-dev/loadwise/blob/main/SECURITY.md).

## Security requirements

What you can expect:

1. **Local analysis.** Scans read and parse files on your machine or CI runner. Source code, project paths and lockfiles are not uploaded.
2. **Network only when you ask for it.** A scan makes no network request unless you opt in:
   * `--online` sends pinned package names, ecosystems and versions to OSV, or to `LOADWISE_OSV_URL`, which must be an HTTPS origin or a loopback HTTP origin (`lib/security/deps/osv.ts`).
   * Crash reporting (`--report-crashes`, `LOADWISE_CRASH_REPORTS=1` or `LOADWISE_SENTRY_DSN`) sends a sanitized report without exception messages, source or project paths (`lib/shared/system/sentry.ts`).
   * Separate commands that you run by name also use the network: `loadwise perf db` connects to the database named in your environment, and `loadwise editor setup` downloads the editor package from GitHub Releases and checks its SHA-256 digest and size against the release metadata (`lib/editor/release-vsix.ts`).
3. **Scans do not execute the scanned project.** The checkers parse files with the TypeScript compiler API, `@astrojs/compiler`, `libpg-query`, `yaml` and the bundled `@ast-grep/cli` binary with Loadwise's own rules. They do not run the project's scripts, tests or build. Config files are read as JSON or JSONC, and rule packs are versioned JSON data. These documented exceptions load code from the project's own `node_modules`:
   * `loadwise fix`, when it writes edits, formats them with the project's installed Prettier, which also resolves the project's Prettier config. Biome is used only with `LOADWISE_ALLOW_BIOME=1`, and only from a binary inside the project root (`lib/shared/fix/fix-presentation.ts`, `fix-presentation-biome.ts`). `--no-format` turns formatting off.
   * `loadwise perf db` loads the project's `pg`, `mysql2`, `mongodb` or `mongoose` driver (`lib/performance/db/drivers.ts`).
4. **Writes only on request.** `loadwise fix` previews by default. It writes only with an edit mode (`--apply`/`--yes`, `--id`, `--all`, or approval in `--interactive`), and every write to a project file stays inside the project root (`lib/shared/fix/project-file-access.ts`). The fix history that `loadwise fix` records for undo is written outside the project, under the user's state directory (`LOCALAPPDATA` or `XDG_STATE_HOME`), by `lib/shared/fix/fix-history.ts`.
5. **Another local user cannot plant a cached result.** On POSIX systems, a cache directory or entry that another user owns or could write is ignored (see below). On Windows, where file stats carry no owner or permission bits, the cache is used only when its resolved folder lies inside the user's profile or `LOCALAPPDATA` and no folder on the path is a junction or symbolic link. Any other `LOADWISE_SCAN_CACHE_ROOT` turns the cache off for that run, with a note.

What you cannot expect: Loadwise does not sandbox the project tools listed in point 3, and it does not guarantee that a scan finds every vulnerability. A missed or false finding is a bug, not a vulnerability ([SECURITY.md, Scope](https://github.com/loadwise-dev/loadwise/blob/main/SECURITY.md#scope)).

## Threat model and trust boundaries

| Boundary | Untrusted input | Threat |
| - | - | - |
| Scanned repository → Loadwise | Source, markup, lockfiles, workflows, symlinks, file names, Git refs | Path escape on write, command injection, parser crashes or hangs, code execution |
| Project config → Loadwise | `loadwise.config.json(c)`, `extends`, rule packs, ignore globs | Reading or writing outside the project, ReDoS, prototype pollution |
| Local file system → Loadwise | Scan cache directory and entries, fix history | Another local user planting cached results or redirecting writes through links |
| Network → Loadwise (opt-in only) | OSV responses, GitHub release metadata | Malformed or tampered responses |
| Loadwise supply chain → user | npm package, VSIX, GitHub Action, dependencies | Tampered release, compromised dependency or workflow |

The user running Loadwise, the Loadwise package as installed, and the project's own installed tools (point 3) are trusted.

## Secure design principles applied

* **Least privilege.** Every workflow sets top-level `permissions` (most `contents: read`, Scorecard `read-all`) and raises them per job only where needed, for example `id-token: write` only in the npm stage and GitHub release jobs of `.github/workflows/release.yml`. Checkouts use `persist-credentials: false`.
* **Fail-safe defaults.** Network features are off by default, `fix` previews by default, and an untrusted cache is bypassed rather than used.
* **Complete mediation of writes.** All `--fix` writes to project files go through `project-file-access.ts`, which checks every path against the project root after resolving links and writes atomically. The check and the write are separate path operations, so they do not stop another local process that swaps a folder in the project between them.
* **Separation.** Checkers run in child processes (`lib/shared/reporting/pillars.ts`) with bounded output (`maxOutputBytes`). When several source checkers are selected they share one child, so a failure there fails all of them.
* **Economy of mechanism.** One glob dialect (`lib/shared/system/glob.ts`) and one JSONC reader (`lib/shared/system/jsonc-config.ts`) serve all config parsing.
* **Separation of duty in releases.** The workflow can only stage an npm publish; a maintainer approves it on npmjs.com with 2FA.

## Common weaknesses and how they are countered

| Weakness | Counter-measure |
| - | - |
| Path traversal (CWE-22), link following (CWE-59) | Fix writes are checked with `isPathInside` after resolving real paths (`lib/shared/fix/project-file-access.ts`). Rule packs must be relative, stay inside the config directory and are opened with `O_NOFOLLOW` (`lib/shared/declarative-rule-packs.ts`). `extends` must name a relative local file (`lib/shared/config.ts`). Cache entries are opened with `O_NOFOLLOW` and must be regular files with one link (`lib/shared/analysis/scan-cache-storage.ts`). |
| OS command injection (CWE-78, CWE-88) | Child processes use `spawn`/`spawnSync` with argument arrays and no shell. `--changed-since` rejects refs that start with `-` (`lib/shared/changed-lines.ts`). Git runs for patches disable diff filters and set the attributes file (`lib/shared/fix/fix-patch.ts`). |
| ReDoS (CWE-1333) | User globs are compiled by `lib/shared/system/glob.ts`, which escapes regex metacharacters, collapses repeated `**/` and `***`, and caps brace nesting at 8. This does not remove backtracking between repeated `*` wildcards: a pattern such as `*a*a*a*a*a*a*a*ab` can make matching a long file name that does not match slow. |
| Prototype pollution (CWE-1321) | Config keys are read with `Object.hasOwn` and validated against known rules and sections, so inherited keys are ignored (`lib/shared/config.ts`). Rule packs reject duplicate keys. |
| Unsafe deserialization (CWE-502) | Config, rule packs, cache entries and network responses are parsed with `JSON.parse` or the `yaml` parser and then shape-checked (for example `isStoredRun` in `scan-cache.ts`). No `eval`, `new Function` or `node:vm` is used on input. |
| Uncontrolled resource use (CWE-400) | Rule packs are limited to 1 MiB and inherited editor config to 256 KiB. Child output is capped. Formatter and OSV requests have timeouts. |
| Insecure temporary or cache files (CWE-377, CWE-732) | Cache directories are created with mode `0700`. On POSIX systems, directories and entries owned by another user or writable by group or others are rejected (`trustedCacheDirectory`, `trustedCacheEntry`). On Windows, whose file stats lack owners and modes, the directory must resolve inside the user's profile or `LOCALAPPDATA` (ACLs are not read). |
| Download integrity (CWE-494) | `loadwise editor setup` verifies the VSIX SHA-256 digest and size against the GitHub release asset metadata before installing it. |

Property-based fuzz tests with `fast-check` in `test/shared/fuzz-properties.test.ts` cover the JSONC comment masking and check that `parseConfigFile` rejects arbitrary config text only with a plain `Error`.

## Supply-chain controls

* **Pinned actions.** Every third-party action in `.github/workflows/` and `action.yml` is pinned to a full commit SHA. Dependabot updates npm, Cargo and GitHub Actions dependencies weekly (`.github/dependabot.yml`).
* **npm provenance, no stored token.** `release.yml` publishes with npm Trusted Publishing through GitHub OIDC and `npm stage publish --provenance`, after checking the tarball's SHA-256 against the verified build. The version goes live only after maintainer approval with 2FA.
* **Signed release assets.** The editor packages get Sigstore-signed SLSA build provenance (`actions/attest-build-provenance`), attached as `loadwise-<version>.sigstore.json` and `.intoto.jsonl`. [Release signatures](https://loadwise.mintlify.site/release-signatures.md) shows how to verify them.
* **Release gates.** A tag publishes only from a commit on `main` whose `check`, `codeql` and `scorecard` runs passed (`main-ci-green` job). The release tags ruleset blocks moving or deleting `v*.*.*` tags.
* **CodeQL.** `.github/workflows/codeql.yml` analyzes JavaScript/TypeScript and GitHub Actions on pushes to `main`, pull requests and weekly. The `main` ruleset blocks merges with CodeQL errors or high-severity security alerts.
* **OpenSSF Scorecard.** `.github/workflows/scorecard.yml` runs on `main` and weekly and publishes results.
* **Required CI.** `main` requires the `CI passed` check from `.github/workflows/check.yml`, which runs format, lint and the Linux test suite on every pull request. Every push to `main` also runs the Windows, Node 22 and macOS tests. On a pull request, Windows and Node 22 run when CI, packaging or platform-sensitive files change or with the `full-ci` label, macOS runs only with the `full-ci` label, and the package smoke test runs when packaging inputs change. `CI passed` accepts a scoped-out job as skipped and fails on any other result.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.