#16658·joplin

Plugin Review Ecosystem — Complete Feature Plan

Author: laurent22Created Sep 25, 2026Updated Sep 28, 2026
Labelsenhancementsecurityhighplugins

What we're replacing

Today: A 30-minute cron job (update-repo.yml in joplin/plugins) runs @joplin/plugin-repo-cli commandBuild. It polls npm for packages tagged joplin-plugin, downloads each .tgz, extracts the manifest, builds a .jpl, and updates manifests.json in joplin/plugins. No security review, no human gate, no traceability to source. If a malicious version hits npm, it ships to users in ~30 minutes.

Target: GitHub Actions-based submission queue. Developer submits an issue; CI scans; a maintainer reviews and applies an approval label; a separate publish job builds the plugin from source and updates the registry. Nothing ships without human review.

The end-to-end flow

bash
Developer machine                joplin/plugins repo              User's Joplin
────────────────                 ──────────────────                ─────────────

npm run submit
  ├─ validate metadata
  ├─ verify build
  ├─ verify git state
  ├─ device flow auth
  └─ POST issue ──────────► [Plugin Submission] issue
                              │
                              ▼
                            security-scan.yml
                              ├─ validate payload
                              ├─ checkout at commit_hash
                              ├─ run CodeQL
                              ├─ post scan report as comment
                              └─ set label `scan: clean` / `scan: findings`
                                    │
                                    ▼
                            maintainer reviews report
                            maintainer applies `status: approved`
                              │
                              ▼
                            publish-plugin.yml (split-job)
                              ├─ verify scan was against this exact commit
                              ├─ build job (no write perms): npm ci && npm run dist
                              ├─ publish job (has write perms): plugin-repo-cli publish-plugin
                              │   ├─ check plugin ID / repo URL uniqueness
                              │   ├─ copy .jpl + manifest.json into plugins/<id>/
                              │   ├─ update manifests.json
                              │   ├─ update README.md
                              │   └─ upload .jpl to Releases
                              └─ close issue
                                                                    ▼
                                                                fetches manifests.json
                                                                downloads .jpl from Releases
                                                                installs plugin

Component 1: Developer CLI (generator-joplin)

What it does: Runs on the developer's machine when they type npm run submit. Turns "I want to publish my plugin" into "an issue on joplin/plugins."

Concrete responsibilities:

  • Metadata validation — package.json name starts with joplin-plugin-, manifest.json has valid semver, repository_url is a normalized GitHub URL.
  • Build verification — Runs npm run dist locally to prove the plugin compiles. Rejects if it doesn't.
  • Git state check — Working tree must be clean, local HEAD must match origin remote HEAD. This ensures the commit hash they'll submit actually exists on GitHub and reflects what they've built.
  • GitHub auth via Device Flow — First-time users see a browser prompt to authorize a Joplin-owned OAuth app; subsequent runs use cached credentials at ~/.config/joplin-plugin/credentials.json (0o600 permissions). No PAT juggling.
  • Payload submission — Opens an issue on joplin/plugins with title [Plugin Submission] <name> v<version> and a JSON body containing {plugin_id, repository_url, commit_hash, version}.

Design notes:

  • The CLI is not a security boundary. A malicious developer can hand-craft the API request and skip it. All the actual validation happens server-side in the CI. The CLI exists purely for DX.
  • The OAuth app is owned by Joplin. Client ID hardcoded in the generator template (public value, safe). No client secret needed because Device Flow is designed for CLIs. Scope requested: public_repo — enough to file issues on joplin/plugins, nothing more.
  • Immutable repo URL policy: once a plugin_id is bound to a repository_url in the registry, subsequent submissions must match. If a plugin genuinely moves repos, the maintainer edits the registry manually.

Component 2: Submission Registry (joplin/plugins repo structure)

The existing repo, but with new machinery. Directory shape stays compatible with the current npm-polling flow so both can run in parallel during transition.

Files that matter:

  • manifests.json — master registry. Same file format as today. Keyed by plugin ID. Each entry has id, version, name, author, description, homepage_url, repository_url, categories, screenshots, _publish_hash, _publish_commit, and (for legacy npm entries only) _npm_package_name.
  • manifestOverrides.json — manual overrides (_recommended, _obsolete). Existing mechanism, untouched.
  • plugins/<plugin_id>/plugin.jpl — built artifact.
  • plugins/<plugin_id>/manifest.json — per-plugin manifest.
  • stats.json — download counts.
  • README.md — auto-generated plugin table.

Trust anchor: For new-flow plugins, repository_url is the identity binding. First submission for a given plugin_id locks the URL. Any future submission for that ID must have a matching normalized URL, or it's rejected. Legacy npm-flow plugins keep _npm_package_name as their anchor until they migrate to the new flow (which happens naturally the first time their maintainer submits via the new CLI).

URL normalization: strip scheme, www., .git, trailing slash, lowercase. https://GitHub.com/Foo/Bar.git/ and github.com/foo/bar compare equal.

Component 3: Scan Workflow (.github/workflows/security-scan.yml)

Triggered by: issue opened or edited, title starts with [Plugin Submission].

Steps:

  1. Pre-flight validation (in-line JS via github-script): title matches expected format, body contains a valid JSON payload, all required fields present, repository_url is a normalized GitHub URL.
  2. Checkout target plugin at the exact commit_hash from the submitted repo.
  3. Initialize CodeQL with the custom ruleset in .github/codeql/codeql_rules/.
  4. Run CodeQL analysis against target-plugin/, output SARIF.
  5. Apply plugin-scoped approval baseline (see Component 5) — filter findings that a maintainer has previously reviewed and approved for this plugin at these unchanged locations.
  6. Post scan report as a comment on the issue: markdown table of findings grouped by severity, with file:line references, plus a "N findings suppressed by prior approval" summary line if applicable.
  7. Apply label scan: clean or scan: findings for maintainer filtering.

Permissions: issues: write, contents: read. No write access to the registry.

Component 4: CodeQL Ruleset (.github/codeql/codeql_rules/)

What it is: ~20 custom .ql files targeting Joplin-specific threats. Not general JavaScript CVEs — malicious behavior specific to what a plugin can do inside the Joplin runtime.

The threat model (canonical list):

Phase 1 — critical / structural threats:

  1. Dynamic code execution (eval, Function, vm.runInContext with remote/user data)
  2. Sensitive settings access (joplin.settings.globalValue(s) on master password, sync credentials, API token, encryption keys)
  3. Unauthorized filesystem access (targeting ~/.config/joplin-desktop/database.sqlite, self-modification of plugin dist files)
  4. Network backdoors (net.createServer, dgram, HTTP servers listening on ports)
  5. Clipboard hijacking (silent background reads, replacement of clipboard content)
  6. Cryptojacking / native binary dropping (xmrig, mining pool URLs, obfuscated binary drops)
  7. Electron main-process access (@electron/remote, direct IPC)
  8. Untrusted archive extraction (joplin.fs.archiveExtract on user input, zip-slip patterns)
  9. Native module bypass (direct require('child_process'), require('fs-extra') etc. — bypassing joplin.require)

Phase 2 — dual-use threats (require human judgment): 10. Command execution (child_process on any input) 11. Data exfiltration (joplin.data.get piped to fetch/axios) 12. Mass encryption / ransomware (bulk read + crypto.createCipheriv + bulk write) 13. Silent backup hijacking (fetch inside registerExportModule callback) 14. Malicious import module 15. Remote webview injection (external URLs in panel HTML) 16. Sync smuggling (bulk read + joplin.data.userDataSet — covert exfiltration via Joplin's own sync) 17. UI phishing (fake auth dialogs with credential exfiltration) 18. Tag flooding / search poisoning 19. Semantic sabotage / gaslighting (stochastic note corruption) 20. Mass data destruction (bulk delete loops) 21. Keylogging (workspace/settings/note-change hooks feeding network)

Not in scope:

  • Generic web app CVEs (ReDoS in transitive deps, XSS in server-side rendering)
  • Code quality issues (useless-regexp-character-escape, weak crypto modes in non-security contexts)
  • Anything that would harm the plugin author but not the Joplin user

Rule design principles:

  • Every rule maps to a numbered threat model entry in THREAT_MODEL.md.
  • Every rule has a header comment: what it detects, approach, known limitations.
  • Rules stay strict — legitimate exceptions live in the allowlist (Component 5), not in the rule file.
  • No paths-ignore on files that ship in the .jpl (rule scope = what users execute).
  • paths-ignore is acceptable for build tooling that doesn't ship (webpack.config.js, *.config.js at repo root).

Current state (as inherited from GSoC): 20 rules exist, largely LLM-generated, will need a careful audit and partial rewrite. Some rules currently silence themselves on specific commands (cp, mv) to hit "0 FPs on top 20." This weakens detection and should be replaced with per-plugin allowlist entries. See Section "Post-summer cleanup" below.

Component 5: Plugin-Scoped Finding Approvals

Problem this solves: Legitimate plugins sometimes use dangerous-looking APIs (backup plugin uses cp, format converters use child_process.spawn, etc.). We want the rule to fire globally but suppress the finding for that specific plugin at that specific location when a maintainer has reviewed and approved it.

File: .github/codeql/approved-findings/<plugin-id>.json

Shape (rough):

json
{
  "plugin_id": "io.github.jackgruber.backup",
  "approvals": [
    {
      "rule_id": "js/joplin/command-execution-structural",
      "file": "src/helper.ts",
      "code_hash": "sha256:<hash of the code context>",
      "reason": "cp for local backup directory, reviewed 2026-08-19",
      "approved_by": "laurentcozic",
      "approved_at": "2026-08-19",
      "approved_at_commit": "0c901a1e9d3e768a12db635f40b589060ae2d101"
    }
  ]
}

How the hash works: covers the command + arguments + enclosing function name (not raw line number, so refactors that move code don't invalidate approvals; not full file, so unrelated changes don't invalidate them). If the actual dangerous call changes shape — different command, different arguments, moved to a different function — the hash no longer matches and the finding re-appears for review.

Where approvals come from: When a maintainer reviews a scan and decides "this finding is legitimate, don't nag me next time," they add an entry. Either manually via PR to joplin/plugins, or via a workflow that captures the finding when the maintainer comments something like /approve-finding <finding-id>. The first is simpler and safer for the PoC; the second is nicer UX once trusted.

Reporting: The scan report shows two sections — new findings (require review) and previously-approved findings (informational). Reviewer never sees an "empty scan" report that's actually hiding suppressed findings.

Component 6: Publish Workflow (.github/workflows/publish-plugin.yml)

Triggered by: issue labeled status: approved, applied by an authorized maintainer.

Split into three jobs for privilege separation:

Job 1: initialize-publish — permissions: issues: write, contents: read.

  • Validate the issue payload.
  • Verify a successful scan exists in the issue comments for the exact commit_hash. If the payload was edited after scanning, abort.
  • Emit plugin_id, repository_url, commit_hash as outputs for the next jobs.

Job 2: build-plugin — permissions: contents: read only.

  • Clone the target repo at the exact commit_hash.
  • Run npm ci && npm run dist. This executes untrusted code — but with read-only permissions, any malicious build script can't steal the GITHUB_TOKEN or push unauthorized changes.
  • Verify output: exactly one .jpl file, one manifest.json (extracted from the .jpl, not read from source — otherwise a malicious plugin could ship different manifests to scanner vs registry).
  • Upload as a GitHub Actions artifact.

Job 3: publish-plugin — permissions: contents: write, issues: write. Runs no third-party code.

  • Download the artifact from Job 2.
  • Verify SHA-256 hash of the .jpl matches what Job 2 computed.
  • Call plugin-repo-cli publish-plugin <repo-dir> <manifest-file> <jpl-file>:
    • validateUntrustedManifest with source: 'repository' — enforces repository_url is set, _npm_package_name is absent, plugin ID uniqueness respects first-come-first-served.
    • Copy .jpl and manifest into plugins/<plugin_id>/.
    • Update manifests.json.
    • Update README.md via updateReadme.
  • Upload .jpl to GitHub Releases (via update-release).
  • Commit the registry changes atomically.
  • Close the submission issue.

Concurrency: concurrency: { group: global-joplin-registry-mutation, cancel-in-progress: false } — serializes registry mutations so two simultaneous approvals don't race.

Failure recovery: each job supports GitHub Actions' native "Re-run failed jobs." Manual override via workflow_dispatch with issue number input, for when the label event is dropped.

Component 7: Plugin ID Uniqueness (plugin-repo-cli/lib/checkIfPluginCanBeAdded.ts)

Already merged. Enforces the first-come-first-served locking:

  • New-flow plugin registers: ID must not exist in manifests.json. Bind the ID to the normalized repository_url forever.
  • New-flow plugin updates: submitted repository_url (normalized) must match the stored repository_url. Reject if not.
  • npm→repository migration: if the existing entry has _npm_package_name and no repository_url, a new-flow submission is rejected with "A maintainer must verify and register its repository URL." The maintainer manually confirms the transition once, then the plugin lives in the new flow.
  • npm-flow legacy updates: existing behavior preserved. Same npm package name required for updates.

Two backward-compat security holes closed (attacker takeover paths from mid-summer): incoming new-flow submissions must have repository_url, must not have _npm_package_name. Both requirements enforced in validateUntrustedManifest.

Component 8: Regression Testing Framework

Two CI jobs on every PR to .github/codeql/**:

A. Positive tests — codeql test run .github/codeql/tests/

  • One test directory per rule. Each contains: mock TypeScript file with malicious code the rule should catch, .qlref pointing to the rule, .expected file with the expected CodeQL output.
  • Fails PR if any rule's output diverges from its .expected.
  • Purpose: rules can't silently regress; changes to a rule require intentional updates to its expected output.

B. False-positive corpus test — rule-regression-test.yml

  • Matrix job over .github/codeql/target-plugins.json — list of 20 known-clean plugins pinned by {repo, commit_hash} (not just repo — see "Post-summer cleanup").
  • Each matrix cell: clone the plugin at the pinned commit, run the ruleset, upload findings as artifact.
  • Aggregate job: collect all findings, fail the workflow if any rule fires on any corpus plugin.
  • Purpose: rules can't be silently loosened by tuning against a moving target; the corpus is the source of truth for "0 false positives."

Component 9: Migration Path (out of scope for GSoC PoC but planned)

Phase 1 (done): PoC runs on joplin/plugins-test. Old cron on joplin/plugins untouched. Two systems in parallel.

Phase 2: Rebuild ruleset with proper audit (post-summer work — see below). Populate the top-20 corpus with pinned commits. Bring FP tests up to standard.

Phase 3: Cut over. On joplin/plugins:

  • Deprecate npm cron (leave running or turn off — either way, all new submissions go through the new flow).
  • Add prepublishOnly hook to generator-joplin template that intercepts npm publish and prints "As of DATE, Joplin plugins are no longer published via npm. Please use npm run submit."
  • Existing legacy plugins stay in manifests.json with _npm_package_name as trust anchor. They migrate individually when their maintainer next submits an update.

Phase 4 (later, out of scope):

  • Obsoletion automation — status: revoked label triggers a workflow that adds _obsolete: true to manifestOverrides.json and removes the plugin from the registry.
  • Vulnerability disclosure — scaffold SECURITY.md into new plugin templates.
  • Retroactive scanning — scheduled job that re-scans installed plugins against the current ruleset, flagging plugins that would fail today's rules even if they passed at submission time.

Post-summer cleanup (before this goes to joplin/plugins)

  1. Threat model as canonical document. Currently rules.md describes rules and implicitly defines the threat model. Invert: create THREAT_MODEL.md with numbered threat entries. Each rule references its threat entry. Rules without a mapped threat get deleted.
  2. Audit the 20 rules. For each: read the QL, compare against the threat model entry, decide keep / rewrite / delete. My guess: probably half survive as-is, a quarter need rewriting to be less structural and more semantic, a quarter should be deleted or merged. Estimated 2-3 weeks of maintainer time.
  3. Remove the cp/mv exclusion in rule 07b. Replace with per-plugin allowlist entries for the backup plugin. Apply the same pattern to any other rule that has plugin-specific silencing.
  4. Pin the top-20 corpus by commit hash in target-plugins.json. Currently references repos without commit pins, which means upstream changes to those plugins flake the regression tests.
  5. Aggregate job must actually fail on non-empty findings. Verify aggregateFindings.js exits with code 1 when SARIF has results — don't just print a report.
  6. Land the plugin-scoped approvals feature. GSoC designed but didn't ship it. Build the hash + allowlist file + scan post-processing.
  7. Fix joplin.settings.globalValues at the Joplin core level. Separate track, not GSoC scope, but the finding is real: currently any plugin can read the user's master password, sync credentials, and API token via this API. Fix is an allowlist of readable settings — plugins can only read their own namespace plus a small set of explicitly public settings. Everything else requires a manifest permission.

What we already have shipped

Merged to laurent22/joplin:

  • PR #15596 — Local validations in generator-joplin (metadata + git state checks)
  • PR #15711 — Regex-based semver validation (removed the semver dep)
  • PR #15981 — plugin-repo-cli publish-plugin command + ID uniqueness enforcement with source: 'npm' | 'repository' discrimination
  • **P