[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M793STXG0C5YK8XMBSE0KYDX":3,"skill-same:01M793STXG0C5YK8XMBSE0KYDX":58},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":35,"commitSha":36,"skillDirectory":37,"forksCount":38,"repositoryHtmlUrl":39,"repositoryHomepageUrl":6,"ownerHtmlUrl":40,"ownerBlogUrl":41,"ownerDescription":42,"updatedAt":43,"install":44,"resources":57},"01M793STXG0C5YK8XMBSE0KYDX","obsidian-security-basics",null,"Implement secure Obsidian plugin development practices. Covers credential\nstorage, input validation, XSS prevention, network security, URI handler\nsafety, and Electron security. Use when handling user data, storing API keys,\nmaking network requests, or preparing for community plugin submission.\nTrigger with phrases like \"obsidian security\", \"secure obsidian plugin\",\n\"obsidian data protection\", \"obsidian privacy\", \"obsidian api key storage\".","jukeyman\u002Fjukeyman-skills","jukeyman","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F142960420?v=4","01M78FR4Y3DHMMCBCC0GXXNB3F","RICK JEFFERSON","01M78FR4Z8RVQRAD31Y5J7V6EB",1,"MIT","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fsaas-packs--obsidian-pack--obsidian-security-basics\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: obsidian-security-basics\ndescription: |\n  Implement secure Obsidian plugin development practices. Covers credential\n  storage, input validation, XSS prevention, network security, URI handler\n  safety, and Electron security. Use when handling user data, storing API keys,\n  making network requests, or preparing for community plugin submission.\n  Trigger with phrases like \"obsidian security\", \"secure obsidian plugin\",\n  \"obsidian data protection\", \"obsidian privacy\", \"obsidian api key storage\".\nallowed-tools: Read, Write, Edit, Grep\nversion: 2.0.0\nlicense: MIT\nauthor: Jeremy Longshore \u003Cjeremy@intentsolutions.io>\ncompatible-with: claude-code, codex, openclaw\ntags: [obsidian, security, authentication, privacy, electron]\n---\n# Obsidian Security Basics\n\n## Overview\nSecurity practices for Obsidian plugin development. Plugins run with full vault filesystem access and can make arbitrary network requests inside Electron. Responsible development requires protecting credentials, sanitizing external data, validating URI handlers, minimizing permissions, and following Obsidian's plugin guidelines to avoid community submission rejection.\n\n## Prerequisites\n- Obsidian plugin development environment\n- Understanding that `.obsidian\u002Fplugins\u002F\u003Cid>\u002Fdata.json` is synced by cloud services\n- Awareness of [Obsidian Plugin Guidelines](https:\u002F\u002Fdocs.obsidian.md\u002FPlugins\u002FReleasing\u002FPlugin+guidelines)\n\n## Instructions\n\n### Step 1: Credential Storage — Never in data.json\n\nPlugin settings (`data.json`) live inside the vault and are synced by iCloud, Dropbox, Obsidian Sync, and Git. API keys stored here are effectively public.\n\n```typescript\n\u002F\u002F BAD: API key stored in plugin settings (synced to cloud, committed to Git)\ninterface BadSettings {\n  apiKey: string; \u002F\u002F This ends up in .obsidian\u002Fplugins\u002Fmy-plugin\u002Fdata.json\n}\n\n\u002F\u002F GOOD: Use Electron's safeStorage for desktop (encrypted at OS level)\nimport { Platform } from 'obsidian';\n\nexport class SecureStorage {\n  private plugin: Plugin;\n\n  constructor(plugin: Plugin) { this.plugin = plugin; }\n\n  async storeSecret(key: string, value: string): Promise\u003Cvoid> {\n    if (Platform.isDesktopApp) {\n      \u002F\u002F Electron's safeStorage uses OS keychain (Keychain on macOS, DPAPI on Windows)\n      const { safeStorage } = require('electron').remote || require('@electron\u002Fremote');\n      if (safeStorage.isEncryptionAvailable()) {\n        const encrypted = safeStorage.encryptString(value);\n        const data = await this.plugin.loadData() ?? {};\n        data[`_encrypted_${key}`] = encrypted.toString('base64');\n        await this.plugin.saveData(data);\n        return;\n      }\n    }\n    \u002F\u002F Fallback for mobile or when encryption unavailable: prompt each session\n    \u002F\u002F Store only in memory — never persisted\n    this.memoryStore.set(key, value);\n  }\n\n  async getSecret(key: string): Promise\u003Cstring | null> {\n    if (Platform.isDesktopApp) {\n      const { safeStorage } = require('electron').remote || require('@electron\u002Fremote');\n      const data = await this.plugin.loadData();\n      const encrypted = data?.[`_encrypted_${key}`];\n      if (encrypted && safeStorage.isEncryptionAvailable()) {\n        return safeStorage.decryptString(Buffer.from(encrypted, 'base64'));\n      }\n    }\n    return this.memoryStore.get(key) ?? null;\n  }\n\n  private memoryStore = new Map\u003Cstring, string>();\n}\n\n\u002F\u002F Alternative: prompt user each session (simplest, most secure)\nasync onload() {\n  if (!this.apiKey) {\n    this.apiKey = await this.promptForApiKey();\n  }\n}\n```\n\n### Step 2: Input Validation and XSS Prevention\n\nData from HTTP responses, clipboard, or URI handlers must be sanitized before rendering.\n\n```typescript\n\u002F\u002F Sanitize HTML content before inserting into Obsidian views\nfunction sanitizeHtml(input: string): string {\n  \u002F\u002F Strip dangerous elements\n  input = input.replace(\u002F\u003Cscript[^>]*>[\\s\\S]*?\u003C\\\u002Fscript>\u002Fgi, '');\n  input = input.replace(\u002F\u003Ciframe[^>]*>[\\s\\S]*?\u003C\\\u002Fiframe>\u002Fgi, '');\n  input = input.replace(\u002F\u003Cobject[^>]*>[\\s\\S]*?\u003C\\\u002Fobject>\u002Fgi, '');\n  input = input.replace(\u002F\u003Cembed[^>]*>\u002Fgi, '');\n  \u002F\u002F Strip event handlers\n  input = input.replace(\u002F\\bon\\w+\\s*=\\s*\"[^\"]*\"\u002Fgi, '');\n  input = input.replace(\u002F\\bon\\w+\\s*=\\s*'[^']*'\u002Fgi, '');\n  \u002F\u002F Strip javascript: URIs\n  input = input.replace(\u002Fhref\\s*=\\s*\"javascript:[^\"]*\"\u002Fgi, 'href=\"#\"');\n  return input;\n}\n\n\u002F\u002F For plain text in DOM elements — escape instead of strip\nfunction escapeHtml(text: string): string {\n  const div = document.createElement('div');\n  div.textContent = text;\n  return div.innerHTML;\n}\n\n\u002F\u002F Safe DOM creation (preferred in Obsidian)\n\u002F\u002F Use createEl with text content — Obsidian escapes automatically\ncontainer.createEl('p', { text: userInput }); \u002F\u002F Safe — text is escaped\ncontainer.createEl('p').innerHTML = userInput;  \u002F\u002F DANGEROUS — raw HTML injection\n\n\u002F\u002F For markdown content from external sources\nfunction sanitizeMarkdown(md: string): string {\n  \u002F\u002F Remove HTML blocks that could contain scripts\n  md = md.replace(\u002F\u003Cscript[\\s\\S]*?\u003C\\\u002Fscript>\u002Fgi, '');\n  \u002F\u002F Remove image onerror handlers\n  md = md.replace(\u002Fonerror\\s*=\\s*[\"'][^\"']*[\"']\u002Fgi, '');\n  \u002F\u002F Limit length to prevent DoS\n  if (md.length > 500_000) md = md.substring(0, 500_000);\n  return md;\n}\n```\n\n### Step 3: Secure URI Handler Registration\n\nObsidian's `registerObsidianProtocolHandler` lets external apps trigger plugin actions via `obsidian:\u002F\u002F` URIs. Validate all parameters.\n\n```typescript\nthis.registerObsidianProtocolHandler('myplugin', async (params) => {\n  \u002F\u002F Whitelist allowed actions\n  const ALLOWED_ACTIONS = ['open', 'create', 'search'] as const;\n  type Action = typeof ALLOWED_ACTIONS[number];\n\n  const action = params.action as string;\n  if (!ALLOWED_ACTIONS.includes(action as Action)) {\n    new Notice(`Invalid action: ${action}`);\n    return;\n  }\n\n  \u002F\u002F Sanitize file paths — prevent directory traversal\n  const path = params.path?.replace(\u002F\\.\\.\u002Fg, '').replace(\u002F^\\\u002F\u002F, '');\n  if (!path) {\n    new Notice('Missing path parameter');\n    return;\n  }\n\n  \u002F\u002F Validate path is within vault\n  const normalized = normalizePath(path);\n  if (normalized.includes('..') || normalized.startsWith('\u002F')) {\n    new Notice('Invalid path');\n    return;\n  }\n\n  \u002F\u002F Limit content length\n  const content = params.content?.substring(0, 100_000) ?? '';\n\n  switch (action as Action) {\n    case 'open': {\n      const file = this.app.vault.getAbstractFileByPath(normalized);\n      if (file instanceof TFile) {\n        await this.app.workspace.getLeaf().openFile(file);\n      } else {\n        new Notice(`File not found: ${normalized}`);\n      }\n      break;\n    }\n    case 'create': {\n      await this.app.vault.create(normalized, content);\n      new Notice(`Created: ${normalized}`);\n      break;\n    }\n    case 'search': {\n      \u002F\u002F Use Obsidian's built-in search\n      (this.app as any).internalPlugins.plugins['global-search']\n        ?.instance.openGlobalSearch(content);\n      break;\n    }\n  }\n});\n```\n\n### Step 4: Secure Network Requests\n\n```typescript\nimport { requestUrl, RequestUrlParam } from 'obsidian';\n\n\u002F\u002F Always use Obsidian's requestUrl — it respects proxy settings and CORS\nasync function secureFetch(url: string, options?: Partial\u003CRequestUrlParam>): Promise\u003Cany> {\n  \u002F\u002F Enforce HTTPS\n  if (!url.startsWith('https:\u002F\u002F')) {\n    throw new Error('Only HTTPS requests are allowed');\n  }\n\n  \u002F\u002F Allowlist domains (prevents SSRF if URL comes from user input)\n  const ALLOWED_DOMAINS = ['api.example.com', 'cdn.example.com'];\n  const urlObj = new URL(url);\n  if (!ALLOWED_DOMAINS.includes(urlObj.hostname)) {\n    throw new Error(`Domain not allowed: ${urlObj.hostname}`);\n  }\n\n  const response = await requestUrl({\n    url,\n    method: 'GET',\n    headers: {\n      'User-Agent': 'ObsidianPlugin\u002F1.0',\n      ...options?.headers,\n    },\n    ...options,\n  });\n\n  if (response.status \u003C 200 || response.status >= 300) {\n    throw new Error(`HTTP ${response.status}: ${url}`);\n  }\n\n  return response.json;\n}\n\n\u002F\u002F Never log or display full API responses — they may contain PII\nfunction redactForLogging(data: any): any {\n  const redacted = { ...data };\n  const sensitiveKeys = ['apiKey', 'token', 'password', 'secret', 'authorization'];\n  for (const key of Object.keys(redacted)) {\n    if (sensitiveKeys.some(s => key.toLowerCase().includes(s))) {\n      redacted[key] = '[REDACTED]';\n    }\n  }\n  return redacted;\n}\n```\n\n### Step 5: Permission Minimization\n\n```typescript\n\u002F\u002F manifest.json — only set isDesktopOnly if you actually need Electron APIs\n{\n  \"isDesktopOnly\": false\n  \u002F\u002F Obsidian has no granular permission model in manifest.json.\n  \u002F\u002F The review team evaluates your code for:\n  \u002F\u002F - Network requests: must be essential to plugin function\n  \u002F\u002F - Filesystem access outside vault: strongly discouraged\n  \u002F\u002F - No telemetry\u002Fanalytics without explicit user consent\n  \u002F\u002F - No remote code loading (eval, new Function, loading JS from URL)\n}\n\n\u002F\u002F At runtime: guard platform-specific code\nimport { Platform, FileSystemAdapter } from 'obsidian';\n\nfunction getVaultBasePath(): string | null {\n  if (this.app.vault.adapter instanceof FileSystemAdapter) {\n    return this.app.vault.adapter.getBasePath();\n    \u002F\u002F IMPORTANT: never access files outside this basePath\n  }\n  return null; \u002F\u002F Mobile — no filesystem access outside vault\n}\n\n\u002F\u002F Guard Electron APIs\nif (Platform.isDesktopApp) {\n  \u002F\u002F Safe to use: require('electron'), child_process, etc.\n} else {\n  \u002F\u002F Mobile: these APIs don't exist — provide fallback or disable feature\n}\n```\n\n### Step 6: Plugin Review Rejection Checklist\n\nObsidian's plugin review team will reject plugins for these violations:\n\n```typescript\n\u002F\u002F REJECTED: eval() or dynamic code execution\neval(userInput);                    \u002F\u002F Never\nnew Function('return ' + code)();  \u002F\u002F Never\ndocument.createElement('script');  \u002F\u002F Never for external scripts\n\n\u002F\u002F REJECTED: remote code loading\nconst script = document.createElement('script');\nscript.src = 'https:\u002F\u002Fcdn.example.com\u002Flib.js';  \u002F\u002F Load at build time instead\n\n\u002F\u002F REJECTED: console.log in production\nconsole.log('user data:', settings);  \u002F\u002F Remove before submission\n\n\u002F\u002F REJECTED: unencrypted credential storage\nthis.saveData({ apiKey: 'sk-abc123' });  \u002F\u002F Use SecureStorage (Step 1)\n\n\u002F\u002F REJECTED: undisclosed network requests\nfetch('https:\u002F\u002Fanalytics.example.com\u002Ftrack', { body: ... });  \u002F\u002F No hidden telemetry\n\n\u002F\u002F APPROVED alternatives:\n\u002F\u002F - Bundle dependencies with esbuild (no runtime loading)\n\u002F\u002F - Use a debug flag for console statements\n\u002F\u002F - Document all network requests in README\n\u002F\u002F - Get explicit consent before any data leaves the device\n```\n\n## Output\n- SecureStorage class using Electron's safeStorage for encrypted credential storage\n- HTML and markdown sanitization for all external content\n- URI handler with action whitelist and path validation\n- Secure network request wrapper with HTTPS enforcement and domain allowlist\n- Platform-specific guards for desktop\u002Fmobile code paths\n- Plugin review rejection checklist with approved alternatives\n\n## Error Handling\n| Issue | Cause | Solution |\n|-------|-------|----------|\n| API key synced to cloud | Stored in `data.json` | Use `SecureStorage` with Electron `safeStorage` |\n| XSS in note preview | Unsanitized external HTML | Use `createEl` with `text` property, or `sanitizeHtml` |\n| Directory traversal via URI | Unvalidated path parameter | Strip `..`, normalize, validate within vault |\n| SSRF from user-provided URL | No domain allowlist | Validate against ALLOWED_DOMAINS before `requestUrl` |\n| Plugin rejected on review | `eval`, `console.log`, or telemetry | Follow rejection checklist (Step 6) |\n| `safeStorage` unavailable | Older Electron version or mobile | Fall back to per-session prompt |\n\n## Examples\n\n### Content Security for Custom Views\n```typescript\n\u002F\u002F When rendering external content in an ItemView\nasync onOpen() {\n  const externalData = await this.fetchData();\n  const container = this.containerEl.children[1];\n  container.empty();\n\n  \u002F\u002F Safe: text content is escaped by createEl\n  container.createEl('h3', { text: externalData.title });\n  container.createEl('p', { text: externalData.summary });\n\n  \u002F\u002F If you must render HTML, sanitize first\n  const safeHtml = sanitizeHtml(externalData.htmlContent);\n  const htmlContainer = container.createEl('div');\n  htmlContainer.innerHTML = safeHtml;\n}\n```\n\n### Audit Your Plugin for Security Issues\n```bash\n# Quick security audit of plugin source code\ngrep -rn 'eval(\\|new Function(' src\u002F --include=\"*.ts\" && echo \"FAIL: dynamic code execution\"\ngrep -rn 'innerHTML\\s*=' src\u002F --include=\"*.ts\" && echo \"WARN: check for XSS\"\ngrep -rn 'console\\.log' src\u002F --include=\"*.ts\" | grep -v '\u002F\u002F DEBUG' && echo \"WARN: console.log in prod\"\ngrep -rn 'apiKey\\|secret\\|password' src\u002F --include=\"*.ts\" && echo \"CHECK: credential handling\"\necho \"Done.\"\n```\n\n## Resources\n- [Obsidian Plugin Guidelines](https:\u002F\u002Fdocs.obsidian.md\u002FPlugins\u002FReleasing\u002FPlugin+guidelines)\n- [Electron Security](https:\u002F\u002Fwww.electronjs.org\u002Fdocs\u002Flatest\u002Ftutorial\u002Fsecurity)\n- [OWASP XSS Prevention](https:\u002F\u002Fcheatsheetseries.owasp.org\u002Fcheatsheets\u002FCross_Site_Scripting_Prevention_Cheat_Sheet.html)\n- [Obsidian requestUrl API](https:\u002F\u002Fdocs.obsidian.md\u002FReference\u002FTypeScript+API\u002FrequestUrl)\n\n## Next Steps\nFor production readiness checks, see `obsidian-prod-checklist`.\nFor deployment and community submission, see `obsidian-deploy-integration`.\n","# Obsidian Security Basics\n\n## Overview\nSecurity practices for Obsidian plugin development. Plugins run with full vault filesystem access and can make arbitrary network requests inside Electron. Responsible development requires protecting credentials, sanitizing external data, validating URI handlers, minimizing permissions, and following Obsidian's plugin guidelines to avoid community submission rejection.\n\n## Prerequisites\n- Obsidian plugin development environment\n- Understanding that `.obsidian\u002Fplugins\u002F\u003Cid>\u002Fdata.json` is synced by cloud services\n- Awareness of [Obsidian Plugin Guidelines](https:\u002F\u002Fdocs.obsidian.md\u002FPlugins\u002FReleasing\u002FPlugin+guidelines)\n\n## Instructions\n\n### Step 1: Credential Storage — Never in data.json\n\nPlugin settings (`data.json`) live inside the vault and are synced by iCloud, Dropbox, Obsidian Sync, and Git. API keys stored here are effectively public.\n\n```typescript\n\u002F\u002F BAD: API key stored in plugin settings (synced to cloud, committed to Git)\ninterface BadSettings {\n  apiKey: string; \u002F\u002F This ends up in .obsidian\u002Fplugins\u002Fmy-plugin\u002Fdata.json\n}\n\n\u002F\u002F GOOD: Use Electron's safeStorage for desktop (encrypted at OS level)\nimport { Platform } from 'obsidian';\n\nexport class SecureStorage {\n  private plugin: Plugin;\n\n  constructor(plugin: Plugin) { this.plugin = plugin; }\n\n  async storeSecret(key: string, value: string): Promise\u003Cvoid> {\n    if (Platform.isDesktopApp) {\n      \u002F\u002F Electron's safeStorage uses OS keychain (Keychain on macOS, DPAPI on Windows)\n      const { safeStorage } = require('electron').remote || require('@electron\u002Fremote');\n      if (safeStorage.isEncryptionAvailable()) {\n        const encrypted = safeStorage.encryptString(value);\n        const data = await this.plugin.loadData() ?? {};\n        data[`_encrypted_${key}`] = encrypted.toString('base64');\n        await this.plugin.saveData(data);\n        return;\n      }\n    }\n    \u002F\u002F Fallback for mobile or when encryption unavailable: prompt each session\n    \u002F\u002F Store only in memory — never persisted\n    this.memoryStore.set(key, value);\n  }\n\n  async getSecret(key: string): Promise\u003Cstring | null> {\n    if (Platform.isDesktopApp) {\n      const { safeStorage } = require('electron').remote || require('@electron\u002Fremote');\n      const data = await this.plugin.loadData();\n      const encrypted = data?.[`_encrypted_${key}`];\n      if (encrypted && safeStorage.isEncryptionAvailable()) {\n        return safeStorage.decryptString(Buffer.from(encrypted, 'base64'));\n      }\n    }\n    return this.memoryStore.get(key) ?? null;\n  }\n\n  private memoryStore = new Map\u003Cstring, string>();\n}\n\n\u002F\u002F Alternative: prompt user each session (simplest, most secure)\nasync onload() {\n  if (!this.apiKey) {\n    this.apiKey = await this.promptForApiKey();\n  }\n}\n```\n\n### Step 2: Input Validation and XSS Prevention\n\nData from HTTP responses, clipboard, or URI handlers must be sanitized before rendering.\n\n```typescript\n\u002F\u002F Sanitize HTML content before inserting into Obsidian views\nfunction sanitizeHtml(input: string): string {\n  \u002F\u002F Strip dangerous elements\n  input = input.replace(\u002F\u003Cscript[^>]*>[\\s\\S]*?\u003C\\\u002Fscript>\u002Fgi, '');\n  input = input.replace(\u002F\u003Ciframe[^>]*>[\\s\\S]*?\u003C\\\u002Fiframe>\u002Fgi, '');\n  input = input.replace(\u002F\u003Cobject[^>]*>[\\s\\S]*?\u003C\\\u002Fobject>\u002Fgi, '');\n  input = input.replace(\u002F\u003Cembed[^>]*>\u002Fgi, '');\n  \u002F\u002F Strip event handlers\n  input = input.replace(\u002F\\bon\\w+\\s*=\\s*\"[^\"]*\"\u002Fgi, '');\n  input = input.replace(\u002F\\bon\\w+\\s*=\\s*'[^']*'\u002Fgi, '');\n  \u002F\u002F Strip javascript: URIs\n  input = input.replace(\u002Fhref\\s*=\\s*\"javascript:[^\"]*\"\u002Fgi, 'href=\"#\"');\n  return input;\n}\n\n\u002F\u002F For plain text in DOM elements — escape instead of strip\nfunction escapeHtml(text: string): string {\n  const div = document.createElement('div');\n  div.textContent = text;\n  return div.innerHTML;\n}\n\n\u002F\u002F Safe DOM creation (preferred in Obsidian)\n\u002F\u002F Use createEl with text content — Obsidian escapes automatically\ncontainer.createEl('p', { text: userInput }); \u002F\u002F Safe — text is escaped\ncontainer.createEl('p').innerHTML = userInput;  \u002F\u002F DANGEROUS — raw HTML injection\n\n\u002F\u002F For markdown content from external sources\nfunction sanitizeMarkdown(md: string): string {\n  \u002F\u002F Remove HTML blocks that could contain scripts\n  md = md.replace(\u002F\u003Cscript[\\s\\S]*?\u003C\\\u002Fscript>\u002Fgi, '');\n  \u002F\u002F Remove image onerror handlers\n  md = md.replace(\u002Fonerror\\s*=\\s*[\"'][^\"']*[\"']\u002Fgi, '');\n  \u002F\u002F Limit length to prevent DoS\n  if (md.length > 500_000) md = md.substring(0, 500_000);\n  return md;\n}\n```\n\n### Step 3: Secure URI Handler Registration\n\nObsidian's `registerObsidianProtocolHandler` lets external apps trigger plugin actions via `obsidian:\u002F\u002F` URIs. Validate all parameters.\n\n```typescript\nthis.registerObsidianProtocolHandler('myplugin', async (params) => {\n  \u002F\u002F Whitelist allowed actions\n  const ALLOWED_ACTIONS = ['open', 'create', 'search'] as const;\n  type Action = typeof ALLOWED_ACTIONS[number];\n\n  const action = params.action as string;\n  if (!ALLOWED_ACTIONS.includes(action as Action)) {\n    new Notice(`Invalid action: ${action}`);\n    return;\n  }\n\n  \u002F\u002F Sanitize file paths — prevent directory traversal\n  const path = params.path?.replace(\u002F\\.\\.\u002Fg, '').replace(\u002F^\\\u002F\u002F, '');\n  if (!path) {\n    new Notice('Missing path parameter');\n    return;\n  }\n\n  \u002F\u002F Validate path is within vault\n  const normalized = normalizePath(path);\n  if (normalized.includes('..') || normalized.startsWith('\u002F')) {\n    new Notice('Invalid path');\n    return;\n  }\n\n  \u002F\u002F Limit content length\n  const content = params.content?.substring(0, 100_000) ?? '';\n\n  switch (action as Action) {\n    case 'open': {\n      const file = this.app.vault.getAbstractFileByPath(normalized);\n      if (file instanceof TFile) {\n        await this.app.workspace.getLeaf().openFile(file);\n      } else {\n        new Notice(`File not found: ${normalized}`);\n      }\n      break;\n    }\n    case 'create': {\n      await this.app.vault.create(normalized, content);\n      new Notice(`Created: ${normalized}`);\n      break;\n    }\n    case 'search': {\n      \u002F\u002F Use Obsidian's built-in search\n      (this.app as any).internalPlugins.plugins['global-search']\n        ?.instance.openGlobalSearch(content);\n      break;\n    }\n  }\n});\n```\n\n### Step 4: Secure Network Requests\n\n```typescript\nimport { requestUrl, RequestUrlParam } from 'obsidian';\n\n\u002F\u002F Always use Obsidian's requestUrl — it respects proxy settings and CORS\nasync function secureFetch(url: string, options?: Partial\u003CRequestUrlParam>): Promise\u003Cany> {\n  \u002F\u002F Enforce HTTPS\n  if (!url.startsWith('https:\u002F\u002F')) {\n    throw new Error('Only HTTPS requests are allowed');\n  }\n\n  \u002F\u002F Allowlist domains (prevents SSRF if URL comes from user input)\n  const ALLOWED_DOMAINS = ['api.example.com', 'cdn.example.com'];\n  const urlObj = new URL(url);\n  if (!ALLOWED_DOMAINS.includes(urlObj.hostname)) {\n    throw new Error(`Domain not allowed: ${urlObj.hostname}`);\n  }\n\n  const response = await requestUrl({\n    url,\n    method: 'GET',\n    headers: {\n      'User-Agent': 'ObsidianPlugin\u002F1.0',\n      ...options?.headers,\n    },\n    ...options,\n  });\n\n  if (response.status \u003C 200 || response.status >= 300) {\n    throw new Error(`HTTP ${response.status}: ${url}`);\n  }\n\n  return response.json;\n}\n\n\u002F\u002F Never log or display full API responses — they may contain PII\nfunction redactForLogging(data: any): any {\n  const redacted = { ...data };\n  const sensitiveKeys = ['apiKey', 'token', 'password', 'secret', 'authorization'];\n  for (const key of Object.keys(redacted)) {\n    if (sensitiveKeys.some(s => key.toLowerCase().includes(s))) {\n      redacted[key] = '[REDACTED]';\n    }\n  }\n  return redacted;\n}\n```\n\n### Step 5: Permission Minimization\n\n```typescript\n\u002F\u002F manifest.json — only set isDesktopOnly if you actually need Electron APIs\n{\n  \"isDesktopOnly\": false\n  \u002F\u002F Obsidian has no granular permission model in manifest.json.\n  \u002F\u002F The review team evaluates your code for:\n  \u002F\u002F - Network requests: must be essential to plugin function\n  \u002F\u002F - Filesystem access outside vault: strongly discouraged\n  \u002F\u002F - No telemetry\u002Fanalytics without explicit user consent\n  \u002F\u002F - No remote code loading (eval, new Function, loading JS from URL)\n}\n\n\u002F\u002F At runtime: guard platform-specific code\nimport { Platform, FileSystemAdapter } from 'obsidian';\n\nfunction getVaultBasePath(): string | null {\n  if (this.app.vault.adapter instanceof FileSystemAdapter) {\n    return this.app.vault.adapter.getBasePath();\n    \u002F\u002F IMPORTANT: never access files outside this basePath\n  }\n  return null; \u002F\u002F Mobile — no filesystem access outside vault\n}\n\n\u002F\u002F Guard Electron APIs\nif (Platform.isDesktopApp) {\n  \u002F\u002F Safe to use: require('electron'), child_process, etc.\n} else {\n  \u002F\u002F Mobile: these APIs don't exist — provide fallback or disable feature\n}\n```\n\n### Step 6: Plugin Review Rejection Checklist\n\nObsidian's plugin review team will reject plugins for these violations:\n\n```typescript\n\u002F\u002F REJECTED: eval() or dynamic code execution\neval(userInput);                    \u002F\u002F Never\nnew Function('return ' + code)();  \u002F\u002F Never\ndocument.createElement('script');  \u002F\u002F Never for external scripts\n\n\u002F\u002F REJECTED: remote code loading\nconst script = document.createElement('script');\nscript.src = 'https:\u002F\u002Fcdn.example.com\u002Flib.js';  \u002F\u002F Load at build time instead\n\n\u002F\u002F REJECTED: console.log in production\nconsole.log('user data:', settings);  \u002F\u002F Remove before submission\n\n\u002F\u002F REJECTED: unencrypted credential storage\nthis.saveData({ apiKey: 'sk-abc123' });  \u002F\u002F Use SecureStorage (Step 1)\n\n\u002F\u002F REJECTED: undisclosed network requests\nfetch('https:\u002F\u002Fanalytics.example.com\u002Ftrack', { body: ... });  \u002F\u002F No hidden telemetry\n\n\u002F\u002F APPROVED alternatives:\n\u002F\u002F - Bundle dependencies with esbuild (no runtime loading)\n\u002F\u002F - Use a debug flag for console statements\n\u002F\u002F - Document all network requests in README\n\u002F\u002F - Get explicit consent before any data leaves the device\n```\n\n## Output\n- SecureStorage class using Electron's safeStorage for encrypted credential storage\n- HTML and markdown sanitization for all external content\n- URI handler with action whitelist and path validation\n- Secure network request wrapper with HTTPS enforcement and domain allowlist\n- Platform-specific guards for desktop\u002Fmobile code paths\n- Plugin review rejection checklist with approved alternatives\n\n## Error Handling\n| Issue | Cause | Solution |\n|-------|-------|----------|\n| API key synced to cloud | Stored in `data.json` | Use `SecureStorage` with Electron `safeStorage` |\n| XSS in note preview | Unsanitized external HTML | Use `createEl` with `text` property, or `sanitizeHtml` |\n| Directory traversal via URI | Unvalidated path parameter | Strip `..`, normalize, validate within vault |\n| SSRF from user-provided URL | No domain allowlist | Validate against ALLOWED_DOMAINS before `requestUrl` |\n| Plugin rejected on review | `eval`, `console.log`, or telemetry | Follow rejection checklist (Step 6) |\n| `safeStorage` unavailable | Older Electron version or mobile | Fall back to per-session prompt |\n\n## Examples\n\n### Content Security for Custom Views\n```typescript\n\u002F\u002F When rendering external content in an ItemView\nasync onOpen() {\n  const externalData = await this.fetchData();\n  const container = this.containerEl.children[1];\n  container.empty();\n\n  \u002F\u002F Safe: text content is escaped by createEl\n  container.createEl('h3', { text: externalData.title });\n  container.createEl('p', { text: externalData.summary });\n\n  \u002F\u002F If you must render HTML, sanitize first\n  const safeHtml = sanitizeHtml(externalData.htmlContent);\n  const htmlContainer = container.createEl('div');\n  htmlContainer.innerHTML = safeHtml;\n}\n```\n\n### Audit Your Plugin for Security Issues\n```bash\n# Quick security audit of plugin source code\ngrep -rn 'eval(\\|new Function(' src\u002F --include=\"*.ts\" && echo \"FAIL: dynamic code execution\"\ngrep -rn 'innerHTML\\s*=' src\u002F --include=\"*.ts\" && echo \"WARN: check for XSS\"\ngrep -rn 'console\\.log' src\u002F --include=\"*.ts\" | grep -v '\u002F\u002F DEBUG' && echo \"WARN: console.log in prod\"\ngrep -rn 'apiKey\\|secret\\|password' src\u002F --include=\"*.ts\" && echo \"CHECK: credential handling\"\necho \"Done.\"\n```\n\n## Resources\n- [Obsidian Plugin Guidelines](https:\u002F\u002Fdocs.obsidian.md\u002FPlugins\u002FReleasing\u002FPlugin+guidelines)\n- [Electron Security](https:\u002F\u002Fwww.electronjs.org\u002Fdocs\u002Flatest\u002Ftutorial\u002Fsecurity)\n- [OWASP XSS Prevention](https:\u002F\u002Fcheatsheetseries.owasp.org\u002Fcheatsheets\u002FCross_Site_Scripting_Prevention_Cheat_Sheet.html)\n- [Obsidian requestUrl API](https:\u002F\u002Fdocs.obsidian.md\u002FReference\u002FTypeScript+API\u002FrequestUrl)\n\n## Next Steps\nFor production readiness checks, see `obsidian-prod-checklist`.\nFor deployment and community submission, see `obsidian-deploy-integration`.\n",{"name":5,"tags":24,"author":30,"license":15,"version":31,"description":32,"allowed-tools":33,"compatible-with":34},[25,26,27,28,29],"obsidian","security","authentication","privacy","electron","Jeremy Longshore \u003Cjeremy@intentsolutions.io>","2.0.0","Implement secure Obsidian plugin development practices. Covers credential\nstorage, input validation, XSS prevention, network security, URI handler\nsafety, and Electron security. Use when handling user data, storing API keys,\nmaking network requests, or preparing for community plugin submission.\nTrigger with phrases like \"obsidian security\", \"secure obsidian plugin\",\n\"obsidian data protection\", \"obsidian privacy\", \"obsidian api key storage\".\n","Read, Write, Edit, Grep","claude-code, codex, openclaw","main","99825ad3f3bcc6597ddcc7294a14e6e922f2b67b","skills\u002Fsaas-packs--obsidian-pack--obsidian-security-basics",0,"https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills","https:\u002F\u002Fgithub.com\u002Fjukeyman","https:\u002F\u002FRJBUSINESSSOLUTIONS.ORG","Credit and Finance Expert | Developer\r\n\r\nI'm Rick Jefferson, a seasoned credit and finance expert with over a decade of experience in financial literacy,","2026-07-13 07:03:29",{"source":8,"skillName":5,"commands":45,"prompt":55,"zipAvailable":56},[46,49,52],{"tool":47,"command":48},"npx","npx skills add jukeyman\u002Fjukeyman-skills --skill obsidian-security-basics",{"tool":50,"command":51},"bunx","bunx skills add jukeyman\u002Fjukeyman-skills --skill obsidian-security-basics",{"tool":53,"command":54},"pnpm","pnpm dlx skills add jukeyman\u002Fjukeyman-skills --skill obsidian-security-basics","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fsaas-packs--obsidian-pack--obsidian-security-basics\u002FSKILL.md",true,[],[59,66,73,80,87,95],{"skillNo":60,"name":61,"nameZh":6,"description":62,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":19},"01M79ANS2SM329NEP5ZCX106RR","zustand-store-creator","Create zustand store creator operations. Auto-activating skill for Frontend Development.\nTriggers on: zustand store creator, zustand store creator\nPart of the Frontend Development skill category. Use when working with zustand store creator functionality. Trigger with phrases like \"zustand store creator\", \"zustand creator\", \"zustand\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzustand-store-creator\u002FSKILL.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":19},"01M79AMZKP4YDEZ7EHG1Y7PP74","zero-trust-config-helper","Configure with zero trust config helper operations. Auto-activating skill for Security Advanced.\nTriggers on: zero trust config helper, zero trust config helper\nPart of the Security Advanced skill category. Use when configuring systems or services. Trigger with phrases like \"zero trust config helper\", \"zero helper\", \"zero\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzero-trust-config-helper\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":19},"01M79AMJSBCEJQNBTYNAHYN5HM","zapier-integration-helper","Assist with zapier integration helper operations. Auto-activating skill for Business Automation.\nTriggers on: zapier integration helper, zapier integration helper\nPart of the Business Automation skill category. Use when working with APIs or building integrations. Trigger with phrases like \"zapier integration helper\", \"zapier helper\", \"zapier\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzapier-integration-helper\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":19},"01M79AHJZGVMARS13VFQYRR1MP","yaml-config-validator","Validate yaml config validator operations. Auto-activating skill for DevOps Basics.\nTriggers on: yaml config validator, yaml config validator\nPart of the DevOps Basics skill category. Use when configuring systems or services. Trigger with phrases like \"yaml config validator\", \"yaml validator\", \"yaml\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fyaml-config-validator\u002FSKILL.md",[],[],{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":91,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":19},"01M79AHGDZRN0020RDQSQDPAM8","xvary-stock-research","Thesis-driven equity analysis from public SEC EDGAR and market data; \u002Fanalyze, \u002Fscore, \u002Fcompare workflows with bundled Python tools (Claude Code, Cursor, Codex).","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fxvary-stock-research\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fxvary-stock-research\u002FSKILL.md",[],[],{"skillNo":96,"name":97,"nameZh":6,"description":98,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":99,"categories":100,"keywords":101,"publishedAt":19},"01M79AHCYJ9FV9RMHQ24HDRN33","xss-vulnerability-scanner","Scan xss vulnerability scanner operations. Auto-activating skill for Security Fundamentals.\nTriggers on: xss vulnerability scanner, xss vulnerability scanner\nPart of the Security Fundamentals skill category. Use when working with xss vulnerability scanner functionality. Trigger with phrases like \"xss vulnerability scanner\", \"xss scanner\", \"xss\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fxss-vulnerability-scanner\u002FSKILL.md",[],[]]