fix(security): address CodeQL, OpenSSF Scorecard, and npm audit findings#12
fix(security): address CodeQL, OpenSSF Scorecard, and npm audit findings#12mirowolff merged 10 commits intobitbonsai:mainfrom
Conversation
Automated detection of security vulnerabilities in TypeScript code (path traversal, injection, prototype pollution) to protect users' personal vault data. Uses security-extended queries and runs weekly to catch new CVEs. Ref: https://docs.github.com/en/code-security/code-scanning/introduction-to-code-scanning/about-code-scanning-with-codeql
Prevent supply chain attacks through compromised dependencies by validating lockfile integrity and running npm audit on every PR. Lockfile validation detects dependency confusion attacks where package-lock.json diverges from declared dependencies. Refs: - https://docs.npmjs.com/cli/v10/commands/npm-audit - https://blog.npmjs.org/post/626173315965468672/npm-v7-series-why-keep-package-lockjson
Ensure known vulnerabilities (CVEs) in dependencies are patched promptly without manual tracking. Major updates stay as separate PRs for careful review of breaking changes. Ref: https://docs.github.com/en/code-security/dependabot/dependabot-security-updates/about-dependabot-security-updates
Allow users to verify that npm packages were built from this exact GitHub repository and commit, not from a compromised machine. Verification: npm audit signatures Requires NPM_TOKEN secret in repository settings. Ref: https://docs.npmjs.com/generating-provenance-statements
Automated evaluation of security practices (branch protection, dependency updates, signed releases, etc.) with results visible in GitHub Security tab. Helps identify gaps in project security hygiene. Ref: https://securityscorecards.dev/
Upgrade vitest 1.6.1 → 4.0.15 to resolve transitive vite/esbuild vulnerabilities. Sync lockfile with package.json 0.7.0. Refs: - GHSA-w48q-cv73-mx4w - GHSA-mh29-5h37-fv8m - GHSA-67mh-4wv8-2f99
Remove check-then-act patterns that were flagged by CodeQL as js/file-system-race vulnerabilities. Instead of access() followed by readFile/unlink/etc, handle ENOENT errors directly from the operation. Use writeFile with 'wx' flag for atomic "create if not exists" in moveNote(). Ref: https://cwe.mitre.org/data/definitions/367.html
The glob-to-regex conversion wasn't escaping special regex characters, allowing patterns with characters like . + $ etc to be misinterpreted. Also normalizes backslashes in patterns for Windows compatibility. Ref: https://codeql.github.com/codeql-query-help/javascript/js-incomplete-sanitization/
Predictable paths in /tmp are vulnerable to symlink attacks. mkdtemp creates directories with random suffixes, preventing local attackers from pre-creating malicious symlinks. Ref: https://codeql.github.com/codeql-query-help/javascript/js-insecure-temporary-file/
Define responsible disclosure process, security scope, and response timelines for vulnerability reports. Documents implemented security controls and clarifies what's in/out of scope for this project vs upstream (MCP protocol, Obsidian). Ref: https://docs.github.com/en/code-security/getting-started/adding-a-security-policy-to-your-repository
Version bump accounts for PR #12 security fixes (0.7.1) and website updates. Add comprehensive integration test suite covering: - End-to-end service layer workflows - Special characters in paths (parentheses, brackets, unicode, emoji) - Regex special chars in content - Security: path traversal and blocked directories - Multi-step workflows (search → read → update) - Performance regression tests All 102 tests passing.
|
@hellvinz Really appreciate this PR! Took some time to go through the changes properly - the TOCTOU fixes and regex After merging I added some integration tests to make sure everything plays nicely with the existing workflows. All 102 Merged as v0.7.2. Thanks for taking the time to strengthen the security here! 🙏 |
No problem! Thank you for writing this MCP server. I wanted to use it, but I wanted to be sure about my data too. |
Summary
This PR addresses security vulnerabilities identified by CodeQL, OpenSSF Scorecard, Dependabot, and npm audit, plus adds comprehensive test coverage.
Changes
Dependency Vulnerabilities (Dependabot + npm audit)
npm auditfindingsTOCTOU Race Conditions (
filesystem.ts)js/file-system-raceaccess()followed byreadFile/unlink)ENOENT/EACCESerrors directly from operationsRef: https://cwe.mitre.org/data/definitions/367.html
Regex Injection in Glob Patterns (
pathfilter.ts)js/incomplete-sanitizationbackup.2024/**from being misinterpretedRef: https://codeql.github.com/codeql-query-help/javascript/js-incomplete-sanitization/
OpenSSF Scorecard Findings
mkdtempfor unpredictable temp directories in testsSECURITY.mdwith vulnerability reporting guidelines