Skip to content

Security Contract

Assertions

SEC-001 - Joplin credentials never enter public output or workspace state

Contract: The Joplin token MUST be accepted only from JOPLIN_TOKEN or a token file, except that the local process mcp stdio MAY also accept the compatibility argument --token TOKEN, whose value is visible to other local processes and IDE configuration readers. Every Joplin and MCP token file MUST be a bounded single-line regular file opened without following symlinks. On POSIX it MUST be owned by the current user with no group or other access. On Windows it MUST be owned by the current user, SYSTEM, or Administrators, and no effective allow entry of its ACL MAY give another account read, write, or permission-change rights. Rejections MUST NOT echo the file content. Every accepted form MUST be redacted from stdout, stderr, log files, and logged tracebacks and MUST NOT be stored in workspace files. Stdio stdout MUST contain only protocol messages, and stdio mode MUST NOT open HTTP interfaces or accept their bearer credentials. Authentication failure MUST not echo remote response content containing the credential.

Evidence:

SEC-002 - Remote network exposure always requires explicit authorization

Contract: Joplin API addresses outside loopback MUST require --allow-remote-api. MCP listeners outside loopback MUST require both --allow-remote-mcp and protected MCP bearer authentication. Browser-origin requests MUST pass the configured Origin policy.

Evidence:

SEC-003 - Bearer sources are strong, protected, and rotatable

Contract: MCP bearer sources MUST be token files protected as defined by SEC-001 on POSIX and Windows, not symlinks or directories, and contain one bounded URL-safe Base64 value encoding at least 256 bits. Files MUST be re-read per request and comparisons MUST fail closed for non-ASCII, malformed, oversized, or duplicate authorization.

Evidence:

SEC-004 - Filesystem inputs cannot escape or redirect traversal

Contract: Remote titles and local relative paths MUST be sanitized and checked against the workspace root. Workspace scanning and bearer-file loading MUST reject symlinks. Local replacements MUST be atomic, and destructive sync operations MUST retain backup or quarantine evidence.

Evidence:

SEC-005 - Untrusted note content is data, never executable input

Contract: Runtime modules MUST NOT invoke a shell, subprocess, dynamic eval, or dynamic exec. Note bodies, titles, tags, tool arguments, and tool results MUST be treated as data and MUST not become filesystem paths or command arguments outside their validated domain adapters.

Evidence:

SEC-007 - Destructive boundaries match Joplin recovery capabilities

Contract: Sync and direct note/notebook operations MUST use Joplin trash and support restore. Tag and resource deletion MAY be permanent because Joplin has no trash API for them and MUST be marked destructive in registry metadata. MCP MUST report the actual deletion class.

Evidence:

SEC-008 - GitHub OAuth permits one verified numeric account

Contract: OAuth configuration MUST require one positive ASCII decimal GitHub user ID. Login hints, email, unverified JWT claims and API scopes alone MUST NOT authorize an account. Issuance, refresh and protected requests MUST verify the current account via GitHub /user before downstream tokens are issued or a tool runs. An upstream grant that GitHub already rotated MUST be retained when that verification is temporarily unavailable, so the same downstream refresh can be retried. Only within-request positive caching is permitted. Downstream redirect URIs MUST exactly match the hosted Claude callback https://claude.ai/api/mcp/auth_callback; DCR, PKCE, consent/state and one-use code/refresh binding MUST remain enforced. Unverified registrations MUST stay pending with a bounded count and lifetime until an owner login establishes them; registration, token and browser-flow requests MUST have separate rate budgets. Client credentials MUST remain independent across OAuth, legacy MCP and Joplin, comparing the signing key as key material in every accepted encoding. Codes, credentials and note bodies MUST NOT enter application/SDK logs. GitHub expiring access and refresh token formats MUST be validated before issuing client credentials. The consent page MUST warn the owner not to approve a connection they did not start, and MUST fail closed instead of rendering an approval without that warning.

Evidence:

SEC-009 - OAuth state is private, encrypted and exclusively managed

Contract: Persistent OAuth credentials MUST be encrypted in a private, dedicated directory outside sync state with an exclusive process lock and validated schema. Incompatible/corrupt state or a wrong signing key MUST fail closed without resetting existing grants. Reset MUST require explicit local confirmation and the same exclusive lock. Restart MUST retain valid grants; changing the allowed account or resetting state MUST deny old access. Quota or storage failures MUST NOT evict existing valid grants to admit new ones.

Evidence:

SEC-010 - OAuth security events are recorded without credentials

Contract: The OAuth service MUST record registrations, consent decisions and forgery attempts, callback binding failures, foreign GitHub accounts, token issuance, refresh success and replay, rejected resource tokens, rate limiting, GitHub outages and local resets as single-line audit events. Events MUST contain only a fixed name and whitelisted, validated fields, and MUST NOT contain tokens, codes, state, transaction or CSRF values, secrets, request content, client metadata or forwarded addresses. Anonymous-triggerable events MUST be throttled per event and reason with a suppressed count. Audit events MUST be visible at default service verbosity.

Evidence: